Use ASSERT_TIMELY in tests where possible (#2780)
* Use ASSERT_TIMELY in tests where possible * Fix node.fork_no_vote_quorum failing test
This commit is contained in:
parent
adc904d851
commit
bc805827bc
17 changed files with 610 additions and 2985 deletions
|
@ -51,10 +51,7 @@ TEST (active_transactions, confirm_active)
|
|||
nano::lock_guard<std::mutex> guard (node2.rep_crawler.probable_reps_mutex);
|
||||
node2.rep_crawler.probable_reps.emplace (nano::test_genesis_key.pub, nano::genesis_amount, *peers.begin ());
|
||||
}
|
||||
while (node2.ledger.cache.cemented_count < 2 || !node2.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.ledger.cache.cemented_count == 2 && node2.active.empty ());
|
||||
// At least one confirmation request
|
||||
ASSERT_GT (election->confirmation_request_count, 0u);
|
||||
// Blocks were cleared (except for not_an_account)
|
||||
|
@ -84,11 +81,7 @@ TEST (active_transactions, confirm_frontier)
|
|||
node_flags2.disable_rep_crawler = true;
|
||||
auto & node2 = *system.add_node (node_flags2);
|
||||
ASSERT_EQ (nano::process_result::progress, node2.process (*send).code);
|
||||
system.deadline_set (5s);
|
||||
while (node2.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, !node2.active.empty ());
|
||||
// Save election to check request count afterwards
|
||||
auto election = node2.active.election (send->qualified_root ());
|
||||
ASSERT_NE (nullptr, election);
|
||||
|
@ -101,11 +94,7 @@ TEST (active_transactions, confirm_frontier)
|
|||
nano::lock_guard<std::mutex> guard (node2.rep_crawler.probable_reps_mutex);
|
||||
node2.rep_crawler.probable_reps.emplace (nano::test_genesis_key.pub, nano::genesis_amount, *peers.begin ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node2.ledger.cache.cemented_count < 2 || !node2.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2.ledger.cache.cemented_count == 2 && node2.active.empty ());
|
||||
ASSERT_GT (election->confirmation_request_count, 0u);
|
||||
}
|
||||
}
|
||||
|
@ -161,11 +150,7 @@ TEST (active_transactions, adjusted_multiplier_priority)
|
|||
node1.process_active (open1); // key1
|
||||
node1.process_active (open2); // key2
|
||||
nano::blocks_confirm (node1, { send1, send2, open1, open2 });
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.size () != 4)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.active.size () == 4);
|
||||
|
||||
// Check adjusted difficulty
|
||||
{
|
||||
|
@ -187,11 +172,7 @@ TEST (active_transactions, adjusted_multiplier_priority)
|
|||
node1.active.roots.begin ()->election->confirm_once ();
|
||||
}
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node1.ledger.cache.cemented_count < 5 || !node1.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.ledger.cache.cemented_count == 5 && node1.active.empty ());
|
||||
|
||||
//genesis and key1,key2 are opened
|
||||
//start chain of 2 on each
|
||||
|
@ -258,11 +239,7 @@ TEST (active_transactions, adjusted_multiplier_priority)
|
|||
node1.process_active (send8); // key2
|
||||
nano::blocks_confirm (node1, { send3, send4, send5, send6, send7, send8 });
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.size () != 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.active.size () == 6);
|
||||
|
||||
// Check adjusted difficulty
|
||||
nano::lock_guard<std::mutex> lock (node1.active.mutex);
|
||||
|
@ -302,12 +279,8 @@ TEST (active_transactions, keep_local)
|
|||
auto send4 (wallet.send_action (nano::test_genesis_key.pub, key4.pub, node.config.receive_minimum.number ()));
|
||||
auto send5 (wallet.send_action (nano::test_genesis_key.pub, key5.pub, node.config.receive_minimum.number ()));
|
||||
auto send6 (wallet.send_action (nano::test_genesis_key.pub, key6.pub, node.config.receive_minimum.number ()));
|
||||
system.deadline_set (5s);
|
||||
// should not drop wallet created transactions
|
||||
while (node.active.size () != 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.active.size () == 6);
|
||||
ASSERT_EQ (0, node.active.recently_dropped.size ());
|
||||
while (!node.active.empty ())
|
||||
{
|
||||
|
@ -349,12 +322,8 @@ TEST (active_transactions, keep_local)
|
|||
node.process_active (open2);
|
||||
node.process_active (open3);
|
||||
node.block_processor.flush ();
|
||||
system.deadline_set (5s);
|
||||
// bound elections, should drop after one loop
|
||||
while (node.active.size () != node_config.active_elections_size)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.active.size () == node_config.active_elections_size);
|
||||
ASSERT_EQ (1, node.active.recently_dropped.size ());
|
||||
ASSERT_EQ (1, node.stats.count (nano::stat::type::election, nano::stat::detail::election_drop));
|
||||
}
|
||||
|
@ -446,11 +415,7 @@ TEST (active_transactions, prioritize_chains)
|
|||
node1.process_active (open1);
|
||||
node1.process_active (send5);
|
||||
nano::blocks_confirm (node1, { send1, open1, send5 });
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.size () != 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.active.size () == 3);
|
||||
while (!node1.active.empty ())
|
||||
{
|
||||
nano::lock_guard<std::mutex> active_guard (node1.active.mutex);
|
||||
|
@ -464,19 +429,10 @@ TEST (active_transactions, prioritize_chains)
|
|||
node1.process_active (send4);
|
||||
node1.process_active (send6);
|
||||
nano::blocks_confirm (node1, { send2, send3, send4, send6 });
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.size () != 4)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
ASSERT_TIMELY (10s, node1.active.size () == 4);
|
||||
std::this_thread::sleep_for (1s);
|
||||
node1.process_active (open2);
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.size () != 4)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.active.size () == 4);
|
||||
size_t seen (0);
|
||||
{
|
||||
nano::lock_guard<std::mutex> active_guard (node1.active.mutex);
|
||||
|
@ -510,18 +466,10 @@ TEST (active_transactions, inactive_votes_cache)
|
|||
.build_shared ();
|
||||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, std::vector<nano::block_hash> (1, send->hash ())));
|
||||
node.vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, node.network.endpoint (), node.network_params.protocol.protocol_version));
|
||||
system.deadline_set (5s);
|
||||
while (node.active.inactive_votes_cache_size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.active.inactive_votes_cache_size () == 1);
|
||||
node.process_active (send);
|
||||
node.block_processor.flush ();
|
||||
system.deadline_set (5s);
|
||||
while (!node.ledger.block_confirmed (node.store.tx_begin_read (), send->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -549,11 +497,7 @@ TEST (active_transactions, inactive_votes_cache_fork)
|
|||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, std::vector<nano::block_hash> (1, send1->hash ())));
|
||||
node.vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, node.network.endpoint (), node.network_params.protocol.protocol_version));
|
||||
auto channel1 (node.network.udp_channels.create (node.network.endpoint ()));
|
||||
system.deadline_set (5s);
|
||||
while (node.active.inactive_votes_cache_size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.active.inactive_votes_cache_size () == 1);
|
||||
node.network.process_message (nano::publish (send2), channel1);
|
||||
node.block_processor.flush ();
|
||||
ASSERT_NE (nullptr, node.block (send2->hash ()));
|
||||
|
@ -598,11 +542,7 @@ TEST (active_transactions, inactive_votes_cache_existing_vote)
|
|||
node.process_active (send);
|
||||
node.block_processor.add (open);
|
||||
node.block_processor.flush ();
|
||||
system.deadline_set (5s);
|
||||
while (node.active.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.active.size () == 1);
|
||||
std::shared_ptr<nano::election> election;
|
||||
{
|
||||
nano::lock_guard<std::mutex> active_guard (node.active.mutex);
|
||||
|
@ -903,11 +843,7 @@ TEST (active_transactions, activate_dependencies)
|
|||
// Establish a representative
|
||||
node2->process_active (block0);
|
||||
node2->block_processor.flush ();
|
||||
system.deadline_set (10s);
|
||||
while (node1->block (block0->hash ()) == nullptr)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->block (block0->hash ()));
|
||||
auto block1 = builder.state ()
|
||||
.account (nano::test_genesis_key.pub)
|
||||
.previous (block0->hash ())
|
||||
|
@ -936,17 +872,9 @@ TEST (active_transactions, activate_dependencies)
|
|||
node2->process_active (block2);
|
||||
node2->block_processor.flush ();
|
||||
node2->block_confirm (block2);
|
||||
system.deadline_set (10s);
|
||||
while (node1->block (block2->hash ()) == nullptr)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->block (block2->hash ()));
|
||||
ASSERT_NE (nullptr, node1->block (block2->hash ()));
|
||||
system.deadline_set (10s);
|
||||
while (!node1->active.empty () || !node2->active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->active.empty () && node2->active.empty ());
|
||||
ASSERT_TRUE (node1->block_confirmed_or_being_confirmed (node1->store.tx_begin_read (), block2->hash ()));
|
||||
ASSERT_TRUE (node2->block_confirmed_or_being_confirmed (node2->store.tx_begin_read (), block2->hash ()));
|
||||
}
|
||||
|
@ -1010,11 +938,7 @@ TEST (active_transactions, dropped_cleanup)
|
|||
node.worker.push_task ([&flag]() {
|
||||
flag = true;
|
||||
});
|
||||
system.deadline_set (5s);
|
||||
while (!flag)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, flag);
|
||||
|
||||
// The filter must have been cleared
|
||||
ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
|
||||
|
@ -1262,11 +1186,7 @@ TEST (active_transactions, vote_generator_session)
|
|||
generator_session.flush ();
|
||||
});
|
||||
thread.join ();
|
||||
system.deadline_set (5s);
|
||||
while (node->stats.count (nano::stat::type::vote, nano::stat::detail::vote_indeterminate) < (100 / nano::network::confirm_ack_hashes_max))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll (5ms));
|
||||
}
|
||||
ASSERT_TIMELY (5s, node->stats.count (nano::stat::type::vote, nano::stat::detail::vote_indeterminate) == (100 / nano::network::confirm_ack_hashes_max));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1457,18 +1377,10 @@ TEST (active_transactions, confirm_new)
|
|||
auto & node2 = *system.add_node ();
|
||||
// Add key to node2
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.deadline_set (5s);
|
||||
// Let node2 know about the block
|
||||
while (node2.block (send->hash ()) == nullptr)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
ASSERT_TIMELY (5s, node2.block (send->hash ()));
|
||||
// Wait confirmation
|
||||
while (node1.ledger.cache.cemented_count < 2 || node2.ledger.cache.cemented_count < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1.ledger.cache.cemented_count == 2 && node2.ledger.cache.cemented_count == 2);
|
||||
}
|
||||
|
||||
TEST (active_transactions, restart_dropped)
|
||||
|
|
|
@ -205,11 +205,7 @@ TEST (bootstrap_processor, process_one)
|
|||
ASSERT_NE (hash1, hash2);
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
ASSERT_NE (node1->latest (nano::test_genesis_key.pub), node0->latest (nano::test_genesis_key.pub));
|
||||
system.deadline_set (10s);
|
||||
while (node1->latest (nano::test_genesis_key.pub) != node0->latest (nano::test_genesis_key.pub))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->latest (nano::test_genesis_key.pub) == node0->latest (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, node1->active.size ());
|
||||
node1->stop ();
|
||||
}
|
||||
|
@ -235,11 +231,7 @@ TEST (bootstrap_processor, process_two)
|
|||
ASSERT_FALSE (node1->init_error ());
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
ASSERT_NE (node1->latest (nano::test_genesis_key.pub), node0->latest (nano::test_genesis_key.pub));
|
||||
system.deadline_set (10s);
|
||||
while (node1->latest (nano::test_genesis_key.pub) != node0->latest (nano::test_genesis_key.pub))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->latest (nano::test_genesis_key.pub) == node0->latest (nano::test_genesis_key.pub));
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -265,11 +257,7 @@ TEST (bootstrap_processor, process_state)
|
|||
ASSERT_NE (node1->latest (nano::test_genesis_key.pub), block2->hash ());
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
ASSERT_NE (node1->latest (nano::test_genesis_key.pub), node0->latest (nano::test_genesis_key.pub));
|
||||
system.deadline_set (10s);
|
||||
while (node1->latest (nano::test_genesis_key.pub) != node0->latest (nano::test_genesis_key.pub))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->latest (nano::test_genesis_key.pub) == node0->latest (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, node1->active.size ());
|
||||
node1->stop ();
|
||||
}
|
||||
|
@ -288,21 +276,13 @@ TEST (bootstrap_processor, process_new)
|
|||
nano::keypair key2;
|
||||
system.wallet (1)->insert_adhoc (key2.prv);
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node1->config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1->balance (key2.pub).is_zero ());
|
||||
nano::uint128_t balance1 (node1->balance (nano::test_genesis_key.pub));
|
||||
nano::uint128_t balance2 (node1->balance (key2.pub));
|
||||
auto node3 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (node3->init_error ());
|
||||
node3->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node3->balance (key2.pub) != balance2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node3->balance (key2.pub) == balance2);
|
||||
ASSERT_EQ (balance1, node3->balance (nano::test_genesis_key.pub));
|
||||
node3->stop ();
|
||||
}
|
||||
|
@ -327,11 +307,7 @@ TEST (bootstrap_processor, pull_diamond)
|
|||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.alarm, system.logging, system.work));
|
||||
ASSERT_FALSE (node1->init_error ());
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (nano::test_genesis_key.pub) != 100)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->balance (nano::test_genesis_key.pub) == 100);
|
||||
ASSERT_EQ (100, node1->balance (nano::test_genesis_key.pub));
|
||||
node1->stop ();
|
||||
}
|
||||
|
@ -354,11 +330,7 @@ TEST (bootstrap_processor, DISABLED_pull_requeue_network_error)
|
|||
node1->bootstrap_initiator.bootstrap (node2->network.endpoint ());
|
||||
auto attempt (node1->bootstrap_initiator.current_attempt ());
|
||||
ASSERT_NE (nullptr, attempt);
|
||||
system.deadline_set (2s);
|
||||
while (!attempt->frontiers_received)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, attempt->frontiers_received);
|
||||
// Add non-existing pull & stop remote peer
|
||||
{
|
||||
nano::unique_lock<std::mutex> lock (node1->bootstrap_initiator.connections->mutex);
|
||||
|
@ -368,11 +340,7 @@ TEST (bootstrap_processor, DISABLED_pull_requeue_network_error)
|
|||
node1->bootstrap_initiator.connections->request_pull (lock);
|
||||
node2->stop ();
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (attempt != nullptr && attempt->requeued_pulls < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, attempt == nullptr || attempt->requeued_pulls == 1);
|
||||
ASSERT_EQ (0, node1->stats.count (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull_failed_account, nano::stat::dir::in)); // Requeue is not increasing failed attempts
|
||||
}
|
||||
|
||||
|
@ -421,20 +389,12 @@ TEST (bootstrap_processor, frontiers_unconfirmed)
|
|||
node_config.peering_port = nano::get_available_port ();
|
||||
node_flags.disable_legacy_bootstrap = false;
|
||||
auto node3 = system.add_node (node_config, node_flags);
|
||||
system.deadline_set (5s);
|
||||
while (node3->rep_crawler.representative_count () == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node3->rep_crawler.representative_count () != 0);
|
||||
//Add single excluded peers record (2 records are required to drop peer)
|
||||
node3->network.excluded_peers.add (nano::transport::map_endpoint_to_tcp (node1->network.endpoint ()), 0);
|
||||
ASSERT_FALSE (node3->network.excluded_peers.check (nano::transport::map_endpoint_to_tcp (node1->network.endpoint ())));
|
||||
node3->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
system.deadline_set (15s);
|
||||
while (node3->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (15s, !node3->bootstrap_initiator.in_progress ());
|
||||
ASSERT_FALSE (node3->ledger.block_exists (send1->hash ()));
|
||||
ASSERT_FALSE (node3->ledger.block_exists (open1->hash ()));
|
||||
ASSERT_EQ (1, node3->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in)); // failed request from node1
|
||||
|
@ -477,17 +437,9 @@ TEST (bootstrap_processor, frontiers_confirmed)
|
|||
node_flags.disable_legacy_bootstrap = false;
|
||||
node_flags.disable_rep_crawler = false;
|
||||
auto node2 = system.add_node (node_config, node_flags);
|
||||
system.deadline_set (5s);
|
||||
while (node2->rep_crawler.representative_count () == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2->rep_crawler.representative_count () != 0);
|
||||
node2->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node2->bootstrap_initiator.current_attempt () != nullptr && !node2->bootstrap_initiator.current_attempt ()->frontiers_confirmed)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->bootstrap_initiator.current_attempt () == nullptr || node2->bootstrap_initiator.current_attempt ()->frontiers_confirmed);
|
||||
ASSERT_EQ (1, node2->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_successful, nano::stat::dir::in)); // Successful request from node1
|
||||
ASSERT_EQ (0, node2->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in));
|
||||
}
|
||||
|
@ -534,17 +486,9 @@ TEST (bootstrap_processor, frontiers_unconfirmed_threshold)
|
|||
auto node3 = system.add_node (node_config, node_flags);
|
||||
ASSERT_EQ (nano::process_result::progress, node3->process (*send1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, node3->process (*open1).code); // Change known representative weight
|
||||
system.deadline_set (5s);
|
||||
while (node3->rep_crawler.representative_count () < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node3->rep_crawler.representative_count () == 2);
|
||||
node3->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
system.deadline_set (15s);
|
||||
while (node3->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in) < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (15s, node3->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in) == 1);
|
||||
ASSERT_FALSE (node3->ledger.block_exists (send2->hash ()));
|
||||
ASSERT_FALSE (node3->ledger.block_exists (open2->hash ()));
|
||||
ASSERT_EQ (1, node3->stats.count (nano::stat::type::bootstrap, nano::stat::detail::frontier_confirmation_failed, nano::stat::dir::in)); // failed confirmation
|
||||
|
@ -572,11 +516,7 @@ TEST (bootstrap_processor, push_diamond)
|
|||
auto receive (std::make_shared<nano::receive_block> (send1->hash (), send2->hash (), nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (send1->hash ())));
|
||||
ASSERT_EQ (nano::process_result::progress, node1->process (*receive).code);
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node0->balance (nano::test_genesis_key.pub) != 100)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->balance (nano::test_genesis_key.pub) == 100);
|
||||
ASSERT_EQ (100, node0->balance (nano::test_genesis_key.pub));
|
||||
node1->stop ();
|
||||
}
|
||||
|
@ -596,11 +536,7 @@ TEST (bootstrap_processor, push_one)
|
|||
ASSERT_NE (nullptr, wallet->send_action (nano::test_genesis_key.pub, key1.pub, 100));
|
||||
ASSERT_NE (balance1, node1->balance (nano::test_genesis_key.pub));
|
||||
node1->bootstrap_initiator.bootstrap (node0->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node0->balance (nano::test_genesis_key.pub) == balance1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->balance (nano::test_genesis_key.pub) != balance1);
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -636,11 +572,7 @@ TEST (bootstrap_processor, lazy_hash)
|
|||
ASSERT_EQ (receive2->hash ().to_string (), lazy_attempt->id);
|
||||
}
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (key2.pub) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->balance (key2.pub) != 0);
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -676,11 +608,7 @@ TEST (bootstrap_processor, lazy_hash_bootstrap_id)
|
|||
ASSERT_EQ ("123456", lazy_attempt->id);
|
||||
}
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (key2.pub) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->balance (key2.pub) != 0);
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -717,11 +645,7 @@ TEST (bootstrap_processor, lazy_max_pull_count)
|
|||
node1->network.udp_channels.insert (node0->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node1->bootstrap_initiator.bootstrap_lazy (change3->hash ());
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node1->block (change3->hash ()) == nullptr)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->block (change3->hash ()));
|
||||
|
||||
auto transaction = node1->store.tx_begin_read ();
|
||||
ASSERT_EQ (node1->ledger.cache.unchecked_count, node1->store.unchecked_count (transaction));
|
||||
|
@ -753,11 +677,7 @@ TEST (bootstrap_processor, lazy_unclear_state_link)
|
|||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (receive->hash ());
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node2->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node2->bootstrap_initiator.in_progress ());
|
||||
node2->block_processor.flush ();
|
||||
ASSERT_TRUE (node2->ledger.block_exists (send1->hash ()));
|
||||
ASSERT_TRUE (node2->ledger.block_exists (send2->hash ()));
|
||||
|
@ -789,11 +709,7 @@ TEST (bootstrap_processor, lazy_unclear_state_link_not_existing)
|
|||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (send2->hash ());
|
||||
// Check processed blocks
|
||||
system.deadline_set (15s);
|
||||
while (node2->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (15s, !node2->bootstrap_initiator.in_progress ());
|
||||
node2->block_processor.flush ();
|
||||
ASSERT_TRUE (node2->ledger.block_exists (send1->hash ()));
|
||||
ASSERT_TRUE (node2->ledger.block_exists (open->hash ()));
|
||||
|
@ -826,11 +742,7 @@ TEST (bootstrap_processor, lazy_destinations)
|
|||
node2->network.udp_channels.insert (node1->network.endpoint (), node1->network_params.protocol.protocol_version);
|
||||
node2->bootstrap_initiator.bootstrap_lazy (send2->hash ());
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node2->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node2->bootstrap_initiator.in_progress ());
|
||||
node2->block_processor.flush ();
|
||||
ASSERT_TRUE (node2->ledger.block_exists (send1->hash ()));
|
||||
ASSERT_TRUE (node2->ledger.block_exists (send2->hash ()));
|
||||
|
@ -874,11 +786,7 @@ TEST (bootstrap_processor, wallet_lazy_frontier)
|
|||
ASSERT_EQ (key2.pub.to_account (), wallet_attempt->id);
|
||||
}
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (!node1->ledger.block_exists (receive2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->ledger.block_exists (receive2->hash ()));
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -911,11 +819,7 @@ TEST (bootstrap_processor, wallet_lazy_pending)
|
|||
wallet->insert_adhoc (key2.prv);
|
||||
node1->bootstrap_wallet ();
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (!node1->ledger.block_exists (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->ledger.block_exists (send2->hash ()));
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -950,27 +854,15 @@ TEST (bootstrap_processor, multiple_attempts)
|
|||
node2->bootstrap_initiator.bootstrap ();
|
||||
auto lazy_attempt (node2->bootstrap_initiator.current_lazy_attempt ());
|
||||
auto legacy_attempt (node2->bootstrap_initiator.current_attempt ());
|
||||
system.deadline_set (5s);
|
||||
while (!lazy_attempt->started || !legacy_attempt->started)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, lazy_attempt->started && legacy_attempt->started);
|
||||
// Check that both bootstrap attempts are running & not finished
|
||||
ASSERT_FALSE (lazy_attempt->stopped);
|
||||
ASSERT_FALSE (legacy_attempt->stopped);
|
||||
ASSERT_GE (node2->bootstrap_initiator.attempts.size (), 2);
|
||||
// Check processed blocks
|
||||
system.deadline_set (10s);
|
||||
while (node2->balance (key2.pub) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->balance (key2.pub) != 0);
|
||||
// Check attempts finish
|
||||
system.deadline_set (5s);
|
||||
while (node2->bootstrap_initiator.attempts.size () != 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2->bootstrap_initiator.attempts.size () == 0);
|
||||
node2->stop ();
|
||||
}
|
||||
|
||||
|
@ -1112,11 +1004,7 @@ TEST (bulk, genesis)
|
|||
nano::block_hash latest3 (node1->latest (nano::test_genesis_key.pub));
|
||||
ASSERT_NE (latest1, latest3);
|
||||
node2->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
system.deadline_set (10s);
|
||||
while (node2->latest (nano::test_genesis_key.pub) != node1->latest (nano::test_genesis_key.pub))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->latest (nano::test_genesis_key.pub) == node1->latest (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (node2->latest (nano::test_genesis_key.pub), node1->latest (nano::test_genesis_key.pub));
|
||||
node2->stop ();
|
||||
}
|
||||
|
@ -1141,29 +1029,19 @@ TEST (bulk, offline_send)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node1->config.receive_minimum.number ()));
|
||||
ASSERT_NE (std::numeric_limits<nano::uint256_t>::max (), node1->balance (nano::test_genesis_key.pub));
|
||||
// Wait to finish election background tasks
|
||||
system.deadline_set (10s);
|
||||
while (!node1->active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->active.empty ());
|
||||
// Initiate bootstrap
|
||||
node2->bootstrap_initiator.bootstrap (node1->network.endpoint ());
|
||||
// Nodes should find each other
|
||||
system.deadline_set (10s);
|
||||
do
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
} while (node1->network.empty () || node2->network.empty ());
|
||||
// Send block arrival via bootstrap
|
||||
while (node2->balance (nano::test_genesis_key.pub) == std::numeric_limits<nano::uint256_t>::max ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->balance (nano::test_genesis_key.pub) != std::numeric_limits<nano::uint256_t>::max ());
|
||||
// Receiving send block
|
||||
system.deadline_set (20s);
|
||||
while (node2->balance (key2.pub) != node1->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, node2->balance (key2.pub) == node1->config.receive_minimum.number ());
|
||||
node2->stop ();
|
||||
}
|
||||
|
||||
|
@ -1177,11 +1055,7 @@ TEST (bulk_pull_account, basics)
|
|||
auto send1 (system.wallet (0)->send_action (nano::genesis_account, key1.pub, 25));
|
||||
auto send2 (system.wallet (0)->send_action (nano::genesis_account, key1.pub, 10));
|
||||
auto send3 (system.wallet (0)->send_action (nano::genesis_account, key1.pub, 2));
|
||||
system.deadline_set (5s);
|
||||
while (system.nodes[0]->balance (key1.pub) != 25)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, system.nodes[0]->balance (key1.pub) == 25);
|
||||
auto connection (std::make_shared<nano::bootstrap_server> (nullptr, system.nodes[0]));
|
||||
|
||||
{
|
||||
|
|
|
@ -53,11 +53,7 @@ TEST (confirmation_height, single)
|
|||
node->process_active (send1);
|
||||
node->block_processor.flush ();
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 1);
|
||||
|
||||
{
|
||||
auto transaction = node->store.tx_begin_write ();
|
||||
|
@ -162,11 +158,7 @@ TEST (confirmation_height, multiple_accounts)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 10)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 10);
|
||||
|
||||
nano::account_info account_info;
|
||||
nano::confirmation_height_info confirmation_height_info;
|
||||
|
@ -367,11 +359,7 @@ TEST (confirmation_height, gap_live)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 6);
|
||||
|
||||
// This should confirm the open block and the source of the receive blocks
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
|
@ -457,11 +445,7 @@ TEST (confirmation_height, send_receive_between_2_accounts)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 10)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 10);
|
||||
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, receive4->hash ()));
|
||||
|
@ -535,11 +519,7 @@ TEST (confirmation_height, send_receive_self)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 6);
|
||||
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, receive3->hash ()));
|
||||
|
@ -639,11 +619,7 @@ TEST (confirmation_height, all_block_types)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 15)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 15);
|
||||
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, state_send2->hash ()));
|
||||
|
@ -811,11 +787,7 @@ TEST (confirmation_height, observers)
|
|||
|
||||
node1->process_active (send1);
|
||||
node1->block_processor.flush ();
|
||||
system.deadline_set (10s);
|
||||
while (node1->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (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 ()));
|
||||
ASSERT_EQ (1, node1->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
|
@ -991,12 +963,8 @@ TEST (confirmation_height, pending_observer_callbacks)
|
|||
|
||||
node->confirmation_height_processor.add (send1->hash ());
|
||||
|
||||
system.deadline_set (10s);
|
||||
// Confirm the callback is not called under this circumstance because there is no election information
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 1 || node->ledger.stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out) != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 1 && node->ledger.stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out) == 1);
|
||||
|
||||
ASSERT_EQ (2, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in));
|
||||
ASSERT_EQ (2, node->stats.count (nano::stat::type::confirmation_height, get_stats_detail (mode_a), nano::stat::dir::in));
|
||||
|
@ -1133,11 +1101,7 @@ TEST (confirmation_height, prioritize_frontiers)
|
|||
node->active.confirm_prioritized_frontiers (transaction);
|
||||
|
||||
// Check that the active transactions roots contains the frontiers
|
||||
system.deadline_set (std::chrono::seconds (10));
|
||||
while (node->active.size () != num_accounts)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.size () == num_accounts);
|
||||
|
||||
std::array<nano::qualified_root, num_accounts> frontiers{ send17.qualified_root (), send6.qualified_root (), send7.qualified_root (), open2.qualified_root (), send11.qualified_root () };
|
||||
for (auto & frontier : frontiers)
|
||||
|
@ -1170,11 +1134,7 @@ TEST (confirmation_height, frontiers_confirmation_mode)
|
|||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node->active.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node->active.size () == 1);
|
||||
}
|
||||
// Auto mode
|
||||
{
|
||||
|
@ -1187,11 +1147,7 @@ TEST (confirmation_height, frontiers_confirmation_mode)
|
|||
auto transaction = node->store.tx_begin_write ();
|
||||
ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code);
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node->active.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node->active.size () == 1);
|
||||
}
|
||||
// Disabled mode
|
||||
{
|
||||
|
@ -1255,12 +1211,7 @@ TEST (confirmation_height, callback_confirmed_history)
|
|||
nano::lock_guard<std::mutex> guard (node->active.mutex);
|
||||
election->confirm_once ();
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->active.size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
|
||||
ASSERT_TIMELY (10s, node->active.size () == 0);
|
||||
ASSERT_EQ (0, node->active.list_recently_cemented ().size ());
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (node->active.mutex);
|
||||
|
@ -1270,36 +1221,19 @@ TEST (confirmation_height, callback_confirmed_history)
|
|||
auto transaction = node->store.tx_begin_read ();
|
||||
ASSERT_FALSE (node->ledger.block_confirmed (transaction, send->hash ()));
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!node->write_database_queue.contains (nano::writer::confirmation_height))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->write_database_queue.contains (nano::writer::confirmation_height));
|
||||
|
||||
// Confirm that no inactive callbacks have been called when the confirmation height processor has already iterated over it, waiting to write
|
||||
ASSERT_EQ (0, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out));
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->write_database_queue.contains (nano::writer::confirmation_height))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node->write_database_queue.contains (nano::writer::confirmation_height));
|
||||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, send->hash ()));
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->active.size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_quorum, nano::stat::dir::out) != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.size () == 0);
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_quorum, nano::stat::dir::out) == 1);
|
||||
|
||||
ASSERT_EQ (1, node->active.list_recently_cemented ().size ());
|
||||
ASSERT_EQ (0, node->active.blocks.size ());
|
||||
|
@ -1356,11 +1290,7 @@ TEST (confirmation_height, dependent_election)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 3);
|
||||
|
||||
ASSERT_EQ (1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_quorum, nano::stat::dir::out));
|
||||
ASSERT_EQ (1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::active_conf_height, nano::stat::dir::out));
|
||||
|
@ -1441,11 +1371,7 @@ TEST (confirmation_height, cemented_gap_below_receive)
|
|||
nano::lock_guard<std::mutex> guard (node->active.mutex);
|
||||
election->confirm_once ();
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 10)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 10);
|
||||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, open1->hash ()));
|
||||
|
@ -1538,11 +1464,7 @@ TEST (confirmation_height, cemented_gap_below_no_cache)
|
|||
nano::lock_guard<std::mutex> guard (node->active.mutex);
|
||||
election->confirm_once ();
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 6);
|
||||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
ASSERT_TRUE (node->ledger.block_confirmed (transaction, open1->hash ()));
|
||||
|
@ -1593,11 +1515,7 @@ TEST (confirmation_height, election_winner_details_clearing)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 2);
|
||||
|
||||
ASSERT_EQ (0, node->active.election_winner_details_size ());
|
||||
node->block_confirm (send);
|
||||
|
@ -1609,11 +1527,7 @@ TEST (confirmation_height, election_winner_details_clearing)
|
|||
}
|
||||
|
||||
// Wait until this block is confirmed
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () != 1 && !node->confirmation_height_processor.current ().is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 1 || node->confirmation_height_processor.current ().is_zero ());
|
||||
|
||||
ASSERT_EQ (1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out));
|
||||
|
||||
|
@ -1625,21 +1539,13 @@ TEST (confirmation_height, election_winner_details_clearing)
|
|||
election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) != 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out) == 3);
|
||||
|
||||
// Add an already cemented block with fake election details. It should get removed
|
||||
node->active.add_election_winner_details (send2->hash (), nullptr);
|
||||
node->confirmation_height_processor.add (send2->hash ());
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
|
||||
ASSERT_EQ (1, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out));
|
||||
ASSERT_EQ (3, node->stats.count (nano::stat::type::http_callback, nano::stat::detail::http_callback, nano::stat::dir::out));
|
||||
|
|
|
@ -253,11 +253,7 @@ TEST (conflicts, adjusted_multiplier)
|
|||
auto send5 (std::make_shared<nano::state_block> (key3.pub, change1->hash (), nano::test_genesis_key.pub, 0, key4.pub, key3.prv, key3.pub, *system.work.generate (change1->hash ()))); // Pending for open epoch block
|
||||
node1.process_active (send5);
|
||||
nano::blocks_confirm (node1, { send1, send2, receive1, open1, send3, send4, open_epoch1, receive2, open2, change1, send5 });
|
||||
system.deadline_set (3s);
|
||||
while (node1.active.size () != 11)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node1.active.size () == 11);
|
||||
std::unordered_map<nano::block_hash, double> adjusted_multipliers;
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (node1.active.mutex);
|
||||
|
@ -288,11 +284,7 @@ TEST (conflicts, adjusted_multiplier)
|
|||
node1.process_active (open_epoch2);
|
||||
node1.block_processor.flush ();
|
||||
node1.block_confirm (open_epoch2);
|
||||
system.deadline_set (3s);
|
||||
while (node1.active.size () != 12)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node1.active.size () == 12);
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (node1.active.mutex);
|
||||
node1.active.update_adjusted_multiplier ();
|
||||
|
|
|
@ -26,11 +26,7 @@ TEST (distributed_work, no_peers)
|
|||
done = true;
|
||||
};
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, node->config.work_peers, node->network_params.network.publish_thresholds.base, callback, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
ASSERT_GE (nano::work_difficulty (nano::work_version::work_1, hash, *work), node->network_params.network.publish_thresholds.base);
|
||||
// should only be removed after cleanup
|
||||
ASSERT_EQ (1, node->distributed_work.items.size ());
|
||||
|
@ -70,22 +66,14 @@ TEST (distributed_work, no_peers_cancel)
|
|||
|
||||
// manually cancel
|
||||
node.distributed_work.cancel (hash, true); // forces local stop
|
||||
system.deadline_set (20s);
|
||||
while (!done || !node.distributed_work.items.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, done && node.distributed_work.items.empty ());
|
||||
|
||||
// now using observer
|
||||
done = false;
|
||||
ASSERT_FALSE (node.distributed_work.make (nano::work_version::work_1, hash, node.config.work_peers, nano::difficulty::from_multiplier (1e6, node.network_params.network.publish_thresholds.base), callback_to_cancel));
|
||||
ASSERT_EQ (1, node.distributed_work.items.size ());
|
||||
node.observers.work_cancel.notify (hash);
|
||||
system.deadline_set (20s);
|
||||
while (!done || !node.distributed_work.items.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, done && node.distributed_work.items.empty ());
|
||||
}
|
||||
|
||||
TEST (distributed_work, no_peers_multi)
|
||||
|
@ -111,11 +99,7 @@ TEST (distributed_work, no_peers_multi)
|
|||
ASSERT_EQ (hash, requests->first);
|
||||
ASSERT_GE (requests->second.size (), total - 4);
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (count < total)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, count == total);
|
||||
system.deadline_set (5s);
|
||||
while (!node->distributed_work.items.empty ())
|
||||
{
|
||||
|
@ -135,11 +119,7 @@ TEST (distributed_work, no_peers_multi)
|
|||
{
|
||||
ASSERT_EQ (1, requests.second.size ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (count < total)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, count == total);
|
||||
system.deadline_set (5s);
|
||||
while (!node->distributed_work.items.empty ())
|
||||
{
|
||||
|
@ -171,11 +151,7 @@ TEST (distributed_work, peer)
|
|||
decltype (node->config.work_peers) peers;
|
||||
peers.emplace_back ("::ffff:127.0.0.1", work_peer->port ());
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, peers, node->network_params.network.publish_thresholds.base, callback, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
ASSERT_GE (nano::work_difficulty (nano::work_version::work_1, hash, *work), node->network_params.network.publish_thresholds.base);
|
||||
ASSERT_EQ (1, work_peer->generations_good);
|
||||
ASSERT_EQ (0, work_peer->generations_bad);
|
||||
|
@ -201,17 +177,9 @@ TEST (distributed_work, peer_malicious)
|
|||
decltype (node->config.work_peers) peers;
|
||||
peers.emplace_back ("::ffff:127.0.0.1", malicious_peer->port ());
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, peers, node->network_params.network.publish_thresholds.base, callback, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
ASSERT_GE (nano::work_difficulty (nano::work_version::work_1, hash, *work), node->network_params.network.publish_thresholds.base);
|
||||
system.deadline_set (5s);
|
||||
while (malicious_peer->generations_bad < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, malicious_peer->generations_bad >= 1);
|
||||
// make sure it was *not* the malicious peer that replied
|
||||
ASSERT_EQ (0, malicious_peer->generations_good);
|
||||
// initial generation + the second time when it also starts doing local generation
|
||||
|
@ -226,11 +194,7 @@ TEST (distributed_work, peer_malicious)
|
|||
malicious_peer2->start ();
|
||||
peers[0].second = malicious_peer2->port ();
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, peers, node->network_params.network.publish_thresholds.base, {}, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (malicious_peer2->generations_bad < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, malicious_peer2->generations_bad >= 2);
|
||||
node->distributed_work.cancel (hash);
|
||||
ASSERT_EQ (0, malicious_peer2->cancels);
|
||||
}
|
||||
|
@ -259,17 +223,9 @@ TEST (distributed_work, peer_multi)
|
|||
peers.emplace_back ("localhost", slow_peer->port ());
|
||||
peers.emplace_back ("localhost", good_peer->port ());
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, peers, node->network_params.network.publish_thresholds.base, callback, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
ASSERT_GE (nano::work_difficulty (nano::work_version::work_1, hash, *work), node->network_params.network.publish_thresholds.base);
|
||||
system.deadline_set (5s);
|
||||
while (slow_peer->cancels < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, slow_peer->cancels == 1);
|
||||
ASSERT_EQ (0, malicious_peer->generations_good);
|
||||
ASSERT_EQ (1, malicious_peer->generations_bad);
|
||||
ASSERT_EQ (0, malicious_peer->cancels);
|
||||
|
@ -298,10 +254,6 @@ TEST (distributed_work, fail_resolve)
|
|||
decltype (node->config.work_peers) peers;
|
||||
peers.emplace_back ("beeb.boop.123z", 0);
|
||||
ASSERT_FALSE (node->distributed_work.make (nano::work_version::work_1, hash, peers, node->network_params.network.publish_thresholds.base, callback, nano::account ()));
|
||||
system.deadline_set (5s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
ASSERT_GE (nano::work_difficulty (nano::work_version::work_1, hash, *work), node->network_params.network.publish_thresholds.base);
|
||||
}
|
||||
|
|
|
@ -24,11 +24,7 @@ TEST (gap_cache, add_existing)
|
|||
ASSERT_NE (cache.blocks.get<1> ().end (), existing1);
|
||||
auto arrival (existing1->arrival);
|
||||
lock.unlock ();
|
||||
system.deadline_set (20s);
|
||||
while (arrival == std::chrono::steady_clock::now ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, arrival != std::chrono::steady_clock::now ());
|
||||
cache.add (block1->hash ());
|
||||
ASSERT_EQ (1, cache.size ());
|
||||
lock.lock ();
|
||||
|
@ -48,11 +44,7 @@ TEST (gap_cache, comparison)
|
|||
ASSERT_NE (cache.blocks.get<1> ().end (), existing1);
|
||||
auto arrival (existing1->arrival);
|
||||
lock.unlock ();
|
||||
system.deadline_set (20s);
|
||||
while (std::chrono::steady_clock::now () == arrival)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, std::chrono::steady_clock::now () != arrival);
|
||||
auto block3 (std::make_shared<nano::send_block> (0, 42, 1, nano::keypair ().prv, 3, 4));
|
||||
cache.add (block3->hash ());
|
||||
ASSERT_EQ (2, cache.size ());
|
||||
|
|
|
@ -53,11 +53,7 @@ TEST (ipc, asynchronous)
|
|||
});
|
||||
});
|
||||
});
|
||||
system.deadline_set (5s);
|
||||
while (!call_completed)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, call_completed);
|
||||
ipc.stop ();
|
||||
}
|
||||
|
||||
|
@ -86,11 +82,7 @@ TEST (ipc, synchronous)
|
|||
});
|
||||
client_thread.detach ();
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!call_completed)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, call_completed);
|
||||
ipc.stop ();
|
||||
}
|
||||
|
||||
|
|
|
@ -618,11 +618,7 @@ TEST (system, generate_send_new)
|
|||
ASSERT_EQ (system.wallet (0)->store.end (), iterator2);
|
||||
ASSERT_FALSE (new_account.is_zero ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node1.balance (new_account) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.balance (new_account) != 0);
|
||||
system.stop ();
|
||||
runner.join ();
|
||||
}
|
||||
|
|
|
@ -87,26 +87,10 @@ TEST (network, send_node_id_handshake)
|
|||
node0->network.send_keepalive (channel);
|
||||
ASSERT_EQ (0, node0->network.size ());
|
||||
ASSERT_EQ (0, node1->network.size ());
|
||||
system.deadline_set (10s);
|
||||
while (node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) == initial_node1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node0->network.size () != 0 && node1->network.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) < initial + 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node0->network.size () != 1 && node1->network.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) != initial_node1);
|
||||
ASSERT_TIMELY (10s, node0->network.size () == 0 || node1->network.size () == 1);
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) == initial + 2);
|
||||
ASSERT_TIMELY (10s, node0->network.size () == 1 || node1->network.size () == 1);
|
||||
auto list1 (node0->network.list (1));
|
||||
ASSERT_EQ (node1->network.endpoint (), list1[0]->get_endpoint ());
|
||||
auto list2 (node1->network.list (1));
|
||||
|
@ -134,26 +118,10 @@ TEST (network, send_node_id_handshake_tcp)
|
|||
});
|
||||
ASSERT_EQ (0, node0->network.size ());
|
||||
ASSERT_EQ (0, node1->network.size ());
|
||||
system.deadline_set (10s);
|
||||
while (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) < initial + 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) < initial_node1 + 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node0->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) < initial_keepalive + 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node1->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) < initial_keepalive + 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) >= initial + 2);
|
||||
ASSERT_TIMELY (5s, node1->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake, nano::stat::dir::in) >= initial_node1 + 2);
|
||||
ASSERT_TIMELY (5s, node0->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) >= initial_keepalive + 2);
|
||||
ASSERT_TIMELY (5s, node1->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) >= initial_keepalive + 2);
|
||||
ASSERT_EQ (1, node0->network.size ());
|
||||
ASSERT_EQ (1, node1->network.size ());
|
||||
auto list1 (node0->network.list (1));
|
||||
|
@ -177,13 +145,9 @@ TEST (network, last_contacted)
|
|||
system.nodes.push_back (node1);
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, nano::endpoint (boost::asio::ip::address_v6::loopback (), system.nodes.front ()->network.endpoint ().port ()), node1->network_params.protocol.protocol_version));
|
||||
node1->network.send_keepalive (channel1);
|
||||
system.deadline_set (10s);
|
||||
|
||||
// Wait until the handshake is complete
|
||||
while (node0->network.size () < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->network.size () == 1);
|
||||
ASSERT_EQ (node0->network.size (), 1);
|
||||
|
||||
auto channel2 (node0->network.udp_channels.channel (nano::endpoint (boost::asio::ip::address_v6::loopback (), node1->network.endpoint ().port ())));
|
||||
|
@ -191,10 +155,7 @@ TEST (network, last_contacted)
|
|||
// Make sure last_contact gets updated on receiving a non-handshake message
|
||||
auto timestamp_before_keepalive = channel2->get_last_packet_received ();
|
||||
node1->network.send_keepalive (channel1);
|
||||
while (node0->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::message, nano::stat::detail::keepalive, nano::stat::dir::in) == 2);
|
||||
ASSERT_EQ (node0->network.size (), 1);
|
||||
auto timestamp_after_keepalive = channel2->get_last_packet_received ();
|
||||
ASSERT_GT (timestamp_after_keepalive, timestamp_before_keepalive);
|
||||
|
@ -218,20 +179,12 @@ TEST (network, multi_keepalive)
|
|||
node1->network.send_keepalive (channel1);
|
||||
ASSERT_EQ (0, node1->network.size ());
|
||||
ASSERT_EQ (0, node0->network.size ());
|
||||
system.deadline_set (10s);
|
||||
while (node0->network.size () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->network.size () == 1);
|
||||
auto node2 = system.add_node (node_flags);
|
||||
ASSERT_FALSE (node2->init_error ());
|
||||
auto channel2 (std::make_shared<nano::transport::channel_udp> (node2->network.udp_channels, node0->network.endpoint (), node2->network_params.protocol.protocol_version));
|
||||
node2->network.send_keepalive (channel2);
|
||||
system.deadline_set (10s);
|
||||
while (node1->network.size () != 2 || node0->network.size () != 2 || node2->network.size () != 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->network.size () == 2 && node0->network.size () == 2 && node2->network.size () == 2);
|
||||
node1->stop ();
|
||||
node2->stop ();
|
||||
}
|
||||
|
@ -249,11 +202,7 @@ TEST (network, send_discarded_publish)
|
|||
ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), node2.latest (nano::test_genesis_key.pub));
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), node2.latest (nano::test_genesis_key.pub));
|
||||
|
@ -272,11 +221,7 @@ TEST (network, send_invalid_publish)
|
|||
ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), node2.latest (nano::test_genesis_key.pub));
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (genesis.hash (), node2.latest (nano::test_genesis_key.pub));
|
||||
|
@ -304,12 +249,8 @@ TEST (network, send_valid_confirm_ack)
|
|||
nano::send_block block2 (latest1, key2.pub, 50, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest1));
|
||||
nano::block_hash latest2 (node2.latest (nano::test_genesis_key.pub));
|
||||
node1.process_active (std::make_shared<nano::send_block> (block2));
|
||||
system.deadline_set (10s);
|
||||
// Keep polling until latest block changes
|
||||
while (node2.latest (nano::test_genesis_key.pub) == latest2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.latest (nano::test_genesis_key.pub) != latest2);
|
||||
// Make sure the balance has decreased after processing the block.
|
||||
ASSERT_EQ (50, node2.balance (nano::test_genesis_key.pub));
|
||||
}
|
||||
|
@ -340,17 +281,9 @@ TEST (network, send_valid_publish)
|
|||
auto hash2 (block2.hash ());
|
||||
nano::block_hash latest2 (node2.latest (nano::test_genesis_key.pub));
|
||||
node2.process_active (std::make_shared<nano::send_block> (block2));
|
||||
system.deadline_set (10s);
|
||||
while (node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
ASSERT_NE (hash2, latest2);
|
||||
system.deadline_set (10s);
|
||||
while (node2.latest (nano::test_genesis_key.pub) == latest2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.latest (nano::test_genesis_key.pub) != latest2);
|
||||
ASSERT_EQ (50, node2.balance (nano::test_genesis_key.pub));
|
||||
}
|
||||
}
|
||||
|
@ -367,11 +300,7 @@ TEST (network, send_insufficient_work)
|
|||
nano::transport::channel_udp channel (node1.network.udp_channels, node2.network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
channel.send (publish, [](boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
system.deadline_set (10s);
|
||||
while (node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
}
|
||||
|
||||
|
@ -437,11 +366,7 @@ TEST (receivable_processor, send_with_receive)
|
|||
ASSERT_EQ (0, node1.balance (key2.pub));
|
||||
ASSERT_EQ (amount - node1.config.receive_minimum.number (), node2.balance (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (0, node2.balance (key2.pub));
|
||||
system.deadline_set (10s);
|
||||
while (node1.balance (key2.pub) != node1.config.receive_minimum.number () || node2.balance (key2.pub) != node1.config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.balance (key2.pub) == node1.config.receive_minimum.number () && node2.balance (key2.pub) == node1.config.receive_minimum.number ());
|
||||
ASSERT_EQ (amount - node1.config.receive_minimum.number (), node1.balance (nano::test_genesis_key.pub));
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node1.balance (key2.pub));
|
||||
ASSERT_EQ (amount - node1.config.receive_minimum.number (), node2.balance (nano::test_genesis_key.pub));
|
||||
|
@ -460,11 +385,7 @@ TEST (network, receive_weight_change)
|
|||
system.wallet (1)->store.representative_set (transaction, key2.pub);
|
||||
}
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) != system.nodes[0]->config.receive_minimum.number (); }))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) == system.nodes[0]->config.receive_minimum.number (); }));
|
||||
}
|
||||
|
||||
TEST (parse_endpoint, valid)
|
||||
|
@ -594,11 +515,7 @@ TEST (network, endpoint_bad_fd)
|
|||
auto endpoint (system.nodes[0]->network.endpoint ());
|
||||
ASSERT_TRUE (endpoint.address ().is_loopback ());
|
||||
// The endpoint is invalidated asynchronously
|
||||
system.deadline_set (10s);
|
||||
while (system.nodes[0]->network.endpoint ().port () != 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, system.nodes[0]->network.endpoint ().port () == 0);
|
||||
}
|
||||
|
||||
TEST (network, reserved_address)
|
||||
|
@ -795,11 +712,7 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
});
|
||||
});
|
||||
|
||||
system.deadline_set (std::chrono::seconds (5));
|
||||
while (!write_done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, write_done);
|
||||
|
||||
boost::optional<std::pair<nano::account, nano::signature>> response_zero (std::make_pair (nano::account (0), nano::signature (0)));
|
||||
nano::node_id_handshake node_id_handshake_response (boost::none, response_zero);
|
||||
|
@ -810,11 +723,7 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
ASSERT_EQ (output->size (), size_a);
|
||||
done = true;
|
||||
});
|
||||
system.deadline_set (std::chrono::seconds (5));
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, done);
|
||||
}
|
||||
|
||||
TEST (tcp_listener, tcp_listener_timeout_empty)
|
||||
|
@ -827,11 +736,7 @@ TEST (tcp_listener, tcp_listener_timeout_empty)
|
|||
ASSERT_FALSE (ec);
|
||||
connected = true;
|
||||
});
|
||||
system.deadline_set (std::chrono::seconds (5));
|
||||
while (!connected)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, connected);
|
||||
bool disconnected (false);
|
||||
system.deadline_set (std::chrono::seconds (6));
|
||||
while (!disconnected)
|
||||
|
@ -859,11 +764,7 @@ TEST (tcp_listener, tcp_listener_timeout_node_id_handshake)
|
|||
ASSERT_EQ (input.size (), size_a);
|
||||
});
|
||||
});
|
||||
system.deadline_set (std::chrono::seconds (5));
|
||||
while (node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node0->stats.count (nano::stat::type::message, nano::stat::detail::node_id_handshake) != 0);
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (node0->bootstrap.mutex);
|
||||
ASSERT_EQ (node0->bootstrap.connections.size (), 1);
|
||||
|
@ -903,16 +804,8 @@ TEST (network, replace_port)
|
|||
ASSERT_EQ (peers_list[0]->get_node_id (), node1->node_id.pub);
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node0->network.udp_channels, node1->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
node0->network.send_keepalive (channel);
|
||||
system.deadline_set (5s);
|
||||
while (!node0->network.udp_channels.channel (node1->network.endpoint ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node0->network.udp_channels.size () > 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node0->network.udp_channels.channel (node1->network.endpoint ()));
|
||||
ASSERT_TIMELY (5s, node0->network.udp_channels.size () <= 1);
|
||||
ASSERT_EQ (node0->network.udp_channels.size (), 1);
|
||||
auto list1 (node0->network.list (1));
|
||||
ASSERT_EQ (node1->network.endpoint (), list1[0]->get_endpoint ());
|
||||
|
@ -920,11 +813,7 @@ TEST (network, replace_port)
|
|||
ASSERT_EQ (node0->network.endpoint (), list2[0]->get_endpoint ());
|
||||
// Remove correct peer (same node ID)
|
||||
node0->network.udp_channels.clean_node_id (nano::endpoint (node1->network.endpoint ().address (), 23000), node1->node_id.pub);
|
||||
system.deadline_set (5s);
|
||||
while (node0->network.udp_channels.size () > 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node0->network.udp_channels.size () <= 1);
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -962,21 +851,13 @@ TEST (network, duplicate_detection)
|
|||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish));
|
||||
udp_channel->send (publish);
|
||||
udp_channel->send (publish);
|
||||
system.deadline_set (2s);
|
||||
while (node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish) < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish) == 1);
|
||||
|
||||
// Publish duplicate detection through TCP
|
||||
auto tcp_channel (node0.network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node1.network.endpoint ())));
|
||||
ASSERT_EQ (1, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish));
|
||||
tcp_channel->send (publish);
|
||||
system.deadline_set (2s);
|
||||
while (node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish) < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish) == 2);
|
||||
}
|
||||
|
||||
TEST (network, duplicate_revert_publish)
|
||||
|
|
|
@ -118,11 +118,7 @@ TEST (node, send_self)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (system.nodes[0]->balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
|
@ -135,11 +131,7 @@ TEST (node, send_single)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
system.deadline_set (10s);
|
||||
while (system.nodes[0]->balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
}
|
||||
|
||||
TEST (node, send_single_observing_peer)
|
||||
|
@ -151,11 +143,7 @@ TEST (node, send_single_observing_peer)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
system.deadline_set (10s);
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->balance (key2.pub).is_zero (); }))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
}
|
||||
|
||||
TEST (node, send_single_many_peers)
|
||||
|
@ -167,11 +155,7 @@ TEST (node, send_single_many_peers)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - system.nodes[0]->config.receive_minimum.number (), system.nodes[0]->balance (nano::test_genesis_key.pub));
|
||||
ASSERT_TRUE (system.nodes[0]->balance (key2.pub).is_zero ());
|
||||
system.deadline_set (3.5min);
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->balance (key2.pub).is_zero (); }))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3.5min, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return !node_a->balance (key2.pub).is_zero (); }));
|
||||
system.stop ();
|
||||
for (auto node : system.nodes)
|
||||
{
|
||||
|
@ -211,11 +195,7 @@ TEST (node, send_out_of_order)
|
|||
node1.process_active (send3);
|
||||
node1.process_active (send2);
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (10s);
|
||||
while (std::any_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->balance (nano::test_genesis_key.pub) != nano::genesis_amount - node1.config.receive_minimum.number () * 3; }))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->balance (nano::test_genesis_key.pub) == nano::genesis_amount - node1.config.receive_minimum.number () * 3; }));
|
||||
}
|
||||
|
||||
TEST (node, quick_confirm)
|
||||
|
@ -235,11 +215,7 @@ TEST (node, quick_confirm)
|
|||
.work (*system.work.generate (previous))
|
||||
.build_shared ();
|
||||
node1.process_active (send);
|
||||
system.deadline_set (10s);
|
||||
while (node1.balance (key.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1.balance (key.pub).is_zero ());
|
||||
ASSERT_EQ (node1.balance (nano::test_genesis_key.pub), node1.config.online_weight_minimum.number () + 1);
|
||||
ASSERT_EQ (node1.balance (key.pub), genesis_start_balance - (node1.config.online_weight_minimum.number () + 1));
|
||||
}
|
||||
|
@ -261,11 +237,7 @@ TEST (node, node_receive_quorum)
|
|||
.work (*system.work.generate (previous))
|
||||
.build_shared ();
|
||||
node1.process_active (send);
|
||||
system.deadline_set (10s);
|
||||
while (!node1.ledger.block_exists (send->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.ledger.block_exists (send->hash ()));
|
||||
{
|
||||
nano::lock_guard<std::mutex> guard (node1.active.mutex);
|
||||
auto info (node1.active.roots.find (nano::qualified_root (previous, previous)));
|
||||
|
@ -302,45 +274,21 @@ TEST (node, auto_bootstrap)
|
|||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
auto send1 (system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node0->config.receive_minimum.number ()));
|
||||
ASSERT_NE (nullptr, send1);
|
||||
system.deadline_set (10s);
|
||||
while (node0->balance (key2.pub) != node0->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->balance (key2.pub) == node0->config.receive_minimum.number ());
|
||||
auto node1 (std::make_shared<nano::node> (system.io_ctx, nano::get_available_port (), nano::unique_path (), system.alarm, system.logging, system.work, node_flags));
|
||||
ASSERT_FALSE (node1->init_error ());
|
||||
auto channel (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
node1->network.send_keepalive (channel);
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
system.deadline_set (10s);
|
||||
while (!node1->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (key2.pub) != node0->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node1->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->bootstrap_initiator.in_progress ());
|
||||
ASSERT_TIMELY (10s, node1->balance (key2.pub) == node0->config.receive_minimum.number ());
|
||||
ASSERT_TIMELY (10s, !node1->bootstrap_initiator.in_progress ());
|
||||
ASSERT_TRUE (node1->ledger.block_exists (send1->hash ()));
|
||||
// Wait block receive
|
||||
system.deadline_set (5s);
|
||||
while (node1->ledger.cache.block_count < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1->ledger.cache.block_count == 3);
|
||||
// Confirmation for all blocks
|
||||
system.deadline_set (5s);
|
||||
while (node1->ledger.cache.cemented_count < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1->ledger.cache.cemented_count == 3);
|
||||
|
||||
auto transaction = node1->store.tx_begin_read ();
|
||||
ASSERT_EQ (node1->ledger.cache.unchecked_count, node1->store.unchecked_count (transaction));
|
||||
|
@ -368,11 +316,7 @@ TEST (node, auto_bootstrap_reverse)
|
|||
node0->network.send_keepalive (channel);
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
system.deadline_set (10s);
|
||||
while (node1->balance (key2.pub) != node0->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->balance (key2.pub) == node0->config.receive_minimum.number ());
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -414,11 +358,7 @@ TEST (node, search_pending)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->search_pending ());
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node->balance (key2.pub).is_zero ());
|
||||
}
|
||||
|
||||
TEST (node, search_pending_same)
|
||||
|
@ -431,11 +371,7 @@ TEST (node, search_pending_same)
|
|||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->search_pending ());
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key2.pub) != 2 * node->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->balance (key2.pub) == 2 * node->config.receive_minimum.number ());
|
||||
}
|
||||
|
||||
TEST (node, search_pending_multiple)
|
||||
|
@ -447,20 +383,12 @@ TEST (node, search_pending_multiple)
|
|||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.wallet (0)->insert_adhoc (key3.prv);
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key3.pub, node->config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key3.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node->balance (key3.pub).is_zero ());
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (key3.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
ASSERT_FALSE (system.wallet (0)->search_pending ());
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key2.pub) != 2 * node->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->balance (key2.pub) == 2 * node->config.receive_minimum.number ());
|
||||
}
|
||||
|
||||
TEST (node, search_pending_confirmed)
|
||||
|
@ -475,11 +403,7 @@ TEST (node, search_pending_confirmed)
|
|||
ASSERT_NE (nullptr, send1);
|
||||
auto send2 (system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
ASSERT_NE (nullptr, send2);
|
||||
system.deadline_set (10s);
|
||||
while (!node->active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.empty ());
|
||||
bool confirmed (false);
|
||||
system.deadline_set (5s);
|
||||
while (!confirmed)
|
||||
|
@ -501,11 +425,7 @@ TEST (node, search_pending_confirmed)
|
|||
auto existing2 (node->active.blocks.find (send2->hash ()));
|
||||
ASSERT_EQ (node->active.blocks.end (), existing2);
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key2.pub) != 2 * node->config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->balance (key2.pub) == 2 * node->config.receive_minimum.number ());
|
||||
}
|
||||
|
||||
TEST (node, unlock_search)
|
||||
|
@ -520,15 +440,8 @@ TEST (node, unlock_search)
|
|||
}
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node->config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (nano::test_genesis_key.pub) == balance)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (!node->active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->balance (nano::test_genesis_key.pub) != balance);
|
||||
ASSERT_TIMELY (10s, node->active.empty ());
|
||||
system.wallet (0)->insert_adhoc (key2.prv);
|
||||
{
|
||||
nano::lock_guard<std::recursive_mutex> lock (system.wallet (0)->store.mutex);
|
||||
|
@ -538,11 +451,7 @@ TEST (node, unlock_search)
|
|||
auto transaction (system.wallet (0)->wallets.tx_begin_write ());
|
||||
ASSERT_FALSE (system.wallet (0)->enter_password (transaction, ""));
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node->balance (key2.pub).is_zero ());
|
||||
}
|
||||
|
||||
TEST (node, connect_after_junk)
|
||||
|
@ -556,20 +465,12 @@ TEST (node, connect_after_junk)
|
|||
junk_buffer.push_back (0);
|
||||
auto channel1 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
channel1->send_buffer (nano::shared_const_buffer (std::move (junk_buffer)), nano::stat::detail::bulk_pull, [](boost::system::error_code const &, size_t) {});
|
||||
system.deadline_set (10s);
|
||||
while (node0->stats.count (nano::stat::type::error) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->stats.count (nano::stat::type::error) != 0);
|
||||
node1->start ();
|
||||
system.nodes.push_back (node1);
|
||||
auto channel2 (std::make_shared<nano::transport::channel_udp> (node1->network.udp_channels, node0->network.endpoint (), node1->network_params.protocol.protocol_version));
|
||||
node1->network.send_keepalive (channel2);
|
||||
system.deadline_set (10s);
|
||||
while (node1->network.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1->network.empty ());
|
||||
node1->stop ();
|
||||
}
|
||||
|
||||
|
@ -1238,11 +1139,7 @@ TEST (node_flags, disable_udp)
|
|||
ASSERT_EQ (0, node2->network.size ());
|
||||
// Send TCP handshake
|
||||
node1->network.merge_peer (node2->network.endpoint ());
|
||||
system.deadline_set (5s);
|
||||
while (node1->bootstrap.realtime_count != 1 || node2->bootstrap.realtime_count != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1->bootstrap.realtime_count == 1 && node2->bootstrap.realtime_count == 1);
|
||||
ASSERT_EQ (1, node1->network.size ());
|
||||
auto list1 (node1->network.list (2));
|
||||
ASSERT_EQ (node2->network.endpoint (), list1[0]->get_endpoint ());
|
||||
|
@ -1397,12 +1294,8 @@ TEST (node, fork_keep)
|
|||
ASSERT_TRUE (node1.store.block_exists (transaction0, send1->hash ()));
|
||||
ASSERT_TRUE (node2.store.block_exists (transaction1, send1->hash ()));
|
||||
}
|
||||
system.deadline_set (1.5min);
|
||||
// Wait until the genesis rep makes a vote
|
||||
while (votes1->last_votes_size () == 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (1.5min, votes1->last_votes_size () != 1);
|
||||
auto transaction0 (node1.store.tx_begin_read ());
|
||||
auto transaction1 (node2.store.tx_begin_read ());
|
||||
// The vote should be in agreement with what we already have.
|
||||
|
@ -1767,12 +1660,8 @@ TEST (node, fork_open_flip)
|
|||
lock.unlock ();
|
||||
ASSERT_TRUE (node1.block (open1->hash ()) != nullptr);
|
||||
ASSERT_TRUE (node2.block (open2->hash ()) != nullptr);
|
||||
system.deadline_set (10s);
|
||||
// Node2 should eventually settle on open1
|
||||
while (node2.block (open1->hash ()) == nullptr)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.block (open1->hash ()));
|
||||
node2.block_processor.flush ();
|
||||
auto transaction1 (node1.store.tx_begin_read ());
|
||||
auto transaction2 (node2.store.tx_begin_read ());
|
||||
|
@ -1814,11 +1703,7 @@ TEST (node, fork_no_vote_quorum)
|
|||
}
|
||||
auto block (system.wallet (0)->send_action (nano::test_genesis_key.pub, key1, node1.config.receive_minimum.number ()));
|
||||
ASSERT_NE (nullptr, block);
|
||||
system.deadline_set (30s);
|
||||
while (node3.balance (key1) != node1.config.receive_minimum.number () || node2.balance (key1) != node1.config.receive_minimum.number () || node1.balance (key1) != node1.config.receive_minimum.number ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (30s, node3.balance (key1) == node1.config.receive_minimum.number () && node2.balance (key1) == node1.config.receive_minimum.number () && node1.balance (key1) == node1.config.receive_minimum.number ());
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node1.weight (key1));
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node2.weight (key1));
|
||||
ASSERT_EQ (node1.config.receive_minimum.number (), node3.weight (key1));
|
||||
|
@ -1846,10 +1731,7 @@ TEST (node, fork_no_vote_quorum)
|
|||
}
|
||||
nano::transport::channel_udp channel (node2.network.udp_channels, node3.network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
channel.send_buffer (nano::shared_const_buffer (std::move (buffer)), nano::stat::detail::confirm_ack);
|
||||
while (node3.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::in) < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node3.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::in) >= 3);
|
||||
ASSERT_TRUE (node1.latest (nano::test_genesis_key.pub) == send1.hash ());
|
||||
ASSERT_TRUE (node2.latest (nano::test_genesis_key.pub) == send1.hash ());
|
||||
ASSERT_TRUE (node3.latest (nano::test_genesis_key.pub) == send1.hash ());
|
||||
|
@ -1876,19 +1758,12 @@ TEST (node, DISABLED_fork_pre_confirm)
|
|||
auto transaction (system.wallet (2)->wallets.tx_begin_write ());
|
||||
system.wallet (2)->store.representative_set (transaction, key2.pub);
|
||||
}
|
||||
system.deadline_set (30s);
|
||||
auto block0 (system.wallet (0)->send_action (nano::test_genesis_key.pub, key1.pub, nano::genesis_amount / 3));
|
||||
ASSERT_NE (nullptr, block0);
|
||||
while (node0.balance (key1.pub) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (30s, node0.balance (key1.pub) != 0);
|
||||
auto block1 (system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, nano::genesis_amount / 3));
|
||||
ASSERT_NE (nullptr, block1);
|
||||
while (node0.balance (key2.pub) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (30s, node0.balance (key2.pub) != 0);
|
||||
nano::keypair key3;
|
||||
nano::keypair key4;
|
||||
nano::state_block_builder builder;
|
||||
|
@ -2124,11 +1999,7 @@ TEST (node, broadcast_elected)
|
|||
.build_shared ();
|
||||
system.wallet (2)->insert_adhoc (rep_small.prv);
|
||||
node2->process_active (fork1);
|
||||
system.deadline_set (10s);
|
||||
while (!node0->ledger.block_exists (fork0->hash ()) || !node1->ledger.block_exists (fork0->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->ledger.block_exists (fork0->hash ()) && node1->ledger.block_exists (fork0->hash ()));
|
||||
system.deadline_set (50s);
|
||||
while (!node2->ledger.block_exists (fork0->hash ()))
|
||||
{
|
||||
|
@ -2137,11 +2008,7 @@ TEST (node, broadcast_elected)
|
|||
ASSERT_TRUE (node1->ledger.block_exists (fork0->hash ()));
|
||||
ASSERT_NO_ERROR (ec);
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node1->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out) == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2192,12 +2059,8 @@ TEST (node, rep_self_vote)
|
|||
ASSERT_EQ (nano::process_result::progress, node0->process (*block0).code);
|
||||
auto & active (node0->active);
|
||||
auto election1 = active.insert (block0);
|
||||
system.deadline_set (1s);
|
||||
// Wait until representatives are activated & make vote
|
||||
while (election1.election->last_votes_size () != 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (1s, election1.election->last_votes_size () == 3);
|
||||
nano::unique_lock<std::mutex> lock (active.mutex);
|
||||
auto & rep_votes (election1.election->last_votes);
|
||||
ASSERT_NE (rep_votes.end (), rep_votes.find (nano::test_genesis_key.pub));
|
||||
|
@ -2393,11 +2256,7 @@ TEST (node, DISABLED_unconfirmed_send)
|
|||
wallet1->insert_adhoc (key0.prv);
|
||||
wallet0->insert_adhoc (nano::test_genesis_key.prv);
|
||||
auto send1 (wallet0->send_action (nano::genesis_account, key0.pub, 2 * nano::Mxrb_ratio));
|
||||
system.deadline_set (10s);
|
||||
while (node1.balance (key0.pub) != 2 * nano::Mxrb_ratio || node1.bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.balance (key0.pub) == 2 * nano::Mxrb_ratio && !node1.bootstrap_initiator.in_progress ());
|
||||
auto latest (node1.latest (key0.pub));
|
||||
nano::state_block send2 (key0.pub, latest, nano::genesis_account, nano::Mxrb_ratio, nano::genesis_account, key0.prv, key0.pub, *node0.work_generate_blocking (latest));
|
||||
{
|
||||
|
@ -2405,11 +2264,7 @@ TEST (node, DISABLED_unconfirmed_send)
|
|||
ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, send2).code);
|
||||
}
|
||||
auto send3 (wallet1->send_action (key0.pub, nano::genesis_account, nano::Mxrb_ratio));
|
||||
system.deadline_set (10s);
|
||||
while (node0.balance (nano::genesis_account) != nano::genesis_amount)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0.balance (nano::genesis_account) == nano::genesis_amount);
|
||||
}
|
||||
|
||||
// Test that nodes can track nodes that have rep weight for priority broadcasting
|
||||
|
@ -2515,11 +2370,7 @@ TEST (node, rep_weight)
|
|||
node.rep_crawler.response (channel0, vote0);
|
||||
node.rep_crawler.response (channel1, vote1);
|
||||
node.rep_crawler.response (channel2, vote2);
|
||||
system.deadline_set (5s);
|
||||
while (node.rep_crawler.representative_count () != 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.rep_crawler.representative_count () == 2);
|
||||
// Make sure we get the rep with the most weight first
|
||||
auto reps (node.rep_crawler.representatives (1));
|
||||
ASSERT_EQ (1, reps.size ());
|
||||
|
@ -2595,21 +2446,14 @@ TEST (node, rep_remove)
|
|||
node.network.udp_channels.insert (endpoint0, node.network_params.protocol.protocol_version);
|
||||
auto vote1 = std::make_shared<nano::vote> (keypair1.pub, keypair1.prv, 0, genesis.open);
|
||||
node.rep_crawler.response (channel0, vote1);
|
||||
system.deadline_set (5s);
|
||||
while (node.rep_crawler.representative_count () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node.rep_crawler.representative_count () == 1);
|
||||
auto reps (node.rep_crawler.representatives (1));
|
||||
ASSERT_EQ (1, reps.size ());
|
||||
ASSERT_EQ (node.minimum_principal_weight () * 2, reps[0].weight.number ());
|
||||
ASSERT_EQ (keypair1.pub, reps[0].account);
|
||||
ASSERT_EQ (*channel0, reps[0].channel_ref ());
|
||||
// This UDP channel is not reachable and should timeout
|
||||
while (node.rep_crawler.representative_count () != 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node.rep_crawler.representative_count () == 0);
|
||||
// Add working representative
|
||||
auto node1 = system.add_node (nano::node_config (nano::get_available_port (), system.logging));
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
|
@ -2617,10 +2461,7 @@ TEST (node, rep_remove)
|
|||
ASSERT_NE (nullptr, channel1);
|
||||
auto vote2 = std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, genesis.open);
|
||||
node.rep_crawler.response (channel1, vote2);
|
||||
while (node.rep_crawler.representative_count () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node.rep_crawler.representative_count () == 1);
|
||||
// Add inactive TCP representative channel
|
||||
auto node2 (std::make_shared<nano::node> (system.io_ctx, nano::unique_path (), system.alarm, nano::node_config (nano::get_available_port (), system.logging), system.work));
|
||||
std::atomic<bool> done{ false };
|
||||
|
@ -2630,24 +2471,14 @@ TEST (node, rep_remove)
|
|||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->rep_crawler.response (channel2, vote3);
|
||||
while (node_l->rep_crawler.representative_count () != 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node_l->rep_crawler.representative_count () == 2);
|
||||
done = true;
|
||||
}
|
||||
});
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
node2->stop ();
|
||||
// Remove inactive representatives
|
||||
system.deadline_set (10s);
|
||||
while (node.rep_crawler.representative_count () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node.rep_crawler.representative_count () == 1);
|
||||
reps = node.rep_crawler.representatives (1);
|
||||
ASSERT_EQ (nano::test_genesis_key.pub, reps[0].account);
|
||||
ASSERT_EQ (1, node.network.size ());
|
||||
|
@ -2662,18 +2493,10 @@ TEST (node, rep_connection_close)
|
|||
auto & node2 (*system.nodes[1]);
|
||||
// Add working representative (node 2)
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.deadline_set (10s);
|
||||
while (node1.rep_crawler.representative_count () != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.rep_crawler.representative_count () == 1);
|
||||
node2.stop ();
|
||||
// Remove representative with closed channel
|
||||
system.deadline_set (10s);
|
||||
while (node1.rep_crawler.representative_count () != 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.rep_crawler.representative_count () == 0);
|
||||
}
|
||||
|
||||
// Test that nodes can disable representative voting
|
||||
|
@ -2693,11 +2516,7 @@ TEST (node, no_voting)
|
|||
wallet1->insert_adhoc (key1.prv);
|
||||
// Broadcast a confirm so others should know this is a rep node
|
||||
wallet1->send_action (nano::test_genesis_key.pub, key1.pub, nano::Mxrb_ratio);
|
||||
system.deadline_set (10s);
|
||||
while (!node0.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0.active.empty ());
|
||||
ASSERT_EQ (0, node0.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::in));
|
||||
}
|
||||
|
||||
|
@ -2712,11 +2531,7 @@ TEST (node, send_callback)
|
|||
node0.config.callback_port = 8010;
|
||||
node0.config.callback_target = "/";
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::test_genesis_key.pub, key2.pub, node0.config.receive_minimum.number ()));
|
||||
system.deadline_set (10s);
|
||||
while (node0.balance (key2.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0.balance (key2.pub).is_zero ());
|
||||
ASSERT_EQ (std::numeric_limits<nano::uint128_t>::max () - node0.config.receive_minimum.number (), node0.balance (nano::test_genesis_key.pub));
|
||||
}
|
||||
|
||||
|
@ -2879,11 +2694,7 @@ TEST (node, block_confirm)
|
|||
.build_shared ();
|
||||
node1.block_processor.add (send1, nano::seconds_since_epoch ());
|
||||
node2.block_processor.add (send1_copy, nano::seconds_since_epoch ());
|
||||
system.deadline_set (std::chrono::seconds (5));
|
||||
while (!node1.ledger.block_exists (send1->hash ()) || !node2.ledger.block_exists (send1_copy->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1.ledger.block_exists (send1->hash ()) && node2.ledger.block_exists (send1_copy->hash ()));
|
||||
ASSERT_TRUE (node1.ledger.block_exists (send1->hash ()));
|
||||
ASSERT_TRUE (node2.ledger.block_exists (send1_copy->hash ()));
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, send1->hash (), nano::test_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio * 2, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *node1.work_generate_blocking (send1->hash ())));
|
||||
|
@ -2897,11 +2708,7 @@ TEST (node, block_confirm)
|
|||
}
|
||||
node1.block_confirm (send2);
|
||||
ASSERT_TRUE (node1.active.list_recently_cemented ().empty ());
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.list_recently_cemented ().empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1.active.list_recently_cemented ().empty ());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2971,11 +2778,7 @@ TEST (node, confirm_quorum)
|
|||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code);
|
||||
system.wallet (0)->send_action (nano::test_genesis_key.pub, nano::test_genesis_key.pub, new_balance.number ());
|
||||
system.deadline_set (10s);
|
||||
while (node1.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1.active.empty ());
|
||||
nano::lock_guard<std::mutex> guard (node1.active.mutex);
|
||||
auto info (node1.active.roots.find (nano::qualified_root (send1->hash (), send1->hash ())));
|
||||
ASSERT_NE (node1.active.roots.end (), info);
|
||||
|
@ -3063,7 +2866,7 @@ TEST (node, local_votes_cache)
|
|||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
system.poll (node.aggregator.max_delay);
|
||||
ASSERT_NO_ERROR (system.poll (node.aggregator.max_delay));
|
||||
}
|
||||
// Make sure a new vote was not generated
|
||||
{
|
||||
|
@ -3082,7 +2885,7 @@ TEST (node, local_votes_cache)
|
|||
}
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
system.poll (node.aggregator.max_delay);
|
||||
ASSERT_NO_ERROR (system.poll (node.aggregator.max_delay));
|
||||
}
|
||||
wait_vote_sequence (3);
|
||||
ASSERT_TIMELY (3s, node.votes_cache.find (send1->hash ()).empty ());
|
||||
|
@ -3118,46 +2921,26 @@ TEST (node, local_votes_cache_batch)
|
|||
auto channel (node.network.udp_channels.create (node.network.endpoint ()));
|
||||
// Generates and sends one vote for both hashes which is then cached
|
||||
node.network.process_message (message, channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) < 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) == 1);
|
||||
ASSERT_EQ (1, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out));
|
||||
ASSERT_FALSE (node.votes_cache.find (genesis.open->hash ()).empty ());
|
||||
ASSERT_FALSE (node.votes_cache.find (send1->hash ()).empty ());
|
||||
// Only one confirm_ack should be sent if all hashes are part of the same vote
|
||||
node.network.process_message (message, channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) < 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) == 2);
|
||||
ASSERT_EQ (2, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out));
|
||||
// Test when votes are different
|
||||
node.votes_cache.remove (genesis.open->hash ());
|
||||
node.votes_cache.remove (send1->hash ());
|
||||
node.network.process_message (nano::confirm_req (genesis.open->hash (), genesis.open->root ()), channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) == 3);
|
||||
ASSERT_EQ (3, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out));
|
||||
node.network.process_message (nano::confirm_req (send1->hash (), send1->root ()), channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) < 4)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) == 4);
|
||||
ASSERT_EQ (4, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out));
|
||||
// There are two different votes, so both should be sent in response
|
||||
node.network.process_message (message, channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) < 6)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out) == 6);
|
||||
ASSERT_EQ (6, node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out));
|
||||
}
|
||||
|
||||
|
@ -3173,11 +2956,7 @@ TEST (node, local_votes_cache_generate_new_vote)
|
|||
nano::confirm_req message1 (genesis.open);
|
||||
auto channel (node.network.udp_channels.create (node.network.endpoint ()));
|
||||
node.network.process_message (message1, channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.votes_cache.find (genesis.open->hash ()).empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, !node.votes_cache.find (genesis.open->hash ()).empty ());
|
||||
auto votes1 (node.votes_cache.find (genesis.open->hash ()));
|
||||
ASSERT_EQ (1, votes1.size ());
|
||||
ASSERT_EQ (1, votes1[0]->blocks.size ());
|
||||
|
@ -3203,11 +2982,7 @@ TEST (node, local_votes_cache_generate_new_vote)
|
|||
std::vector<std::pair<nano::block_hash, nano::root>> roots_hashes{ std::make_pair (genesis.open->hash (), genesis.open->root ()), std::make_pair (send1->hash (), send1->root ()) };
|
||||
nano::confirm_req message2 (roots_hashes);
|
||||
node.network.process_message (message2, channel);
|
||||
system.deadline_set (3s);
|
||||
while (node.votes_cache.find (send1->hash ()).empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (3s, !node.votes_cache.find (send1->hash ()).empty ());
|
||||
auto votes2 (node.votes_cache.find (send1->hash ()));
|
||||
ASSERT_EQ (1, votes2.size ());
|
||||
ASSERT_EQ (1, votes2[0]->blocks.size ());
|
||||
|
@ -3274,35 +3049,18 @@ TEST (node, vote_republish)
|
|||
.work (*system.work.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!node2.block (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2.block (send1->hash ()));
|
||||
node1.active.publish (send2);
|
||||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2));
|
||||
ASSERT_TRUE (node1.active.active (*send1));
|
||||
ASSERT_TRUE (node2.active.active (*send1));
|
||||
node1.vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (node1.network.udp_channels, node1.network.endpoint (), node1.network_params.protocol.protocol_version));
|
||||
while (!node1.block (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (!node2.block (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.block (send2->hash ()));
|
||||
ASSERT_TIMELY (10s, node2.block (send2->hash ()));
|
||||
ASSERT_FALSE (node1.block (send1->hash ()));
|
||||
ASSERT_FALSE (node2.block (send1->hash ()));
|
||||
system.deadline_set (5s);
|
||||
while (node2.balance (key2.pub) != node1.config.receive_minimum.number () * 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (node1.balance (key2.pub) != node1.config.receive_minimum.number () * 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2.balance (key2.pub) == node1.config.receive_minimum.number () * 2);
|
||||
ASSERT_TIMELY (10s, node1.balance (key2.pub) == node1.config.receive_minimum.number () * 2);
|
||||
}
|
||||
|
||||
namespace nano
|
||||
|
@ -3330,11 +3088,7 @@ TEST (node, vote_by_hash_bundle)
|
|||
|
||||
// Verify that bundling occurs. While reaching 12 should be common on most hardware in release mode,
|
||||
// we set this low enough to allow the test to pass on CI/with santitizers.
|
||||
system.deadline_set (20s);
|
||||
while (max_hashes.load () < 3)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, max_hashes.load () >= 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3372,11 +3126,7 @@ TEST (node, vote_by_hash_republish)
|
|||
.work (*system.work.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!node2.block (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2.block (send1->hash ()));
|
||||
node1.active.publish (send2);
|
||||
std::vector<nano::block_hash> vote_blocks;
|
||||
vote_blocks.push_back (send2->hash ());
|
||||
|
@ -3384,25 +3134,12 @@ TEST (node, vote_by_hash_republish)
|
|||
ASSERT_TRUE (node1.active.active (*send1));
|
||||
ASSERT_TRUE (node2.active.active (*send1));
|
||||
node1.vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (node1.network.udp_channels, node1.network.endpoint (), node1.network_params.protocol.protocol_version));
|
||||
while (!node1.block (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (!node2.block (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.block (send2->hash ()));
|
||||
ASSERT_TIMELY (10s, node2.block (send2->hash ()));
|
||||
ASSERT_FALSE (node1.block (send1->hash ()));
|
||||
ASSERT_FALSE (node2.block (send1->hash ()));
|
||||
system.deadline_set (5s);
|
||||
while (node2.balance (key2.pub) != node1.config.receive_minimum.number () * 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (node1.balance (key2.pub) != node1.config.receive_minimum.number () * 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2.balance (key2.pub) == node1.config.receive_minimum.number () * 2);
|
||||
ASSERT_TIMELY (10s, node1.balance (key2.pub) == node1.config.receive_minimum.number () * 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3431,11 +3168,7 @@ TEST (node, vote_by_hash_epoch_block_republish)
|
|||
.work (*system.work.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!node2.block (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node2.block (send1->hash ()));
|
||||
node1.active.publish (epoch1);
|
||||
std::vector<nano::block_hash> vote_blocks;
|
||||
vote_blocks.push_back (epoch1->hash ());
|
||||
|
@ -3443,14 +3176,8 @@ TEST (node, vote_by_hash_epoch_block_republish)
|
|||
ASSERT_TRUE (node1.active.active (*send1));
|
||||
ASSERT_TRUE (node2.active.active (*send1));
|
||||
node1.vote_processor.vote (vote, std::make_shared<nano::transport::channel_udp> (node1.network.udp_channels, node1.network.endpoint (), node1.network_params.protocol.protocol_version));
|
||||
while (!node1.block (epoch1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (!node2.block (epoch1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.block (epoch1->hash ()));
|
||||
ASSERT_TIMELY (10s, node2.block (epoch1->hash ()));
|
||||
ASSERT_FALSE (node1.block (send1->hash ()));
|
||||
ASSERT_FALSE (node2.block (send1->hash ()));
|
||||
}
|
||||
|
@ -3533,11 +3260,7 @@ TEST (node, epoch_conflict_confirm)
|
|||
}
|
||||
node0->process_active (change);
|
||||
node0->process_active (epoch_open);
|
||||
system.deadline_set (5s);
|
||||
while (!node0->block (change->hash ()) || !node0->block (epoch_open->hash ()) || !node1->block (change->hash ()) || !node1->block (epoch_open->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node0->block (change->hash ()) && node0->block (epoch_open->hash ()) && node1->block (change->hash ()) && node1->block (epoch_open->hash ()));
|
||||
nano::blocks_confirm (*node0, { change, epoch_open });
|
||||
ASSERT_EQ (2, node0->active.size ());
|
||||
{
|
||||
|
@ -3546,11 +3269,7 @@ TEST (node, epoch_conflict_confirm)
|
|||
ASSERT_TRUE (node0->active.blocks.find (epoch_open->hash ()) != node0->active.blocks.end ());
|
||||
}
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
system.deadline_set (5s);
|
||||
while (!node0->active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node0->active.empty ());
|
||||
{
|
||||
auto transaction (node0->store.tx_begin_read ());
|
||||
ASSERT_TRUE (node0->ledger.store.block_exists (transaction, change->hash ()));
|
||||
|
@ -3593,25 +3312,15 @@ TEST (node, fork_invalid_block_signature)
|
|||
auto vote_corrupt (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, send2_corrupt));
|
||||
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (5s);
|
||||
while (!node1.block (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1.block (send1->hash ()));
|
||||
// Send the vote with the corrupt block signature
|
||||
node2.network.flood_vote (vote_corrupt, 1.0f);
|
||||
// Wait for the rollback
|
||||
ASSERT_TIMELY (5s, node1.stats.count (nano::stat::type::rollback, nano::stat::detail::all));
|
||||
// Send the vote with the correct block
|
||||
node2.network.flood_vote (vote, 1.0f);
|
||||
while (node1.block (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
while (!node1.block (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1.block (send1->hash ()));
|
||||
ASSERT_TIMELY (10s, node1.block (send2->hash ()));
|
||||
ASSERT_EQ (node1.block (send2->hash ())->block_signature (), send2->block_signature ());
|
||||
}
|
||||
|
||||
|
@ -3874,11 +3583,7 @@ TEST (node, block_processor_full)
|
|||
ASSERT_FALSE (node.block_processor.full ());
|
||||
node.block_processor.add (send3);
|
||||
// Block processor may be not full during state blocks signatures verification
|
||||
system.deadline_set (2s);
|
||||
while (!node.block_processor.full ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, node.block_processor.full ());
|
||||
}
|
||||
|
||||
TEST (node, block_processor_half_full)
|
||||
|
@ -3924,11 +3629,7 @@ TEST (node, block_processor_half_full)
|
|||
ASSERT_FALSE (node.block_processor.half_full ());
|
||||
node.block_processor.add (send3);
|
||||
// Block processor may be not half_full during state blocks signatures verification
|
||||
system.deadline_set (2s);
|
||||
while (!node.block_processor.half_full ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, node.block_processor.half_full ());
|
||||
ASSERT_FALSE (node.block_processor.full ());
|
||||
}
|
||||
|
||||
|
@ -3974,11 +3675,7 @@ TEST (node, confirm_back)
|
|||
vote_blocks.push_back (send2->hash ());
|
||||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, vote_blocks));
|
||||
node.vote_processor.vote_blocking (vote, std::make_shared<nano::transport::channel_udp> (node.network.udp_channels, node.network.endpoint (), node.network_params.protocol.protocol_version));
|
||||
system.deadline_set (10s);
|
||||
while (!node.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node.active.empty ());
|
||||
}
|
||||
|
||||
TEST (node, peers)
|
||||
|
@ -4003,17 +3700,9 @@ TEST (node, peers)
|
|||
}
|
||||
|
||||
node2->start ();
|
||||
system.deadline_set (10s);
|
||||
while (node2->network.empty () || node1->network.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node2->network.empty () && !node1->network.empty ())
|
||||
// Wait to finish TCP node ID handshakes
|
||||
system.deadline_set (10s);
|
||||
while (node1->bootstrap.realtime_count == 0 || node2->bootstrap.realtime_count == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->bootstrap.realtime_count != 0 && node2->bootstrap.realtime_count != 0);
|
||||
// Confirm that the peers match with the endpoints we are expecting
|
||||
ASSERT_EQ (1, node1->network.size ());
|
||||
auto list1 (node1->network.list (2));
|
||||
|
@ -4026,11 +3715,7 @@ TEST (node, peers)
|
|||
// Stop the peer node and check that it is removed from the store
|
||||
node1->stop ();
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node2->network.size () == 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->network.size () != 1);
|
||||
|
||||
ASSERT_TRUE (node2->network.empty ());
|
||||
|
||||
|
@ -4060,11 +3745,7 @@ TEST (node, peer_cache_restart)
|
|||
store.peer_put (transaction, endpoint_key);
|
||||
}
|
||||
node2->start ();
|
||||
system.deadline_set (10s);
|
||||
while (node2->network.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node2->network.empty ());
|
||||
// Confirm that the peers match with the endpoints we are expecting
|
||||
auto list (node2->network.list (2));
|
||||
ASSERT_EQ (node1->network.endpoint (), list[0]->get_endpoint ());
|
||||
|
@ -4087,11 +3768,7 @@ TEST (node, peer_cache_restart)
|
|||
ASSERT_EQ (store.peer_count (transaction), 1);
|
||||
ASSERT_TRUE (store.peer_exists (transaction, endpoint_key));
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node3->network.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node3->network.empty ());
|
||||
// Confirm that the peers match with the endpoints we are expecting
|
||||
auto list (node3->network.list (2));
|
||||
ASSERT_EQ (node1->network.endpoint (), list[0]->get_endpoint ());
|
||||
|
@ -4222,19 +3899,11 @@ TEST (node, bidirectional_tcp)
|
|||
.build_shared ();
|
||||
node1->process_active (send1);
|
||||
node1->block_processor.flush ();
|
||||
system.deadline_set (5s);
|
||||
while (!node1->ledger.block_exists (send1->hash ()) || !node2->ledger.block_exists (send1->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->ledger.block_exists (send1->hash ()) && node2->ledger.block_exists (send1->hash ()));
|
||||
// Test block confirmation from node 1 (add representative to node 1)
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
// Wait to find new reresentative
|
||||
system.deadline_set (10s);
|
||||
while (node2->rep_crawler.representative_count () == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node2->rep_crawler.representative_count () != 0);
|
||||
/* Wait for confirmation
|
||||
To check connection we need only node 2 confirmation status
|
||||
Node 1 election can be unconfirmed because representative private key was inserted after election start (and node 2 isn't flooding new votes to principal representatives) */
|
||||
|
@ -4264,19 +3933,11 @@ TEST (node, bidirectional_tcp)
|
|||
.build_shared ();
|
||||
node2->process_active (send2);
|
||||
node2->block_processor.flush ();
|
||||
system.deadline_set (5s);
|
||||
while (!node1->ledger.block_exists (send2->hash ()) || !node2->ledger.block_exists (send2->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->ledger.block_exists (send2->hash ()) && node2->ledger.block_exists (send2->hash ()));
|
||||
// Test block confirmation from node 2 (add representative to node 2)
|
||||
system.wallet (1)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
// Wait to find changed reresentative
|
||||
system.deadline_set (10s);
|
||||
while (node1->rep_crawler.representative_count () == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1->rep_crawler.representative_count () != 0);
|
||||
/* Wait for confirmation
|
||||
To check connection we need only node 1 confirmation status
|
||||
Node 2 election can be unconfirmed because representative private key was inserted after election start (and node 1 isn't flooding new votes to principal representatives) */
|
||||
|
@ -4416,11 +4077,7 @@ TEST (active_difficulty, recalculate_work)
|
|||
auto multiplier1 = nano::difficulty::to_multiplier (send1->difficulty (), node1.network_params.network.publish_thresholds.epoch_1);
|
||||
// Process as local block
|
||||
node1.process_active (send1);
|
||||
system.deadline_set (2s);
|
||||
while (node1.active.empty ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (2s, !node1.active.empty ());
|
||||
auto sum (std::accumulate (node1.active.multipliers_cb.begin (), node1.active.multipliers_cb.end (), double(0)));
|
||||
ASSERT_EQ (node1.active.active_difficulty (), nano::difficulty::from_multiplier (sum / node1.active.multipliers_cb.size (), node1.network_params.network.publish_thresholds.epoch_1));
|
||||
nano::unique_lock<std::mutex> lock (node1.active.mutex);
|
||||
|
|
|
@ -233,11 +233,7 @@ TEST (telemetry, basic)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
// Check the metrics are correct
|
||||
|
@ -252,11 +248,7 @@ TEST (telemetry, basic)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
// Wait the cache period and check cache is not used
|
||||
|
@ -269,11 +261,7 @@ TEST (telemetry, basic)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
TEST (telemetry, receive_from_non_listening_channel)
|
||||
|
@ -305,11 +293,7 @@ TEST (telemetry, over_udp)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
|
||||
// Check channels are indeed udp
|
||||
ASSERT_EQ (1, node_client->network.size ());
|
||||
|
@ -335,11 +319,7 @@ TEST (telemetry, invalid_channel)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
TEST (telemetry, blocking_request)
|
||||
|
@ -401,11 +381,7 @@ TEST (telemetry, disconnects)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
TEST (telemetry, dos_tcp)
|
||||
|
@ -426,11 +402,7 @@ TEST (telemetry, dos_tcp)
|
|||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (1 != node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, 1 == node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in));
|
||||
|
||||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
|
@ -440,11 +412,7 @@ TEST (telemetry, dos_tcp)
|
|||
});
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while ((nano::telemetry_cache_cutoffs::test + orig) > std::chrono::steady_clock::now ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, (nano::telemetry_cache_cutoffs::test + orig) <= std::chrono::steady_clock::now ());
|
||||
|
||||
// Should process no more telemetry_req messages
|
||||
ASSERT_EQ (1, node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in));
|
||||
|
@ -477,11 +445,7 @@ TEST (telemetry, dos_udp)
|
|||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
system.deadline_set (20s);
|
||||
while (1 != node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, 1 == node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in));
|
||||
|
||||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
|
@ -491,11 +455,7 @@ TEST (telemetry, dos_udp)
|
|||
});
|
||||
}
|
||||
|
||||
system.deadline_set (20s);
|
||||
while ((nano::telemetry_cache_cutoffs::test + orig) > std::chrono::steady_clock::now ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, (nano::telemetry_cache_cutoffs::test + orig) <= std::chrono::steady_clock::now ());
|
||||
|
||||
// Should process no more telemetry_req messages
|
||||
ASSERT_EQ (1, node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in));
|
||||
|
@ -530,11 +490,7 @@ TEST (telemetry, disable_metrics)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
|
||||
// It should still be able to receive metrics though
|
||||
done = false;
|
||||
|
@ -545,11 +501,7 @@ TEST (telemetry, disable_metrics)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
namespace nano
|
||||
|
|
|
@ -158,11 +158,7 @@ TEST (vote_processor, weights)
|
|||
system.wallet (0)->send_sync (nano::test_genesis_key.pub, key2.pub, level2);
|
||||
|
||||
// Wait for representatives
|
||||
system.deadline_set (10s);
|
||||
while (node.ledger.cache.rep_weights.get_rep_amounts ().size () != 4)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node.ledger.cache.rep_weights.get_rep_amounts ().size () == 4);
|
||||
node.vote_processor.calculate_weights ();
|
||||
|
||||
ASSERT_EQ (node.vote_processor.representatives_1.end (), node.vote_processor.representatives_1.find (key0.pub));
|
||||
|
|
|
@ -198,12 +198,8 @@ TEST (wallet, send_async)
|
|||
nano::system system (1);
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
nano::keypair key2;
|
||||
boost::thread thread ([&system]() {
|
||||
system.deadline_set (10s);
|
||||
while (!system.nodes[0]->balance (nano::test_genesis_key.pub).is_zero ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
std::thread thread ([&system]() {
|
||||
ASSERT_TIMELY (10s, system.nodes[0]->balance (nano::test_genesis_key.pub).is_zero ());
|
||||
});
|
||||
std::atomic<bool> success (false);
|
||||
system.wallet (0)->send_async (nano::test_genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success](std::shared_ptr<nano::block> block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
|
@ -670,12 +666,8 @@ TEST (wallet, work_generate)
|
|||
}
|
||||
nano::keypair key;
|
||||
auto block (wallet->send_action (nano::test_genesis_key.pub, key.pub, 100));
|
||||
system.deadline_set (10s);
|
||||
auto transaction (node1.store.tx_begin_read ());
|
||||
while (node1.ledger.account_balance (transaction, nano::test_genesis_key.pub) == amount1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node1.ledger.account_balance (transaction, nano::test_genesis_key.pub) != amount1);
|
||||
system.deadline_set (10s);
|
||||
auto again (true);
|
||||
while (again)
|
||||
|
@ -1219,11 +1211,7 @@ TEST (work_watcher, propagate)
|
|||
auto & node_passive = *system.add_node (node_config);
|
||||
nano::keypair key;
|
||||
auto const block (wallet.send_action (nano::test_genesis_key.pub, key.pub, 100));
|
||||
system.deadline_set (5s);
|
||||
while (!node_passive.ledger.block_exists (block->hash ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, node_passive.ledger.block_exists (block->hash ()));
|
||||
auto const multiplier (nano::normalized_multiplier (nano::difficulty::to_multiplier (block->difficulty (), nano::work_threshold (block->work_version (), nano::block_details (nano::epoch::epoch_0, false, false, false))), node.network_params.network.publish_thresholds.epoch_1));
|
||||
auto updated_multiplier{ multiplier };
|
||||
auto propagated_multiplier{ multiplier };
|
||||
|
@ -1270,11 +1258,7 @@ TEST (work_watcher, removed_after_win)
|
|||
ASSERT_EQ (0, wallet.wallets.watcher->size ());
|
||||
auto const block1 (wallet.send_action (nano::test_genesis_key.pub, key.pub, 100));
|
||||
ASSERT_EQ (1, wallet.wallets.watcher->size ());
|
||||
system.deadline_set (5s);
|
||||
while (node.wallets.watcher->is_watched (block1->qualified_root ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, !node.wallets.watcher->is_watched (block1->qualified_root ()));
|
||||
ASSERT_EQ (0, node.wallets.watcher->size ());
|
||||
}
|
||||
|
||||
|
@ -1297,11 +1281,7 @@ TEST (work_watcher, removed_after_lose)
|
|||
auto vote (std::make_shared<nano::vote> (nano::test_genesis_key.pub, nano::test_genesis_key.prv, 0, fork1));
|
||||
nano::confirm_ack message (vote);
|
||||
node.network.process_message (message, nullptr);
|
||||
system.deadline_set (5s);
|
||||
while (node.wallets.watcher->is_watched (block1->qualified_root ()))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, !node.wallets.watcher->is_watched (block1->qualified_root ()));
|
||||
ASSERT_EQ (0, node.wallets.watcher->size ());
|
||||
}
|
||||
|
||||
|
@ -1367,11 +1347,7 @@ TEST (work_watcher, cancel)
|
|||
node.active.update_active_multiplier (lock);
|
||||
}
|
||||
// Wait for work generation to start
|
||||
system.deadline_set (5s);
|
||||
while (0 == node.work.size ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, 0 != node.work.size ());
|
||||
// Cancel the ongoing work
|
||||
ASSERT_EQ (1, node.work.size ());
|
||||
node.work.cancel (block1->root ());
|
||||
|
|
|
@ -164,11 +164,7 @@ TEST (wallets, reload)
|
|||
auto wallet (node.node->wallets.create (one));
|
||||
ASSERT_NE (wallet, nullptr);
|
||||
}
|
||||
system.deadline_set (5s);
|
||||
while (node1.wallets.open (one) == nullptr)
|
||||
{
|
||||
system.poll ();
|
||||
}
|
||||
ASSERT_TIMELY (5s, node1.wallets.open (one) != nullptr);
|
||||
ASSERT_EQ (2, node1.wallets.items.size ());
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,7 @@ TEST (websocket, subscription_edge)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Test client subscribing to changes in active_multiplier
|
||||
|
@ -81,11 +77,7 @@ TEST (websocket, active_difficulty)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Fake history records and force a trended_active_multiplier change
|
||||
{
|
||||
|
@ -94,11 +86,7 @@ TEST (websocket, active_difficulty)
|
|||
node1->active.update_active_multiplier (lock);
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
// Check active_difficulty response
|
||||
boost::optional<std::string> response = future.get ();
|
||||
|
@ -153,11 +141,7 @@ TEST (websocket, confirmation)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
nano::keypair key;
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
|
@ -171,11 +155,7 @@ TEST (websocket, confirmation)
|
|||
node1->process_active (send);
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!unsubscribed)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, unsubscribed);
|
||||
|
||||
// Quick confirm a state block
|
||||
{
|
||||
|
@ -185,11 +165,7 @@ TEST (websocket, confirmation)
|
|||
node1->process_active (send);
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Tests getting notification of an erased election
|
||||
|
@ -212,11 +188,7 @@ TEST (websocket, stopped_election)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Create election, then erase it, causing a websocket message to be emitted
|
||||
nano::keypair key1;
|
||||
|
@ -228,11 +200,7 @@ TEST (websocket, stopped_election)
|
|||
node1->block_processor.flush ();
|
||||
node1->active.erase (*send1);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
auto response = future.get ();
|
||||
ASSERT_TRUE (response);
|
||||
|
@ -264,11 +232,7 @@ TEST (websocket, confirmation_options)
|
|||
});
|
||||
auto future1 = std::async (std::launch::async, task1);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Confirm a state block for an in-wallet account
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
|
@ -283,11 +247,7 @@ TEST (websocket, confirmation_options)
|
|||
previous = send->hash ();
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future1.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
|
@ -300,11 +260,7 @@ TEST (websocket, confirmation_options)
|
|||
});
|
||||
auto future2 = std::async (std::launch::async, task2);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, ack_ready);
|
||||
|
||||
// Quick-confirm another block
|
||||
{
|
||||
|
@ -314,11 +270,7 @@ TEST (websocket, confirmation_options)
|
|||
previous = send->hash ();
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future2.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future2.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
auto response2 = future2.get ();
|
||||
ASSERT_TRUE (response2);
|
||||
|
@ -358,11 +310,7 @@ TEST (websocket, confirmation_options)
|
|||
});
|
||||
auto future3 = std::async (std::launch::async, task3);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Confirm a legacy block
|
||||
// When filtering options are enabled, legacy blocks are always filtered
|
||||
|
@ -373,11 +321,7 @@ TEST (websocket, confirmation_options)
|
|||
previous = send->hash ();
|
||||
}
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future1.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Tests updating options of block confirmations
|
||||
|
@ -415,11 +359,7 @@ TEST (websocket, confirmation_options_update)
|
|||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
// Wait for update acknowledgement
|
||||
system.deadline_set (5s);
|
||||
while (!added)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, added);
|
||||
|
||||
// Confirm a block
|
||||
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
|
@ -430,22 +370,14 @@ TEST (websocket, confirmation_options_update)
|
|||
node1->process_active (send);
|
||||
|
||||
// Wait for delete acknowledgement
|
||||
system.deadline_set (5s);
|
||||
while (!deleted)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, deleted);
|
||||
|
||||
// Confirm another block
|
||||
previous = send->hash ();
|
||||
auto send2 (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - 2 * nano::Gxrb_ratio, key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send2);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Subscribes to votes, sends a block and awaits websocket notification of a vote arrival
|
||||
|
@ -468,11 +400,7 @@ TEST (websocket, vote)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Quick-confirm a block
|
||||
nano::keypair key;
|
||||
|
@ -481,11 +409,7 @@ TEST (websocket, vote)
|
|||
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, previous, nano::test_genesis_key.pub, nano::genesis_amount - (node1->config.online_weight_minimum.number () + 1), key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (previous)));
|
||||
node1->process_active (send);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
auto response = future.get ();
|
||||
ASSERT_TRUE (response);
|
||||
|
@ -516,11 +440,7 @@ TEST (websocket, vote_options_type)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Custom made votes for simplicity
|
||||
nano::genesis genesis;
|
||||
|
@ -529,11 +449,7 @@ TEST (websocket, vote_options_type)
|
|||
auto msg (builder.vote_received (vote, nano::vote_code::replay));
|
||||
node1->websocket_server->broadcast (msg);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
auto response = future.get ();
|
||||
ASSERT_TRUE (response);
|
||||
|
@ -573,11 +489,7 @@ TEST (websocket, vote_options_representatives)
|
|||
});
|
||||
auto future1 = std::async (std::launch::async, task1);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Quick-confirm a block
|
||||
nano::keypair key;
|
||||
|
@ -592,11 +504,7 @@ TEST (websocket, vote_options_representatives)
|
|||
};
|
||||
confirm_block ();
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future1.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
|
@ -612,20 +520,12 @@ TEST (websocket, vote_options_representatives)
|
|||
auto future2 = std::async (std::launch::async, task2);
|
||||
|
||||
// Wait for the subscription to be acknowledged
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Confirm another block
|
||||
confirm_block ();
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future2.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future2.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Test client subscribing to notifications for work generation
|
||||
|
@ -652,11 +552,7 @@ TEST (websocket, work)
|
|||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
// Wait for acknowledge
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
ASSERT_EQ (1, node1->websocket_server->subscriber_count (nano::websocket::topic::work));
|
||||
|
||||
// Generate work
|
||||
|
@ -665,11 +561,7 @@ TEST (websocket, work)
|
|||
ASSERT_TRUE (work.is_initialized ());
|
||||
|
||||
// Wait for the work notification
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
// Check the work notification message
|
||||
auto response = future.get ();
|
||||
|
@ -730,22 +622,14 @@ TEST (websocket, bootstrap)
|
|||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
// Wait for acknowledge
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Start bootstrap attempt
|
||||
node1->bootstrap_initiator.bootstrap (true, "123abc");
|
||||
ASSERT_NE (nullptr, node1->bootstrap_initiator.current_attempt ());
|
||||
|
||||
// Wait for the bootstrap notification
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
// Check the bootstrap notification message
|
||||
auto response = future.get ();
|
||||
|
@ -762,11 +646,7 @@ TEST (websocket, bootstrap)
|
|||
ASSERT_EQ (contents.get<std::string> ("mode"), "legacy");
|
||||
|
||||
// Wait for bootstrap finish
|
||||
system.deadline_set (5s);
|
||||
while (node1->bootstrap_initiator.in_progress ())
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, !node1->bootstrap_initiator.in_progress ());
|
||||
}
|
||||
|
||||
TEST (websocket, bootstrap_exited)
|
||||
|
@ -794,11 +674,7 @@ TEST (websocket, bootstrap_exited)
|
|||
});
|
||||
|
||||
// Wait for bootstrap start
|
||||
system.deadline_set (5s);
|
||||
while (!bootstrap_started)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, bootstrap_started);
|
||||
|
||||
// Subscribe to bootstrap and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
|
@ -813,20 +689,12 @@ TEST (websocket, bootstrap_exited)
|
|||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
// Wait for acknowledge
|
||||
system.deadline_set (5s);
|
||||
while (!ack_ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, ack_ready);
|
||||
|
||||
// Wait for the bootstrap notification
|
||||
subscribed_completion.increment ();
|
||||
bootstrap_thread.join ();
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
// Check the bootstrap notification message
|
||||
auto response = future.get ();
|
||||
|
@ -861,11 +729,7 @@ TEST (websocket, ws_keepalive)
|
|||
});
|
||||
auto future = std::async (std::launch::async, task);
|
||||
|
||||
system.deadline_set (5s);
|
||||
while (future.wait_for (0s) != std::future_status::ready)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (5s, future.wait_for (0s) == std::future_status::ready);
|
||||
}
|
||||
|
||||
// Tests sending telemetry
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -78,10 +78,7 @@ TEST (system, receive_while_synchronizing)
|
|||
std::string block_text;
|
||||
block->serialize_json (block_text);
|
||||
}));
|
||||
while (node1->balance (key.pub).is_zero ())
|
||||
{
|
||||
system.poll ();
|
||||
}
|
||||
ASSERT_TIMELY (10s, !node1->balance (key.pub).is_zero ());
|
||||
node1->stop ();
|
||||
system.stop ();
|
||||
runner.join ();
|
||||
|
@ -150,11 +147,7 @@ TEST (wallet, multithreaded_send_async)
|
|||
}
|
||||
}));
|
||||
}
|
||||
system.deadline_set (1000s);
|
||||
while (system.nodes[0]->balance (nano::test_genesis_key.pub) != (nano::genesis_amount - 20 * 1000 * 1000))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (1000s, system.nodes[0]->balance (nano::test_genesis_key.pub) == (nano::genesis_amount - 20 * 1000 * 1000));
|
||||
}
|
||||
for (auto i (threads.begin ()), n (threads.end ()); i != n; ++i)
|
||||
{
|
||||
|
@ -239,7 +232,7 @@ TEST (node, fork_storm)
|
|||
}
|
||||
}
|
||||
});
|
||||
system.poll ();
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
if ((iteration & 0xff) == 0)
|
||||
{
|
||||
std::cerr << "Empty: " << empty << " single: " << single << std::endl;
|
||||
|
@ -502,15 +495,10 @@ TEST (confirmation_height, many_accounts_single_confirmation)
|
|||
election_insertion_result.election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (120s);
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
while (!node->ledger.block_confirmed (transaction, last_open_hash))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
transaction.refresh ();
|
||||
}
|
||||
ASSERT_TIMELY (120s, node->ledger.block_confirmed (node->store.tx_begin_read (), last_open_hash));
|
||||
|
||||
// All frontiers (except last) should have 2 blocks and both should be confirmed
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
for (auto i (node->store.latest_begin (transaction)), n (node->store.latest_end ()); i != n; ++i)
|
||||
{
|
||||
auto & account = i->first;
|
||||
|
@ -533,16 +521,8 @@ TEST (confirmation_height, many_accounts_single_confirmation)
|
|||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_bounded, nano::stat::dir::in), num_accounts * 2 - 2);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in), 0);
|
||||
|
||||
system.deadline_set (40s);
|
||||
while ((node->ledger.cache.cemented_count - 1) != node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (40s, (node->ledger.cache.cemented_count - 1) == node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out));
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, many_accounts_many_confirmations)
|
||||
|
@ -584,22 +564,14 @@ TEST (confirmation_height, many_accounts_many_confirmations)
|
|||
election_insertion_result.election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (1500s);
|
||||
auto const num_blocks_to_confirm = (num_accounts - 1) * 2;
|
||||
while (node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in) != num_blocks_to_confirm)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (1500s, node->stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in) == num_blocks_to_confirm);
|
||||
|
||||
auto num_confirmed_bounded = node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_bounded, nano::stat::dir::in);
|
||||
ASSERT_GE (num_confirmed_bounded, nano::confirmation_height::unbounded_cutoff);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in), num_blocks_to_confirm - num_confirmed_bounded);
|
||||
|
||||
system.deadline_set (60s);
|
||||
while ((node->ledger.cache.cemented_count - 1) != node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (60s, (node->ledger.cache.cemented_count - 1) == node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out));
|
||||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
auto cemented_count = 0;
|
||||
|
@ -611,17 +583,9 @@ TEST (confirmation_height, many_accounts_many_confirmations)
|
|||
ASSERT_EQ (num_blocks_to_confirm + 1, cemented_count);
|
||||
ASSERT_EQ (cemented_count, node->ledger.cache.cemented_count);
|
||||
|
||||
system.deadline_set (20s);
|
||||
while ((node->ledger.cache.cemented_count - 1) != node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, (node->ledger.cache.cemented_count - 1) == node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out));
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, long_chains)
|
||||
|
@ -688,17 +652,7 @@ TEST (confirmation_height, long_chains)
|
|||
election_insertion_result.election->confirm_once ();
|
||||
}
|
||||
|
||||
system.deadline_set (30s);
|
||||
while (true)
|
||||
{
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
if (node->ledger.block_confirmed (transaction, receive1->hash ()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (30s, node->ledger.block_confirmed (node->store.tx_begin_read (), receive1->hash ()));
|
||||
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
nano::account_info account_info;
|
||||
|
@ -724,16 +678,8 @@ TEST (confirmation_height, long_chains)
|
|||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_bounded, nano::stat::dir::in), num_blocks * 2 + 2);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in), 0);
|
||||
|
||||
system.deadline_set (40s);
|
||||
while ((node->ledger.cache.cemented_count - 1) != node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (40s, (node->ledger.cache.cemented_count - 1) == node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::all, nano::stat::dir::out));
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
}
|
||||
|
||||
TEST (confirmation_height, dynamic_algorithm)
|
||||
|
@ -763,28 +709,16 @@ TEST (confirmation_height, dynamic_algorithm)
|
|||
}
|
||||
|
||||
node->confirmation_height_processor.add (state_blocks.front ()->hash ());
|
||||
system.deadline_set (20s);
|
||||
while (node->ledger.cache.cemented_count != 2)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, node->ledger.cache.cemented_count == 2);
|
||||
|
||||
node->confirmation_height_processor.add (latest_genesis);
|
||||
|
||||
system.deadline_set (20s);
|
||||
while (node->ledger.cache.cemented_count != num_blocks + 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, node->ledger.cache.cemented_count == num_blocks + 1);
|
||||
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in), num_blocks);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_bounded, nano::stat::dir::in), 1);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in), num_blocks - 1);
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -845,10 +779,7 @@ TEST (confirmation_height, dynamic_algorithm_no_transition_while_pending)
|
|||
node->confirmation_height_processor.pause ();
|
||||
|
||||
timer.restart ();
|
||||
while (node->confirmation_height_processor.unbounded_processor.pending_writes_size == 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->confirmation_height_processor.unbounded_processor.pending_writes_size != 0);
|
||||
|
||||
{
|
||||
// Make it so that the number of blocks exceed the unbounded cutoff would go into the bounded processor (but shouldn't due to unbounded pending writes)
|
||||
|
@ -861,20 +792,12 @@ TEST (confirmation_height, dynamic_algorithm_no_transition_while_pending)
|
|||
node->confirmation_height_processor.unpause ();
|
||||
}
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (node->ledger.cache.cemented_count != num_blocks + 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->ledger.cache.cemented_count == num_blocks + 1);
|
||||
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed, nano::stat::dir::in), num_blocks);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_bounded, nano::stat::dir::in), 0);
|
||||
ASSERT_EQ (node->ledger.stats.count (nano::stat::type::confirmation_height, nano::stat::detail::blocks_confirmed_unbounded, nano::stat::dir::in), num_blocks);
|
||||
system.deadline_set (10s);
|
||||
while (node->active.election_winner_details_size () > 0)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, node->active.election_winner_details_size () == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1239,18 +1162,11 @@ TEST (telemetry, ongoing_requests)
|
|||
ASSERT_EQ (0, node_client->stats.count (nano::stat::type::bootstrap, nano::stat::detail::telemetry_ack, nano::stat::dir::in));
|
||||
ASSERT_EQ (0, node_client->stats.count (nano::stat::type::bootstrap, nano::stat::detail::telemetry_req, nano::stat::dir::out));
|
||||
|
||||
system.deadline_set (20s);
|
||||
while (node_client->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_ack, nano::stat::dir::in) != 1 || node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_ack, nano::stat::dir::in) != 1)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (20s, node_client->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_ack, nano::stat::dir::in) == 1 && node_server->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_ack, nano::stat::dir::in) == 1);
|
||||
|
||||
// Wait till the next ongoing will be called, and add a 1s buffer for the actual processing
|
||||
auto time = std::chrono::steady_clock::now ();
|
||||
while (std::chrono::steady_clock::now () < (time + node_client->telemetry->cache_plus_buffer_cutoff_time () + 1s))
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, std::chrono::steady_clock::now () >= (time + node_client->telemetry->cache_plus_buffer_cutoff_time () + 1s));
|
||||
|
||||
ASSERT_EQ (2, node_client->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_ack, nano::stat::dir::in));
|
||||
ASSERT_EQ (2, node_client->stats.count (nano::stat::type::message, nano::stat::detail::telemetry_req, nano::stat::dir::in));
|
||||
|
@ -1318,11 +1234,7 @@ namespace transport
|
|||
});
|
||||
}
|
||||
|
||||
system.deadline_set (30s);
|
||||
while (!shared_data.done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (30s, shared_data.done);
|
||||
|
||||
ASSERT_TRUE (std::all_of (node_data.begin (), node_data.end (), [](auto const & data) { return !data.keep_requesting_metrics; }));
|
||||
|
||||
|
@ -1406,11 +1318,7 @@ TEST (telemetry, all_peers_use_single_request_cache)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
auto responses = node_client->telemetry->get_metrics ();
|
||||
|
@ -1438,11 +1346,7 @@ TEST (telemetry, all_peers_use_single_request_cache)
|
|||
done = true;
|
||||
});
|
||||
|
||||
system.deadline_set (10s);
|
||||
while (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
}
|
||||
ASSERT_TIMELY (10s, done);
|
||||
}
|
||||
|
||||
responses = node_client->telemetry->get_metrics ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue