0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

test: Fix intermittent failure in ChainStateManager tests

Before wiping the ChainStateManager, the validationinterface
queue must be drained to avoid accessing deleted memory.
This commit is contained in:
Martin Zumsande 2023-03-27 15:09:23 -04:00
parent b759cefe93
commit f8abcb3e3b

View file

@ -367,10 +367,13 @@ struct SnapshotTestSetup : TestChain100Setup {
BOOST_TEST_MESSAGE("Simulating node restart");
{
LOCK(::cs_main);
for (Chainstate* cs : chainman.GetAll()) {
LOCK(::cs_main);
cs->ForceFlushStateToDisk();
}
// Process all callbacks referring to the old manager before wiping it.
SyncWithValidationInterfaceQueue();
LOCK(::cs_main);
chainman.ResetChainstates();
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 0);
const ChainstateManager::Options chainman_opts{