From f8abcb3e3b2e731c002ec88f7559c21e26a2c079 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 27 Mar 2023 15:09:23 -0400 Subject: test: Fix intermittent failure in ChainStateManager tests Before wiping the ChainStateManager, the validationinterface queue must be drained to avoid accessing deleted memory. --- src/test/validation_chainstatemanager_tests.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp index 688aafdd46..edc7e4b70a 100644 --- a/src/test/validation_chainstatemanager_tests.cpp +++ b/src/test/validation_chainstatemanager_tests.cpp @@ -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{ -- cgit v1.2.3