Replace more rand() % NUM by randranges

This commit is contained in:
Pieter Wuille
2017-06-07 11:34:55 -07:00
parent efee1db21a
commit 3ecabae363
7 changed files with 19 additions and 19 deletions

View File

@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
for (unsigned int i = 0; i < NUM_SIMULATION_ITERATIONS; i++) {
// Do a random modification.
{
uint256 txid = txids[insecure_rand() % txids.size()]; // txid we're going to modify in this iteration.
uint256 txid = txids[insecure_randrange(txids.size())]; // txid we're going to modify in this iteration.
Coin& coin = result[COutPoint(txid, 0)];
const Coin& entry = (insecure_randrange(500) == 0) ? AccessByTxid(*stack.back(), txid) : stack.back()->AccessCoin(COutPoint(txid, 0));
BOOST_CHECK(coin == entry);
@@ -201,7 +201,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
if (insecure_randrange(100) == 0) {
// Every 100 iterations, flush an intermediate cache
if (stack.size() > 1 && insecure_randrange(2) == 0) {
unsigned int flushIndex = insecure_rand() % (stack.size() - 1);
unsigned int flushIndex = insecure_randrange(stack.size() - 1);
stack[flushIndex]->Flush();
}
}
@@ -434,7 +434,7 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
if (insecure_randrange(100) == 0) {
// Every 100 iterations, flush an intermediate cache
if (stack.size() > 1 && insecure_randrange(2) == 0) {
unsigned int flushIndex = insecure_rand() % (stack.size() - 1);
unsigned int flushIndex = insecure_randrange(stack.size() - 1);
stack[flushIndex]->Flush();
}
}