test: Avoid unsafe memory race in index_reorg_crash shutdown

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

View File

@@ -230,6 +230,10 @@ BOOST_FIXTURE_TEST_CASE(index_reorg_crash, TestChain100Setup)
promise.set_value();
// Wait for the index to reach the new tip
func_wait_until(blocking_height + 2, 5s);
// Drain unused BlockConnected events, to avoid unsafe memory races during destruction
m_node.chain->context()->validation_signals->SyncWithValidationInterfaceQueue();
// shutdown sequence (c.f. Shutdown() in init.cpp)
index.Stop();
}