mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-12 15:49:31 +02:00
Replace more rand() % NUM by randranges
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user