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.
This commit is contained in:
@@ -164,14 +164,23 @@ 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();
|
||||
@@ -304,6 +313,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) {
|
||||
|
||||
Reference in New Issue
Block a user