Skip to content

Commit

Permalink
Use nano::test::setup_chain for test setup in bulk.genesis_pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed May 9, 2024
1 parent ab8d3a7 commit 4c813b2
Showing 1 changed file with 6 additions and 28 deletions.
34 changes: 6 additions & 28 deletions nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp>
#include <nano/test_common/chains.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down Expand Up @@ -2023,35 +2024,12 @@ TEST (bulk, genesis_pruning)
node_flags.enable_pruning = true;

auto node1 = system.add_node (config, node_flags);
system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv);

// do 3 sends from genesis to key2
nano::keypair key2;
auto send1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, 100));
ASSERT_NE (nullptr, send1);
auto send2 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, 100));
ASSERT_NE (nullptr, send2);
auto send3 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, 100));
ASSERT_NE (nullptr, send3);

{
auto transaction (node1->wallets.tx_begin_write ());
system.wallet (0)->store.erase (transaction, nano::dev::genesis_key.pub);
}

ASSERT_TIMELY_EQ (5s, send3->hash (), node1->latest (nano::dev::genesis_key.pub));

ASSERT_TRUE (nano::test::start_elections (system, *node1, { send1 }, true));
ASSERT_TIMELY (5s, node1->active.active (send2->qualified_root ()));
ASSERT_EQ (0, node1->ledger.pruned_count ());

ASSERT_TRUE (nano::test::start_elections (system, *node1, { send2 }, true));
ASSERT_TIMELY (5s, node1->active.active (send3->qualified_root ()));
ASSERT_EQ (0, node1->ledger.pruned_count ());

ASSERT_TRUE (nano::test::start_elections (system, *node1, { send3 }, true));
ASSERT_TIMELY (5s, nano::test::confirmed (*node1, { send3 }));
auto blocks = nano::test::setup_chain (system, *node1, 3);
auto send1 = blocks[0];
auto send2 = blocks[1];
auto send3 = blocks[2];

ASSERT_EQ (4, node1->ledger.block_count ());
node1->ledger_pruning (2, false);
ASSERT_EQ (2, node1->ledger.pruned_count ());
ASSERT_EQ (4, node1->ledger.block_count ());
Expand Down

0 comments on commit 4c813b2

Please sign in to comment.