Skip to content

Commit

Permalink
FIX TESTS
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 12, 2024
1 parent 92f669f commit fb603a2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 54 deletions.
56 changes: 28 additions & 28 deletions nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace std::chrono_literals;
TEST (bulk_pull, no_address)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = 1;
req->end = 2;
Expand All @@ -27,7 +27,7 @@ TEST (bulk_pull, no_address)
TEST (bulk_pull, genesis_to_end)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end.clear ();
Expand All @@ -40,7 +40,7 @@ TEST (bulk_pull, genesis_to_end)
TEST (bulk_pull, no_end)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end = 1;
Expand Down Expand Up @@ -72,7 +72,7 @@ TEST (bulk_pull, end_not_owned)
open->signature = nano::sign_message (key2.prv, key2.pub, open->hash ());
system.nodes[0]->work_generate_blocking (*open);
ASSERT_EQ (nano::block_status::progress, system.nodes[0]->process (open));
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = key2.pub;
req->end = nano::dev::genesis->hash ();
Expand All @@ -83,7 +83,7 @@ TEST (bulk_pull, end_not_owned)
TEST (bulk_pull, none)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end = nano::dev::genesis->hash ();
Expand All @@ -95,7 +95,7 @@ TEST (bulk_pull, none)
TEST (bulk_pull, get_next_on_open)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end.clear ();
Expand Down Expand Up @@ -126,7 +126,7 @@ TEST (bulk_pull, ascending_one_hash)
node.work_generate_blocking (*block1);
ASSERT_EQ (nano::block_status::progress, node.process (block1));
auto socket = std::make_shared<nano::transport::socket> (node, nano::transport::socket::endpoint_type_t::server);
auto connection = std::make_shared<nano::transport::tcp_server> (socket, system.nodes[0]);
auto connection = std::make_shared<nano::transport::tcp_server> (system.nodes[0], socket);
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis->hash ();
req->end.clear ();
Expand Down Expand Up @@ -158,7 +158,7 @@ TEST (bulk_pull, ascending_two_account)
node.work_generate_blocking (*block1);
ASSERT_EQ (nano::block_status::progress, node.process (block1));
auto socket = std::make_shared<nano::transport::socket> (node, nano::transport::socket::endpoint_type_t::server);
auto connection = std::make_shared<nano::transport::tcp_server> (socket, system.nodes[0]);
auto connection = std::make_shared<nano::transport::tcp_server> (system.nodes[0], socket);
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end.clear ();
Expand Down Expand Up @@ -193,7 +193,7 @@ TEST (bulk_pull, ascending_end)
node.work_generate_blocking (*block1);
ASSERT_EQ (nano::block_status::progress, node.process (block1));
auto socket = std::make_shared<nano::transport::socket> (node, nano::transport::socket::endpoint_type_t::server);
auto connection = std::make_shared<nano::transport::tcp_server> (socket, system.nodes[0]);
auto connection = std::make_shared<nano::transport::tcp_server> (system.nodes[0], socket);
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub;
req->end = block1->hash ();
Expand All @@ -208,7 +208,7 @@ TEST (bulk_pull, ascending_end)
TEST (bulk_pull, by_block)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis->hash ();
req->end.clear ();
Expand All @@ -224,7 +224,7 @@ TEST (bulk_pull, by_block)
TEST (bulk_pull, by_block_single)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = nano::dev::genesis->hash ();
req->end = nano::dev::genesis->hash ();
Expand Down Expand Up @@ -261,7 +261,7 @@ TEST (bulk_pull, count_limit)
.build ();
ASSERT_EQ (nano::block_status::progress, node0->process (receive1));

auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node0, nano::transport::socket::endpoint_type_t::server), node0));
auto connection (std::make_shared<nano::transport::tcp_server> (node0, std::make_shared<nano::transport::socket> (*node0, nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::bulk_pull> (nano::dev::network_params.network);
req->start = receive1->hash ();
req->set_count_present (true);
Expand Down Expand Up @@ -1692,7 +1692,7 @@ TEST (frontier_req_response, DISABLED_destruction)
std::shared_ptr<nano::frontier_req_server> hold; // Destructing tcp acceptor on non-existent io_context
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (nullptr, system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], nullptr));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = std::numeric_limits<decltype (req->age)>::max ();
Expand All @@ -1706,7 +1706,7 @@ TEST (frontier_req_response, DISABLED_destruction)
TEST (frontier_req, begin)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = std::numeric_limits<decltype (req->age)>::max ();
Expand All @@ -1719,7 +1719,7 @@ TEST (frontier_req, begin)
TEST (frontier_req, end)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start = nano::dev::genesis_key.pub.number () + 1;
req->age = std::numeric_limits<decltype (req->age)>::max ();
Expand Down Expand Up @@ -1760,7 +1760,7 @@ TEST (frontier_req, count)
node1->work_generate_blocking (*receive1);
ASSERT_EQ (nano::block_status::progress, node1->process (receive1));

auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = std::numeric_limits<decltype (req->age)>::max ();
Expand All @@ -1773,7 +1773,7 @@ TEST (frontier_req, count)
TEST (frontier_req, time_bound)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = 1;
Expand All @@ -1786,15 +1786,15 @@ TEST (frontier_req, time_bound)
req2->start.clear ();
req2->age = 1;
req2->count = std::numeric_limits<decltype (req2->count)>::max ();
auto connection2 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection2 (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto request2 (std::make_shared<nano::frontier_req_server> (connection, std::move (req2)));
ASSERT_TRUE (request2->current.is_zero ());
}

TEST (frontier_req, time_cutoff)
{
nano::test::system system (1);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = 3;
Expand All @@ -1808,7 +1808,7 @@ TEST (frontier_req, time_cutoff)
req2->start.clear ();
req2->age = 3;
req2->count = std::numeric_limits<decltype (req2->count)>::max ();
auto connection2 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection2 (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));
auto request2 (std::make_shared<nano::frontier_req_server> (connection, std::move (req2)));
ASSERT_TRUE (request2->frontier.is_zero ());
}
Expand Down Expand Up @@ -1880,7 +1880,7 @@ TEST (frontier_req, confirmed_frontier)
ASSERT_EQ (nano::block_status::progress, node1->process (receive2));

// Request for all accounts (confirmed only)
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req->start.clear ();
req->age = std::numeric_limits<decltype (req->age)>::max ();
Expand All @@ -1893,7 +1893,7 @@ TEST (frontier_req, confirmed_frontier)
ASSERT_EQ (nano::dev::genesis->hash (), request->frontier);

// Request starting with account before genesis (confirmed only)
auto connection2 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection2 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req2 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req2->start = key_before_genesis.pub;
req2->age = std::numeric_limits<decltype (req2->age)>::max ();
Expand All @@ -1906,7 +1906,7 @@ TEST (frontier_req, confirmed_frontier)
ASSERT_EQ (nano::dev::genesis->hash (), request2->frontier);

// Request starting with account after genesis (confirmed only)
auto connection3 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection3 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req3 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req3->start = key_after_genesis.pub;
req3->age = std::numeric_limits<decltype (req3->age)>::max ();
Expand All @@ -1919,7 +1919,7 @@ TEST (frontier_req, confirmed_frontier)
ASSERT_TRUE (request3->frontier.is_zero ());

// Request for all accounts (unconfirmed blocks)
auto connection4 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection4 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req4 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req4->start.clear ();
req4->age = std::numeric_limits<decltype (req4->age)>::max ();
Expand All @@ -1930,7 +1930,7 @@ TEST (frontier_req, confirmed_frontier)
ASSERT_EQ (receive1->hash (), request4->frontier);

// Request starting with account after genesis (unconfirmed blocks)
auto connection5 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection5 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req5 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req5->start = key_after_genesis.pub;
req5->age = std::numeric_limits<decltype (req5->age)>::max ();
Expand All @@ -1943,7 +1943,7 @@ TEST (frontier_req, confirmed_frontier)
// Confirm account before genesis (confirmed only)
ASSERT_TRUE (nano::test::start_elections (system, *node1, { send1, receive1 }, true));
ASSERT_TIMELY (5s, node1->block_confirmed (send1->hash ()) && node1->block_confirmed (receive1->hash ()));
auto connection6 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection6 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req6 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req6->start = key_before_genesis.pub;
req6->age = std::numeric_limits<decltype (req6->age)>::max ();
Expand All @@ -1958,7 +1958,7 @@ TEST (frontier_req, confirmed_frontier)
// Confirm account after genesis (confirmed only)
ASSERT_TRUE (nano::test::start_elections (system, *node1, { send2, receive2 }, true));
ASSERT_TIMELY (5s, node1->block_confirmed (send2->hash ()) && node1->block_confirmed (receive2->hash ()));
auto connection7 (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server), node1));
auto connection7 (std::make_shared<nano::transport::tcp_server> (node1, std::make_shared<nano::transport::socket> (*node1, nano::transport::socket::endpoint_type_t::server)));
auto req7 = std::make_unique<nano::frontier_req> (nano::dev::network_params.network);
req7->start = key_after_genesis.pub;
req7->age = std::numeric_limits<decltype (req7->age)>::max ();
Expand Down Expand Up @@ -2128,7 +2128,7 @@ TEST (bulk_pull_account, basics)
auto send2 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, 10));
auto send3 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, 2));
ASSERT_TIMELY_EQ (5s, system.nodes[0]->balance (key1.pub), 25);
auto connection (std::make_shared<nano::transport::tcp_server> (std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server), system.nodes[0]));
auto connection (std::make_shared<nano::transport::tcp_server> (system.nodes[0], std::make_shared<nano::transport::socket> (*system.nodes[0], nano::transport::socket::endpoint_type_t::server)));

{
auto req = std::make_unique<nano::bulk_pull_account> (nano::dev::network_params.network);
Expand Down
Loading

0 comments on commit fb603a2

Please sign in to comment.