From 9da36074655c3c1af88f6ed73185da85268dc0ac Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Fri, 26 Jan 2024 16:47:10 +0000 Subject: [PATCH] Rewriting tests to not use block_processor::flush. --- nano/core_test/confirmation_height.cpp | 8 ++------ nano/core_test/node.cpp | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/nano/core_test/confirmation_height.cpp b/nano/core_test/confirmation_height.cpp index fb8b97c3f1..a57657b580 100644 --- a/nano/core_test/confirmation_height.cpp +++ b/nano/core_test/confirmation_height.cpp @@ -1497,17 +1497,13 @@ TEST (confirmation_height, callback_confirmed_history) add_callback_stats (*node); node->process_active (send1); - ASSERT_NE (nano::test::start_election (system, *node, send1->hash ()), nullptr); + std::shared_ptr election; + ASSERT_TIMELY (5s, election = nano::test::start_election (system, *node, send1->hash ())); { - node->process_active (send); - node->block_processor.flush (); - // The write guard prevents the confirmation height processor doing any writes auto write_guard = node->write_database_queue.wait (nano::writer::testing); // Confirm send1 - auto election = node->active.election (send1->qualified_root ()); - ASSERT_NE (nullptr, election); election->force_confirm (); ASSERT_TIMELY_EQ (10s, node->active.size (), 0); ASSERT_EQ (0, node->active.recently_cemented.list ().size ()); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index ae4d6865c0..61b59ab008 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2992,8 +2992,7 @@ TEST (node, block_processor_reject_state) send1->signature.bytes[0] ^= 1; ASSERT_FALSE (node.ledger.block_or_pruned_exists (send1->hash ())); node.process_active (send1); - auto flushed = std::async (std::launch::async, [&node] { node.block_processor.flush (); }); - ASSERT_NE (std::future_status::timeout, flushed.wait_for (5s)); + ASSERT_TIMELY_EQ (5s, 1, node.stats.count (nano::stat::type::blockprocessor, nano::stat::detail::bad_signature)); ASSERT_FALSE (node.ledger.block_or_pruned_exists (send1->hash ())); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) @@ -3005,9 +3004,7 @@ TEST (node, block_processor_reject_state) .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); node.process_active (send2); - auto flushed2 = std::async (std::launch::async, [&node] { node.block_processor.flush (); }); - ASSERT_NE (std::future_status::timeout, flushed2.wait_for (5s)); - ASSERT_TRUE (node.ledger.block_or_pruned_exists (send2->hash ())); + ASSERT_TIMELY (5s, node.ledger.block_or_pruned_exists (send2->hash ())); } TEST (node, block_processor_full)