-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Brings back broadcasting blocks on process_live (#3507)
* Brings back broadcasting blocks on process_live * Changed drop policy to allow drops * Adds an unit test for checking block broadcasts on arrival
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <nano/lib/blockbuilders.hpp> | ||
#include <nano/node/node.hpp> | ||
#include <nano/node/nodeconfig.hpp> | ||
#include <nano/secure/common.hpp> | ||
#include <nano/secure/ledger.hpp> | ||
#include <nano/test_common/system.hpp> | ||
#include <nano/test_common/testutil.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
using namespace std::chrono_literals; | ||
|
||
TEST (block_processor, broadcast_block_on_arrival) | ||
{ | ||
nano::system system; | ||
nano::node_config config1{ nano::get_available_port (), system.logging }; | ||
// Deactivates elections on both nodes. | ||
config1.active_elections_size = 0; | ||
nano::node_config config2{ nano::get_available_port (), system.logging }; | ||
config2.active_elections_size = 0; | ||
nano::node_flags flags; | ||
// Disables bootstrap listener to make sure the block won't be shared by this channel. | ||
flags.disable_bootstrap_listener = true; | ||
auto node1 = system.add_node (config1, flags); | ||
auto node2 = system.add_node (config2, flags); | ||
nano::state_block_builder builder; | ||
auto send1 = builder.make_block () | ||
.account (nano::dev::genesis_key.pub) | ||
.previous (nano::dev::genesis->hash ()) | ||
.representative (nano::dev::genesis_key.pub) | ||
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) | ||
.link (nano::dev::genesis_key.pub) | ||
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) | ||
.work (*system.work.generate (nano::dev::genesis->hash ())) | ||
.build_shared (); | ||
// Adds a block to the first node. process_active() -> (calls) block_processor.add() -> add() -> | ||
// awakes process_block() -> process_batch() -> process_one() -> process_live() | ||
node1->process_active (send1); | ||
// Checks whether the block was broadcast. | ||
ASSERT_TIMELY (5s, node2->ledger.block_or_pruned_exists (send1->hash ())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters