From c47edd18eeb523a316803944c43d7bc628a06b2d Mon Sep 17 00:00:00 2001 From: Russel Waters Date: Mon, 8 Jul 2019 00:20:45 -0400 Subject: [PATCH 1/3] test validating #2116 --- nano/core_test/active_transactions.cpp | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 683cb3a84e..58d0bfefb6 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -6,6 +6,33 @@ using namespace std::chrono_literals; +TEST (active_transactions, bounded_active_elections) +{ + nano::system system; + nano::node_config node_config (24000, system.logging); + node_config.enable_voting = false; + node_config.active_elections_size = 5; + auto & node1 = *system.add_node (node_config); + nano::genesis genesis; + size_t count (1); + auto send (std::make_shared (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ()))); + auto previous_size = node1.active.size (); + bool done (false); + while (!done) + { + count++; + node1.process_active (send); + done = previous_size > node1.active.size (); + ASSERT_LT (node1.active.size (), node1.config.active_elections_size); //triggers after reverting #2116 + ASSERT_NO_ERROR (system.poll ()); + auto previous_hash = send->hash (); + send = std::make_shared (nano::test_genesis_key.pub, previous_hash, nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_hash)); + previous_size = node1.active.size (); + //sleep this thread for the max delay between request loop rounds possible for such a asmall active_elections_size + std::this_thread::sleep_for (std::chrono::milliseconds (node1.network_params.network.request_interval_ms + (node_config.active_elections_size * 20))); + } +} + TEST (active_transactions, adjusted_difficulty_priority) { nano::system system; From fed282ec4d0032466df52af7f3f0c6c81ccf9dee Mon Sep 17 00:00:00 2001 From: Russel Waters Date: Mon, 8 Jul 2019 00:44:19 -0400 Subject: [PATCH 2/3] whitespace formatting --- nano/core_test/active_transactions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 58d0bfefb6..3d598f6650 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -23,13 +23,13 @@ TEST (active_transactions, bounded_active_elections) count++; node1.process_active (send); done = previous_size > node1.active.size (); - ASSERT_LT (node1.active.size (), node1.config.active_elections_size); //triggers after reverting #2116 + ASSERT_LT (node1.active.size (), node1.config.active_elections_size); //triggers after reverting #2116 ASSERT_NO_ERROR (system.poll ()); auto previous_hash = send->hash (); send = std::make_shared (nano::test_genesis_key.pub, previous_hash, nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_hash)); previous_size = node1.active.size (); //sleep this thread for the max delay between request loop rounds possible for such a asmall active_elections_size - std::this_thread::sleep_for (std::chrono::milliseconds (node1.network_params.network.request_interval_ms + (node_config.active_elections_size * 20))); + std::this_thread::sleep_for (std::chrono::milliseconds (node1.network_params.network.request_interval_ms + (node_config.active_elections_size * 20))); } } From 869d2452cde2d80278021cf71811537cd477c287 Mon Sep 17 00:00:00 2001 From: Russel Waters Date: Mon, 8 Jul 2019 08:38:37 -0400 Subject: [PATCH 3/3] typo and deadline.set --- nano/core_test/active_transactions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 3d598f6650..7ece70b04b 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -18,6 +18,7 @@ TEST (active_transactions, bounded_active_elections) auto send (std::make_shared (nano::test_genesis_key.pub, genesis.hash (), nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (genesis.hash ()))); auto previous_size = node1.active.size (); bool done (false); + system.deadline_set (5s); while (!done) { count++; @@ -28,7 +29,7 @@ TEST (active_transactions, bounded_active_elections) auto previous_hash = send->hash (); send = std::make_shared (nano::test_genesis_key.pub, previous_hash, nano::test_genesis_key.pub, nano::genesis_amount - count * nano::xrb_ratio, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, system.work.generate (previous_hash)); previous_size = node1.active.size (); - //sleep this thread for the max delay between request loop rounds possible for such a asmall active_elections_size + //sleep this thread for the max delay between request loop rounds possible for such a small active_elections_size std::this_thread::sleep_for (std::chrono::milliseconds (node1.network_params.network.request_interval_ms + (node_config.active_elections_size * 20))); } }