test: Avoid unsafe memory race in baseindex_no_commit_ahead_of_flush

Without the drain, a BlockConnected event may execute during shutdown
and lead to memory races.
This commit is contained in:
MarcoFalke
2026-09-02 16:47:51 +02:00
parent fa0f14ef5e
commit fab80e82c1

View File

@@ -84,6 +84,10 @@ BOOST_FIXTURE_TEST_CASE(baseindex_no_commit_ahead_of_flush, TestChain100Setup)
// Reload index to see which block data was actually committed. // Reload index to see which block data was actually committed.
BOOST_REQUIRE(index->Init()); BOOST_REQUIRE(index->Init());
BOOST_CHECK_EQUAL(index->GetSummary().best_block_height, expected_commit_height); BOOST_CHECK_EQUAL(index->GetSummary().best_block_height, expected_commit_height);
// Drain in-flight validation callbacks before destroying the index.
m_node.chain->context()->validation_signals->SyncWithValidationInterfaceQueue();
// shutdown sequence (c.f. Shutdown() in init.cpp)
index->Stop(); index->Stop();
}; };