From cf844c583a8a732fbbffc40ccb59136729d8ef63 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Thu, 25 Jan 2024 23:41:23 +0000 Subject: [PATCH] Removing calls to flush that already have ASSERT_TIMELY checks immediately after. --- nano/core_test/active_transactions.cpp | 8 ++------ nano/core_test/confirmation_height.cpp | 5 +---- nano/core_test/gap_cache.cpp | 1 - nano/core_test/node.cpp | 8 -------- nano/core_test/websocket.cpp | 3 +-- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 74e32508..dbbb32cf 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -255,7 +255,6 @@ TEST (active_transactions, inactive_votes_cache) node.vote_processor.vote (vote, std::make_shared (node, node)); ASSERT_TIMELY_EQ (5s, node.vote_cache.size (), 1); node.process_active (send); - node.block_processor.flush (); ASSERT_TIMELY (5s, node.ledger.block_confirmed (node.store.tx_begin_read (), send->hash ())); ASSERT_EQ (1, node.stats.count (nano::stat::type::election, nano::stat::detail::vote_cached)); } @@ -356,7 +355,6 @@ TEST (active_transactions, inactive_votes_cache_existing_vote) .build_shared (); node.process_active (send); node.block_processor.add (open); - node.block_processor.flush (); ASSERT_TIMELY_EQ (5s, node.active.size (), 1); auto election (node.active.election (send->qualified_root ())); ASSERT_NE (nullptr, election); @@ -725,7 +723,7 @@ TEST (active_transactions, republish_winner) .build_shared (); node1.process_active (send1); - node1.block_processor.flush (); + ASSERT_TIMELY (5s, nano::test::exists (node1, { send1 })); ASSERT_TIMELY_EQ (3s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in), 1); // Several forks @@ -741,8 +739,8 @@ TEST (active_transactions, republish_winner) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (fork); + ASSERT_TIMELY (5s, node1.active.active (*fork)); } - node1.block_processor.flush (); ASSERT_TIMELY (3s, !node1.active.empty ()); ASSERT_EQ (1, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in)); @@ -764,7 +762,6 @@ TEST (active_transactions, republish_winner) auto vote = nano::test::make_final_vote (nano::dev::genesis_key, { fork }); node1.vote_processor.vote (vote, std::make_shared (node1, node1)); node1.vote_processor.flush (); - node1.block_processor.flush (); ASSERT_TIMELY (5s, election->confirmed ()); ASSERT_EQ (fork->hash (), election->status.winner->hash ()); ASSERT_TIMELY (5s, node2.block_confirmed (fork->hash ())); @@ -1055,7 +1052,6 @@ TEST (active_transactions, DISABLED_confirm_new) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send); - node1.block_processor.flush (); ASSERT_TIMELY_EQ (5s, 1, node1.active.size ()); auto & node2 = *system.add_node (); // Add key to node2 diff --git a/nano/core_test/confirmation_height.cpp b/nano/core_test/confirmation_height.cpp index 2271e498..15b6aa63 100644 --- a/nano/core_test/confirmation_height.cpp +++ b/nano/core_test/confirmation_height.cpp @@ -61,8 +61,7 @@ TEST (confirmation_height, single) ASSERT_EQ (nano::dev::genesis->hash (), confirmation_height_info.frontier); node->process_active (send1); - node->block_processor.flush (); - + ASSERT_TIMELY (5s, nano::test::exists (*node, { send1 })); ASSERT_TIMELY_EQ (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out), 1); { @@ -538,7 +537,6 @@ TEST (confirmation_height, gap_live) // Now complete the chain where the block comes in on the live network node->process_active (open1); - node->block_processor.flush (); ASSERT_TIMELY_EQ (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out), 6); @@ -1220,7 +1218,6 @@ TEST (confirmation_height, observers) add_callback_stats (*node1); node1->process_active (send1); - node1->block_processor.flush (); ASSERT_TIMELY_EQ (10s, node1->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out), 1); auto transaction = node1->store.tx_begin_read (); ASSERT_TRUE (node1->ledger.block_confirmed (transaction, send1->hash ())); diff --git a/nano/core_test/gap_cache.cpp b/nano/core_test/gap_cache.cpp index 7b6924e3..360e2ce2 100644 --- a/nano/core_test/gap_cache.cpp +++ b/nano/core_test/gap_cache.cpp @@ -163,7 +163,6 @@ TEST (gap_cache, two_dependencies) node1.block_processor.flush (); ASSERT_EQ (2, node1.gap_cache.size ()); node1.block_processor.add (send1); - node1.block_processor.flush (); ASSERT_TIMELY_EQ (5s, node1.gap_cache.size (), 0); ASSERT_TIMELY (5s, node1.store.block.exists (node1.store.tx_begin_read (), send1->hash ())); ASSERT_TIMELY (5s, node1.store.block.exists (node1.store.tx_begin_read (), send2->hash ())); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 36470a63..5ba5b9e2 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -575,7 +575,6 @@ TEST (node, fork_publish) .build_shared (); node1.work_generate_blocking (*send2); node1.process_active (send1); - node1.block_processor.flush (); ASSERT_TIMELY_EQ (5s, 1, node1.active.size ()); auto election (node1.active.election (send1->qualified_root ())); ASSERT_NE (nullptr, election); @@ -673,9 +672,7 @@ TEST (node, fork_keep) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); - node1.block_processor.flush (); node2.process_active (send1); - node2.block_processor.flush (); ASSERT_TIMELY_EQ (5s, 1, node1.active.size ()); ASSERT_TIMELY_EQ (5s, 1, node2.active.size ()); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); @@ -728,9 +725,7 @@ TEST (node, fork_flip) auto ignored_channel{ std::make_shared (node1, std::weak_ptr ()) }; node1.network.inbound (publish1, ignored_channel); - node1.block_processor.flush (); node2.network.inbound (publish2, ignored_channel); - node2.block_processor.flush (); ASSERT_TIMELY_EQ (5s, 1, node1.active.size ()); ASSERT_TIMELY_EQ (5s, 1, node2.active.size ()); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); @@ -2083,7 +2078,6 @@ TEST (node, online_reps_election) .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); - node1.block_processor.flush (); ASSERT_TIMELY_EQ (5s, 1, node1.active.size ()); // Process vote for ongoing election auto vote = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::milliseconds_since_epoch (), 0, std::vector{ send1->hash () }); @@ -2453,7 +2447,6 @@ TEST (node, local_votes_cache_fork) node_config.peering_port = system.get_available_port (); auto & node2 (*system.add_node (node_config, node_flags)); node2.process_active (send1_fork); - node2.block_processor.flush (); ASSERT_TIMELY (5s, node2.ledger.block_or_pruned_exists (send1->hash ())); } @@ -3337,7 +3330,6 @@ TEST (node, bidirectional_tcp) .work (*node1->work_generate_blocking (send1->hash ())) .build_shared (); node2->process_active (send2); - node2->block_processor.flush (); ASSERT_TIMELY (10s, node1->ledger.block_or_pruned_exists (send2->hash ()) && node2->ledger.block_or_pruned_exists (send2->hash ())); // Test block confirmation from node 2 (add representative to node 2) system.wallet (1)->insert_adhoc (nano::dev::genesis_key.prv); diff --git a/nano/core_test/websocket.cpp b/nano/core_test/websocket.cpp index 5a010d68..fb88af49 100644 --- a/nano/core_test/websocket.cpp +++ b/nano/core_test/websocket.cpp @@ -210,8 +210,7 @@ TEST (websocket, stopped_election) nano::publish publish1{ nano::dev::network_params.network, send1 }; auto channel1 = std::make_shared (*node1); node1->network.inbound (publish1, channel1); - node1->block_processor.flush (); - ASSERT_TIMELY (1s, node1->active.election (send1->qualified_root ())); + ASSERT_TIMELY (5s, node1->active.election (send1->qualified_root ())); node1->active.erase (*send1); ASSERT_TIMELY_EQ (5s, future.wait_for (0s), std::future_status::ready);