mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-23 21:39:13 +02:00
scripted-diff: Use randbits/bool instead of randrange where possible
-BEGIN VERIFY SCRIPT- sed -i 's/insecure_randbits(1)/insecure_randbool()/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(2)/insecure_randbool()/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(4)/insecure_randbits(2)/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(32)/insecure_randbits(5)/g' src/test/*_tests.cpp sed -i 's/insecure_randrange(256)/insecure_randbits(8)/g' src/test/*_tests.cpp -END VERIFY SCRIPT-
This commit is contained in:
@@ -43,7 +43,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
coin = it->second;
|
||||
if (coin.IsSpent() && insecure_randrange(2) == 0) {
|
||||
if (coin.IsSpent() && insecure_randbool() == 0) {
|
||||
// Randomly return false in case of an empty entry.
|
||||
return false;
|
||||
}
|
||||
@@ -200,20 +200,20 @@ 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) {
|
||||
if (stack.size() > 1 && insecure_randbool() == 0) {
|
||||
unsigned int flushIndex = insecure_randrange(stack.size() - 1);
|
||||
stack[flushIndex]->Flush();
|
||||
}
|
||||
}
|
||||
if (insecure_randrange(100) == 0) {
|
||||
// Every 100 iterations, change the cache stack.
|
||||
if (stack.size() > 0 && insecure_randrange(2) == 0) {
|
||||
if (stack.size() > 0 && insecure_randbool() == 0) {
|
||||
//Remove the top cache
|
||||
stack.back()->Flush();
|
||||
delete stack.back();
|
||||
stack.pop_back();
|
||||
}
|
||||
if (stack.size() == 0 || (stack.size() < 4 && insecure_randrange(2))) {
|
||||
if (stack.size() == 0 || (stack.size() < 4 && insecure_randbool())) {
|
||||
//Add a new cache
|
||||
CCoinsView* tip = &base;
|
||||
if (stack.size() > 0) {
|
||||
@@ -433,19 +433,19 @@ 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) {
|
||||
if (stack.size() > 1 && insecure_randbool() == 0) {
|
||||
unsigned int flushIndex = insecure_randrange(stack.size() - 1);
|
||||
stack[flushIndex]->Flush();
|
||||
}
|
||||
}
|
||||
if (insecure_randrange(100) == 0) {
|
||||
// Every 100 iterations, change the cache stack.
|
||||
if (stack.size() > 0 && insecure_randrange(2) == 0) {
|
||||
if (stack.size() > 0 && insecure_randbool() == 0) {
|
||||
stack.back()->Flush();
|
||||
delete stack.back();
|
||||
stack.pop_back();
|
||||
}
|
||||
if (stack.size() == 0 || (stack.size() < 4 && insecure_randrange(2))) {
|
||||
if (stack.size() == 0 || (stack.size() < 4 && insecure_randbool())) {
|
||||
CCoinsView* tip = &base;
|
||||
if (stack.size() > 0) {
|
||||
tip = stack.back();
|
||||
|
||||
Reference in New Issue
Block a user