Remove nano::test::confirm as it has been functionally superseded by nano::test::start_elections which uses a nano::system to poll.
This function both started an election and returned whether the block was confirmed. This is an asynchronous operation which required thread blocking. Instead, use start_elections which has polling semantics.
This commit is contained in:
parent
f74ebde5ba
commit
00cf95f204
10 changed files with 18 additions and 65 deletions
|
@ -1118,7 +1118,7 @@ TEST (confirmation_height, conflict_rollback_cemented)
|
|||
.work (*system.work.generate (genesis_hash))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*fork1a).code);
|
||||
ASSERT_TRUE (nano::test::confirm (*node1, { fork1a }));
|
||||
nano::test::start_elections (system, *node1, { fork1a }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (*node1, { fork1a }));
|
||||
|
||||
// create the other side of the fork on node2
|
||||
|
|
|
@ -288,7 +288,7 @@ TEST (election, continuous_voting)
|
|||
.build_shared ();
|
||||
|
||||
ASSERT_TRUE (nano::test::process (node1, { send1 }));
|
||||
ASSERT_TIMELY (5s, nano::test::confirm (node1, { send1 }));
|
||||
nano::test::start_elections (system, node1, { send1 }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node1, { send1 }));
|
||||
|
||||
node1.stats.clear ();
|
||||
|
|
|
@ -2573,7 +2573,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_TIMELY (5s, nano::test::confirm (node, { blocks.back () }));
|
||||
nano::test::start_elections (system, node, { blocks.back () }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.back () }));
|
||||
|
||||
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
|
||||
|
@ -2752,7 +2752,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_TIMELY (5s, nano::test::confirm (node1, { open }));
|
||||
nano::test::start_elections (system, node1, { open }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node1, { open }));
|
||||
|
||||
// Process initial blocks on node0
|
||||
|
@ -2766,7 +2766,7 @@ TEST (node, epoch_conflict_confirm)
|
|||
ASSERT_TIMELY (5s, nano::test::exists (node1, { change, epoch_open }));
|
||||
|
||||
// Confirm initial blocks in node1 to allow generating votes later
|
||||
ASSERT_TIMELY (5s, nano::test::confirm (node1, { change, epoch_open, send2 }));
|
||||
nano::test::start_elections (system, node1, { change, epoch_open, send2 }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node1, { change, epoch_open, send2 }));
|
||||
|
||||
// Start elections for node0 for conflicting change and epoch_open blocks (those two blocks have the same root)
|
||||
|
@ -3481,7 +3481,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_TIMELY (5s, nano::test::confirm (node, { send1, open }));
|
||||
nano::test::start_elections (system, node, { send1, open }, true);
|
||||
ASSERT_TIMELY (5s, node.ledger.cache.cemented_count == 3);
|
||||
|
||||
// wait until the rep weights have caught up with the weight transfer
|
||||
|
|
|
@ -24,7 +24,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::confirm (node, { blocks.at (11) }));
|
||||
nano::test::start_elections (system, node, { blocks.at (11) }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.at (11) }));
|
||||
|
||||
// Ensure unconfirmed account head block gets activated
|
||||
|
@ -93,7 +93,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::confirm (node, { blocks.at (55) }));
|
||||
nano::test::start_elections (system, node, { blocks.at (55) }, true);
|
||||
ASSERT_TIMELY (5s, nano::test::confirmed (node, { blocks.at (55) }));
|
||||
|
||||
// Manually trigger backlog scan
|
||||
|
|
|
@ -144,7 +144,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));
|
||||
nano::test::confirm (*node, { block1->hash () });
|
||||
nano::test::start_elections (system, *node, { block1->hash () }, true);
|
||||
ASSERT_TIMELY (5s, !node->active.active (*block1));
|
||||
request.put ("include_only_confirmed", "true");
|
||||
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
||||
|
@ -548,7 +548,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));
|
||||
nano::test::confirm (*node, { block1->hash () });
|
||||
nano::test::start_elections (system, *node, { block1->hash () }, true);
|
||||
ASSERT_TIMELY (5s, !node->active.active (*block1));
|
||||
request.put ("include_only_confirmed", "true");
|
||||
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
||||
|
|
|
@ -1246,10 +1246,7 @@ TEST (rpc, history_pruning)
|
|||
ASSERT_TIMELY (5s, nano::test::exists (*node0, blocks));
|
||||
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);
|
||||
|
||||
// WORKAROUND: this is called repeatedly inside an assert timely because nano::test::confirm()
|
||||
// uses block_processor.flush internally which can fail to flush
|
||||
ASSERT_TIMELY (5s, nano::test::confirm (*node0, blocks));
|
||||
|
||||
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);
|
||||
|
@ -5880,7 +5877,7 @@ TEST (rpc, block_confirmed)
|
|||
.work (*system.work.generate (latest))
|
||||
.build_shared ();
|
||||
node->process_active (send);
|
||||
ASSERT_TIMELY (5s, nano::test::confirm (*node, { send }));
|
||||
nano::test::start_elections (system, *node, { send }, true);
|
||||
|
||||
// Wait until the confirmation height has been set
|
||||
ASSERT_TIMELY (5s, node->ledger.block_confirmed (node->store.tx_begin_read (), send->hash ()) && !node->confirmation_height_processor.is_processing_block (send->hash ()));
|
||||
|
|
|
@ -38,7 +38,7 @@ nano::keypair setup_rep (nano::test::system & system, nano::node & node, nano::u
|
|||
.build_shared ();
|
||||
|
||||
EXPECT_TRUE (nano::test::process (node, { send, open }));
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { send, open }));
|
||||
nano::test::start_elections (system, node, { send, open }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
|
||||
|
||||
return key;
|
||||
|
@ -104,7 +104,7 @@ std::vector<std::shared_ptr<nano::block>> setup_blocks (nano::test::system & sys
|
|||
EXPECT_TRUE (nano::test::process (node, receives));
|
||||
|
||||
// Confirm whole genesis chain at once
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { sends.back () }));
|
||||
nano::test::start_elections (system, node, { sends.back () }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, { sends }));
|
||||
|
||||
std::cout << "setup_blocks done" << std::endl;
|
||||
|
|
|
@ -35,7 +35,7 @@ nano::block_list_t nano::test::setup_chain (nano::test::system & system, nano::n
|
|||
if (confirm)
|
||||
{
|
||||
// Confirm whole chain at once
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { blocks.back () }));
|
||||
nano::test::start_elections (system, node, { blocks.back () }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, blocks));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ std::vector<std::pair<nano::account, nano::block_list_t>> nano::test::setup_chai
|
|||
if (confirm)
|
||||
{
|
||||
// Ensure blocks are in the ledger and confirmed
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { send, open }));
|
||||
nano::test::start_elections (system, node, { send, open }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ nano::block_list_t nano::test::setup_independent_blocks (nano::test::system & sy
|
|||
}
|
||||
|
||||
// Confirm whole genesis chain at once
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { latest }));
|
||||
nano::test::start_elections (system, node, { latest }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, { latest }));
|
||||
|
||||
return blocks;
|
||||
|
@ -179,7 +179,7 @@ nano::keypair nano::test::setup_rep (nano::test::system & system, nano::node & n
|
|||
.build_shared ();
|
||||
|
||||
EXPECT_TRUE (nano::test::process (node, { send, open }));
|
||||
EXPECT_TIMELY (5s, nano::test::confirm (node, { send, open }));
|
||||
nano::test::start_elections (system, node, { send, open }, true);
|
||||
EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
|
||||
|
||||
return key;
|
||||
|
|
|
@ -80,38 +80,6 @@ bool nano::test::process_live (nano::node & node, std::vector<std::shared_ptr<na
|
|||
return true;
|
||||
}
|
||||
|
||||
bool nano::test::confirm (nano::node & node, std::vector<nano::block_hash> hashes)
|
||||
{
|
||||
// Finish processing all blocks - FIXME: block processor flush is broken and should be removed
|
||||
node.block_processor.flush ();
|
||||
for (auto & hash : hashes)
|
||||
{
|
||||
if (node.block_confirmed (hash))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto disk_block = node.block (hash);
|
||||
// A sideband is required to start an election
|
||||
release_assert (disk_block != nullptr);
|
||||
release_assert (disk_block->has_sideband ());
|
||||
// This only starts election
|
||||
auto election = node.block_confirm (disk_block);
|
||||
if (election == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Here we actually confirm the block
|
||||
election->force_confirm ();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool nano::test::confirm (nano::node & node, std::vector<std::shared_ptr<nano::block>> blocks)
|
||||
{
|
||||
return confirm (node, blocks_to_hashes (blocks));
|
||||
}
|
||||
|
||||
bool nano::test::confirmed (nano::node & node, std::vector<nano::block_hash> hashes)
|
||||
{
|
||||
for (auto & hash : hashes)
|
||||
|
|
|
@ -332,18 +332,6 @@ namespace test
|
|||
* @return true if all blocks were successfully processed
|
||||
*/
|
||||
bool process_live (nano::node & node, std::vector<std::shared_ptr<nano::block>> blocks);
|
||||
/*
|
||||
* Convenience function to confirm a list of blocks
|
||||
* The actual confirmation will happen asynchronously, check for that with `nano::test::confirmed (..)` function
|
||||
* @return true if successfully scheduled blocks to be confirmed
|
||||
*/
|
||||
bool confirm (nano::node & node, std::vector<std::shared_ptr<nano::block>> blocks);
|
||||
/*
|
||||
* Convenience function to confirm a list of hashes
|
||||
* The actual confirmation will happen asynchronously, check for that with `nano::test::confirmed (..)` function
|
||||
* @return true if successfully scheduled blocks to be confirmed
|
||||
*/
|
||||
bool confirm (nano::node & node, std::vector<nano::block_hash> hashes);
|
||||
/*
|
||||
* Convenience function to check whether a list of blocks is confirmed.
|
||||
* @return true if all blocks are confirmed, false otherwise
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue