diff options
author | Alex Morcos <morcos@chaincode.com> | 2015-03-26 13:52:10 -0400 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2015-11-18 12:03:50 -0500 |
commit | 072e2f864445bc6ef3b390255f08c9e8bec2ea94 (patch) | |
tree | b1781d992e08263efa1b03b5f00f8f9c08760ac2 /src/test | |
parent | 73fa5e604356ab4182971376fd758b4680737b5a (diff) |
Alter assumptions in CCoinsViewCache::BatchWrite
Previously it would break if you flushed a parent cache while there was a child cache referring to it. This change will allow the flushing of parent caches.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/coins_tests.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 946f904dfa..9489a19f63 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -165,13 +165,22 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test) } if (insecure_rand() % 100 == 0) { + // Every 100 iterations, flush an intermediate cache + if (stack.size() > 1 && insecure_rand() % 2 == 0) { + unsigned int flushIndex = insecure_rand() % (stack.size() - 1); + stack[flushIndex]->Flush(); + } + } + if (insecure_rand() % 100 == 0) { // Every 100 iterations, change the cache stack. if (stack.size() > 0 && insecure_rand() % 2 == 0) { + //Remove the top cache stack.back()->Flush(); delete stack.back(); stack.pop_back(); } if (stack.size() == 0 || (stack.size() < 4 && insecure_rand() % 2)) { + //Add a new cache CCoinsView* tip = &base; if (stack.size() > 0) { tip = stack.back(); @@ -305,6 +314,13 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test) } if (insecure_rand() % 100 == 0) { + // Every 100 iterations, flush an intermediate cache + if (stack.size() > 1 && insecure_rand() % 2 == 0) { + unsigned int flushIndex = insecure_rand() % (stack.size() - 1); + stack[flushIndex]->Flush(); + } + } + if (insecure_rand() % 100 == 0) { // Every 100 iterations, change the cache stack. if (stack.size() > 0 && insecure_rand() % 2 == 0) { stack.back()->Flush(); |