Skip to content

Commit f8abcb3

Browse files
committed
test: Fix intermittent failure in ChainStateManager tests
Before wiping the ChainStateManager, the validationinterface queue must be drained to avoid accessing deleted memory.
1 parent b759cef commit f8abcb3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,13 @@ struct SnapshotTestSetup : TestChain100Setup {
367367

368368
BOOST_TEST_MESSAGE("Simulating node restart");
369369
{
370-
LOCK(::cs_main);
371370
for (Chainstate* cs : chainman.GetAll()) {
371+
LOCK(::cs_main);
372372
cs->ForceFlushStateToDisk();
373373
}
374+
// Process all callbacks referring to the old manager before wiping it.
375+
SyncWithValidationInterfaceQueue();
376+
LOCK(::cs_main);
374377
chainman.ResetChainstates();
375378
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 0);
376379
const ChainstateManager::Options chainman_opts{

0 commit comments

Comments
 (0)