diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 21c8931970..581041a802 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -127,8 +127,7 @@ TEST (active_transactions, confirm_frontier) // we cannot use the same block instance on 2 different nodes, so make a copy auto send_copy = builder.make_block ().from (*send).build (); ASSERT_TRUE (nano::test::process (node1, { send_copy })); - ASSERT_TRUE (nano::test::start_elections (system, node1, { send_copy })); - ASSERT_TIMELY (5s, nano::test::confirmed (node1, { send_copy })); + nano::test::confirm (node1.ledger, send_copy); } // The rep crawler would otherwise request confirmations in order to find representatives @@ -192,14 +191,7 @@ TEST (active_transactions, keep_local) ASSERT_NE (nullptr, send6); // force-confirm blocks - for (auto const & block : { send1, send2, send3, send4, send5, send6 }) - { - std::shared_ptr election{}; - ASSERT_TIMELY (5s, (election = node.active.election (block->qualified_root ())) != nullptr); - node.process_confirmed (nano::election_status{ block }); - election->force_confirm (); - ASSERT_TIMELY (5s, node.block_confirmed (block->hash ())); - } + nano::test::confirm (node.ledger, send6); nano::state_block_builder builder{}; const auto receive1 = builder.make_block () diff --git a/nano/core_test/bootstrap.cpp b/nano/core_test/bootstrap.cpp index 09c8bc08fa..e23a92e438 100644 --- a/nano/core_test/bootstrap.cpp +++ b/nano/core_test/bootstrap.cpp @@ -955,8 +955,7 @@ TEST (bootstrap_processor, lazy_hash_pruning) std::vector> blocks = { send1, receive1, change1, change2, send2, receive2, send3, receive3 }; ASSERT_TRUE (nano::test::process (*node0, blocks)); - ASSERT_TRUE (nano::test::start_elections (system, *node0, blocks, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (*node0, blocks)); + nano::test::confirm (node0->ledger, blocks); config.peering_port = system.get_available_port (); auto node1 = system.make_disconnected_node (config, node_flags); @@ -969,12 +968,7 @@ TEST (bootstrap_processor, lazy_hash_pruning) ASSERT_TIMELY (5s, nano::test::exists (*node1, { send1, receive1, change1, change2 })); // Confirm last block to prune previous - ASSERT_TRUE (nano::test::start_elections (system, *node1, { send1, receive1, change1, change2 }, true)); - ASSERT_TIMELY (5s, node1->block_confirmed (send1->hash ())); - ASSERT_TIMELY (5s, node1->block_confirmed (receive1->hash ())); - ASSERT_TIMELY (5s, node1->block_confirmed (change1->hash ())); - ASSERT_TIMELY (5s, node1->block_confirmed (change2->hash ())); - ASSERT_TIMELY (5s, node1->active.empty ()); + nano::test::confirm (node1->ledger, { send1, receive1, change1, change2 }); ASSERT_EQ (5, node1->ledger.block_count ()); ASSERT_EQ (5, node1->ledger.cemented_count ()); @@ -1922,8 +1916,7 @@ TEST (frontier_req, confirmed_frontier) ASSERT_EQ (receive2->hash (), request5->frontier); // Confirm account before genesis (confirmed only) - ASSERT_TRUE (nano::test::start_elections (system, *node1, { send1, receive1 }, true)); - ASSERT_TIMELY (5s, node1->block_confirmed (send1->hash ()) && node1->block_confirmed (receive1->hash ())); + nano::test::confirm (node1->ledger, receive1); auto connection6 (std::make_shared (std::make_shared (*node1, nano::transport::socket_endpoint::server), node1)); auto req6 = std::make_unique (nano::dev::network_params.network); req6->start = key_before_genesis.pub; @@ -1937,8 +1930,7 @@ TEST (frontier_req, confirmed_frontier) ASSERT_EQ (receive1->hash (), request6->frontier); // Confirm account after genesis (confirmed only) - ASSERT_TRUE (nano::test::start_elections (system, *node1, { send2, receive2 }, true)); - ASSERT_TIMELY (5s, node1->block_confirmed (send2->hash ()) && node1->block_confirmed (receive2->hash ())); + nano::test::confirm (node1->ledger, receive2); auto connection7 (std::make_shared (std::make_shared (*node1, nano::transport::socket_endpoint::server), node1)); auto req7 = std::make_unique (nano::dev::network_params.network); req7->start = key_after_genesis.pub; diff --git a/nano/core_test/election.cpp b/nano/core_test/election.cpp index ac80c52885..c4de4c418e 100644 --- a/nano/core_test/election.cpp +++ b/nano/core_test/election.cpp @@ -289,8 +289,7 @@ TEST (election, continuous_voting) .build (); ASSERT_TRUE (nano::test::process (node1, { send1 })); - ASSERT_TRUE (nano::test::start_elections (system, node1, { send1 }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (node1, { send1 })); + nano::test::confirm (node1.ledger, send1); node1.stats.clear (); diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index da56b816d8..9ec7a830ec 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2168,8 +2168,7 @@ TEST (node, vote_by_hash_bundle) } // Confirming last block will confirm whole chain and allow us to generate votes for those blocks later - ASSERT_TRUE (nano::test::start_elections (system, node, { blocks.back () }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.back () })); + nano::test::confirm (node.ledger, blocks.back ()); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; @@ -2347,8 +2346,7 @@ TEST (node, epoch_conflict_confirm) ASSERT_TRUE (nano::test::process (node1, { send, send2, open })); // Confirm open block in node1 to allow generating votes - ASSERT_TRUE (nano::test::start_elections (system, node1, { open }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (node1, { open })); + nano::test::confirm (node1.ledger, open); // Process initial blocks on node0 ASSERT_TRUE (nano::test::process (node0, { send, send2, open })); @@ -3033,8 +3031,7 @@ TEST (node, rollback_vote_self) // Process and mark the first 2 blocks as confirmed to allow voting ASSERT_TRUE (nano::test::process (node, { send1, open })); - ASSERT_TRUE (nano::test::start_elections (system, node, { send1, open }, true)); - ASSERT_TIMELY_EQ (5s, node.ledger.cemented_count (), 3); + nano::test::confirm (node.ledger, open); // wait until the rep weights have caught up with the weight transfer ASSERT_TIMELY_EQ (5s, nano::dev::constants.genesis_amount / 2, node.weight (key.pub)); @@ -3869,4 +3866,4 @@ TEST (node, process_local_overflow) auto result = node.process_local (send1); ASSERT_FALSE (result); -} \ No newline at end of file +} diff --git a/nano/core_test/optimistic_scheduler.cpp b/nano/core_test/optimistic_scheduler.cpp index 1fc1deac86..4356b54a82 100644 --- a/nano/core_test/optimistic_scheduler.cpp +++ b/nano/core_test/optimistic_scheduler.cpp @@ -26,8 +26,7 @@ TEST (optimistic_scheduler, activate_one) auto & [account, blocks] = chains.front (); // Confirm block towards at the beginning the chain, so gap between confirmation and account frontier is larger than `gap_threshold` - ASSERT_TRUE (nano::test::start_elections (system, node, { blocks.at (11) }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.at (11) })); + nano::test::confirm (node.ledger, blocks.at (11)); // Ensure unconfirmed account head block gets activated auto const & block = blocks.back (); @@ -95,8 +94,7 @@ TEST (optimistic_scheduler, under_gap_threshold) auto & [account, blocks] = chains.front (); // Confirm block towards the end of the chain, so gap between confirmation and account frontier is less than `gap_threshold` - ASSERT_TRUE (nano::test::start_elections (system, node, { blocks.at (55) }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.at (55) })); + nano::test::confirm (node.ledger, blocks.at (55)); // Manually trigger backlog scan node.backlog.trigger (); diff --git a/nano/rpc_test/receivable.cpp b/nano/rpc_test/receivable.cpp index bc39f85c57..289797ace4 100644 --- a/nano/rpc_test/receivable.cpp +++ b/nano/rpc_test/receivable.cpp @@ -147,8 +147,7 @@ TEST (rpc, receivable_unconfirmed) ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0)); request.put ("include_only_confirmed", "false"); ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1)); - ASSERT_TRUE (nano::test::start_elections (system, *node, { block1->hash () }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (*node, { block1 })); + nano::test::confirm (node->ledger, block1); request.put ("include_only_confirmed", "true"); ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1)); } @@ -550,8 +549,7 @@ TEST (rpc, accounts_receivable_confirmed) ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0)); request.put ("include_only_confirmed", "false"); ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1)); - ASSERT_TRUE (nano::test::start_elections (system, *node, { block1->hash () }, true)); - ASSERT_TIMELY (5s, nano::test::confirmed (*node, { block1 })); + nano::test::confirm (node->ledger, block1); request.put ("include_only_confirmed", "true"); ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1)); } diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 3032daf5de..3a96b99c80 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -1259,11 +1259,7 @@ TEST (rpc, history_pruning) ASSERT_TIMELY (5s, nano::test::exists (*node0, blocks)); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - ASSERT_TRUE (nano::test::start_elections (system, *node0, blocks, true)); - ASSERT_TIMELY (5s, node0->block_confirmed (uchange->hash ())); - nano::confirmation_height_info confirmation_height_info; - node0->store.confirmation_height.get (node0->store.tx_begin_read (), nano::dev::genesis_key.pub, confirmation_height_info); - ASSERT_EQ (7, confirmation_height_info.height); + nano::test::confirm (node0->ledger, blocks); // Prune block "change" { @@ -5889,11 +5885,8 @@ TEST (rpc, block_confirmed) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build (); - node->process_active (send); - ASSERT_TRUE (nano::test::start_elections (system, *node, { send }, true)); - - // Wait until the confirmation height has been set - ASSERT_TIMELY (5s, node->ledger.confirmed.block_exists_or_pruned (node->ledger.tx_begin_read (), send->hash ()) && !node->confirming_set.exists (send->hash ())); + ASSERT_EQ (nano::block_status::progress, node->ledger.process (node->ledger.tx_begin_write (), send)); + nano::test::confirm (node->ledger, send); // Requesting confirmation for this should now succeed request.put ("hash", send->hash ().to_string ());