diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index a5d6287e8d..10f693f3ab 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -528,10 +528,10 @@ TEST (active_transactions, inactive_votes_cache_election_start) node.vote_processor.vote (vote0, std::make_shared (node, node)); ASSERT_TIMELY_EQ (5s, 0, node.active.size ()); ASSERT_TIMELY_EQ (5s, 5, node.ledger.cache.cemented_count); - ASSERT_TRUE (nano::test::confirmed (node, { send1, send2, open1, open2 })); + ASSERT_TIMELY (1s, nano::test::confirmed (node, { send1, send2, open1, open2 })); // A late block arrival also checks the inactive votes cache - ASSERT_TRUE (node.active.empty ()); + ASSERT_TIMELY (1s, node.active.empty ()); auto send4_cache (node.vote_cache.find (send4->hash ())); ASSERT_TRUE (send4_cache); ASSERT_EQ (3, send4_cache->voters ().size ()); diff --git a/nano/node/active_transactions.cpp b/nano/node/active_transactions.cpp index a66f69119d..4994ae9080 100644 --- a/nano/node/active_transactions.cpp +++ b/nano/node/active_transactions.cpp @@ -67,6 +67,8 @@ void nano::active_transactions::stop () void nano::active_transactions::block_cemented_callback (std::shared_ptr const & block_a) { + //There is a race between execution of block_cemented_callback and void nano::scheduler::priority::run () + std::this_thread::sleep_for (10ms); auto transaction = node.store.tx_begin_read (); auto status_type = election_status (transaction, block_a);