From 5f0b04eedc5bbdb9319c9f1f1a6c599337f5bbe3 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 7 Jun 2017 11:34:58 -0700 Subject: [PATCH] Replace rand() & ((1 << N) - 1) with randbits(N) --- src/test/coins_tests.cpp | 4 ++-- src/test/pmt_tests.cpp | 2 +- src/test/versionbits_tests.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index c923f8df2..27d8db8b9 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -155,11 +155,11 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test) newcoin.out.nValue = insecure_rand(); newcoin.nHeight = 1; if (insecure_randrange(16) == 0 && coin.IsSpent()) { - newcoin.out.scriptPubKey.assign(1 + (insecure_rand() & 0x3F), OP_RETURN); + newcoin.out.scriptPubKey.assign(1 + insecure_randbits(6), OP_RETURN); BOOST_CHECK(newcoin.out.scriptPubKey.IsUnspendable()); added_an_unspendable_entry = true; } else { - newcoin.out.scriptPubKey.assign(insecure_rand() & 0x3F, 0); // Random sizes so we can test memory usage accounting + newcoin.out.scriptPubKey.assign(insecure_randbits(6), 0); // Random sizes so we can test memory usage accounting (coin.IsSpent() ? added_an_entry : updated_an_entry) = true; coin = newcoin; } diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index d07a9f395..32086ead5 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1) std::vector vMatch(nTx, false); std::vector vMatchTxid1; for (unsigned int j=0; j