mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Merge #12516: Avoid unintentional unsigned integer wraparounds in tests
2736c9e05
Avoid unintentional unsigned integer wraparounds in tests (practicalswift)
Pull request description:
Avoid unintentional unsigned integer wraparounds in tests.
This is a subset of #11535 as suggested by @MarcoFalke :-)
Tree-SHA512: 4f4ee8a08870101a3f7451aefa77ae06aaf44e3c3b2f7555faa2b8a8503f97f34e34dffcf65154278f15767dc9823955f52d1aa7b39930b390e57cdf2b65e0f3
This commit is contained in:
commit
7f99964321
@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(PrevectorTestInt)
|
||||
test.erase(InsecureRandRange(test.size()));
|
||||
}
|
||||
if (InsecureRandBits(3) == 2) {
|
||||
int new_size = std::max<int>(0, std::min<int>(30, test.size() + (InsecureRandRange(5)) - 2));
|
||||
int new_size = std::max(0, std::min(30, (int)test.size() + (int)InsecureRandRange(5) - 2));
|
||||
test.resize(new_size);
|
||||
}
|
||||
if (InsecureRandBits(3) == 3) {
|
||||
|
@ -56,8 +56,8 @@ BOOST_AUTO_TEST_CASE(manythreads)
|
||||
int counter[10] = { 0 };
|
||||
FastRandomContext rng(42);
|
||||
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
|
||||
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + rc.randrange(1012); }; // [-11, 1000]
|
||||
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + rc.randrange(2001); }; // [-1000, 1000]
|
||||
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + (int)rc.randrange(1012); }; // [-11, 1000]
|
||||
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + (int)rc.randrange(2001); }; // [-1000, 1000]
|
||||
|
||||
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
|
||||
boost::chrono::system_clock::time_point now = start;
|
||||
|
@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
||||
wtx.mapValue["comment"] = "y";
|
||||
{
|
||||
CMutableTransaction tx(*wtx.tx);
|
||||
--tx.nLockTime; // Just to change the hash :)
|
||||
++tx.nLockTime; // Just to change the hash :)
|
||||
wtx.SetTx(MakeTransactionRef(std::move(tx)));
|
||||
}
|
||||
pwalletMain->AddToWallet(wtx);
|
||||
@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
||||
wtx.mapValue["comment"] = "x";
|
||||
{
|
||||
CMutableTransaction tx(*wtx.tx);
|
||||
--tx.nLockTime; // Just to change the hash :)
|
||||
++tx.nLockTime; // Just to change the hash :)
|
||||
wtx.SetTx(MakeTransactionRef(std::move(tx)));
|
||||
}
|
||||
pwalletMain->AddToWallet(wtx);
|
||||
|
Loading…
Reference in New Issue
Block a user