Skip to content

Commit 7f99964

Browse files
committed
Merge #12516: Avoid unintentional unsigned integer wraparounds in tests
2736c9e 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
2 parents 6645eaf + 2736c9e commit 7f99964

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/test/prevector_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ BOOST_AUTO_TEST_CASE(PrevectorTestInt)
206206
test.erase(InsecureRandRange(test.size()));
207207
}
208208
if (InsecureRandBits(3) == 2) {
209-
int new_size = std::max<int>(0, std::min<int>(30, test.size() + (InsecureRandRange(5)) - 2));
209+
int new_size = std::max(0, std::min(30, (int)test.size() + (int)InsecureRandRange(5) - 2));
210210
test.resize(new_size);
211211
}
212212
if (InsecureRandBits(3) == 3) {

src/test/scheduler_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ BOOST_AUTO_TEST_CASE(manythreads)
5656
int counter[10] = { 0 };
5757
FastRandomContext rng(42);
5858
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
59-
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + rc.randrange(1012); }; // [-11, 1000]
60-
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + rc.randrange(2001); }; // [-1000, 1000]
59+
auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + (int)rc.randrange(1012); }; // [-11, 1000]
60+
auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + (int)rc.randrange(2001); }; // [-1000, 1000]
6161

6262
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
6363
boost::chrono::system_clock::time_point now = start;

src/wallet/test/accounting_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
8282
wtx.mapValue["comment"] = "y";
8383
{
8484
CMutableTransaction tx(*wtx.tx);
85-
--tx.nLockTime; // Just to change the hash :)
85+
++tx.nLockTime; // Just to change the hash :)
8686
wtx.SetTx(MakeTransactionRef(std::move(tx)));
8787
}
8888
pwalletMain->AddToWallet(wtx);
@@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
9292
wtx.mapValue["comment"] = "x";
9393
{
9494
CMutableTransaction tx(*wtx.tx);
95-
--tx.nLockTime; // Just to change the hash :)
95+
++tx.nLockTime; // Just to change the hash :)
9696
wtx.SetTx(MakeTransactionRef(std::move(tx)));
9797
}
9898
pwalletMain->AddToWallet(wtx);

0 commit comments

Comments
 (0)