diff --git a/nano/core_test/active_transactions.cpp b/nano/core_test/active_transactions.cpp index 472c82c6bf..cfe8355eaa 100644 --- a/nano/core_test/active_transactions.cpp +++ b/nano/core_test/active_transactions.cpp @@ -17,13 +17,12 @@ TEST (active_transactions, confirm_active) nano::node_flags node_flags; node_flags.disable_request_loop = true; auto & node1 = *system.add_node (node_flags); - nano::genesis genesis; auto send = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (nano::public_key ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1.process (*send).code); nano::node_config node_config2 (nano::get_available_port (), system.logging); @@ -49,7 +48,7 @@ TEST (active_transactions, confirm_active) ASSERT_FALSE (peers.empty ()); { nano::lock_guard guard (node2.rep_crawler.probable_reps_mutex); - node2.rep_crawler.probable_reps.emplace (nano::dev::genesis_key.pub, nano::dev::genesis_amount, *peers.begin ()); + node2.rep_crawler.probable_reps.emplace (nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, *peers.begin ()); } ASSERT_TIMELY (5s, election->votes ().size () != 1); // Votes were inserted (except for not_an_account) auto confirm_req_count (election->confirmation_request_count.load ()); @@ -89,19 +88,18 @@ TEST (active_transactions, confirm_frontier) ASSERT_FALSE (peers.empty ()); { nano::lock_guard guard (node2.rep_crawler.probable_reps_mutex); - node2.rep_crawler.probable_reps.emplace (nano::dev::genesis_key.pub, nano::dev::genesis_amount, *peers.begin ()); + node2.rep_crawler.probable_reps.emplace (nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, *peers.begin ()); } - nano::genesis genesis; nano::state_block_builder builder; auto send = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (nano::public_key ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send_copy = builder.make_block ().from (*send).build_shared (); ASSERT_EQ (nano::process_result::progress, node1.process (*send).code); @@ -127,7 +125,6 @@ TEST (active_transactions, keep_local) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node = *system.add_node (node_config); auto & wallet (*system.wallet (0)); - nano::genesis genesis; //key 1/2 will be managed by the wallet nano::keypair key1, key2, key3, key4, key5, key6; wallet.insert_adhoc (nano::dev::genesis_key.prv); @@ -193,7 +190,7 @@ TEST (active_transactions, inactive_votes_cache) auto send = nano::send_block_builder () .previous (latest) .destination (key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); @@ -215,7 +212,7 @@ TEST (active_transactions, inactive_votes_cache_non_final) auto send = nano::send_block_builder () .previous (latest) .destination (key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); @@ -228,7 +225,7 @@ TEST (active_transactions, inactive_votes_cache_non_final) auto election = node.active.election (send->qualified_root ()); ASSERT_NE (nullptr, election); ASSERT_FALSE (election->confirmed ()); - ASSERT_EQ (nano::dev::genesis_amount - 100, election->tally ().begin ()->first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, election->tally ().begin ()->first); } TEST (active_transactions, inactive_votes_cache_fork) @@ -241,14 +238,14 @@ TEST (active_transactions, inactive_votes_cache_fork) auto send1 = builder.make_block () .previous (latest) .destination (key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); auto send2 = builder.make_block () .previous (latest) .destination (key.pub) - .balance (nano::dev::genesis_amount - 200) + .balance (nano::dev::constants.genesis_amount - 200) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); @@ -285,7 +282,7 @@ TEST (active_transactions, inactive_votes_cache_existing_vote) auto send = builder.send () .previous (latest) .destination (key.pub) - .balance (nano::dev::genesis_amount - 100 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 100 * nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); @@ -342,7 +339,7 @@ TEST (active_transactions, inactive_votes_cache_multiple_votes) auto send1 = builder.send () .previous (latest) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 100 * nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); @@ -394,14 +391,14 @@ TEST (active_transactions, inactive_votes_cache_election_start) auto send1 = send_block_builder.make_block () .previous (latest) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 5000 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 5000 * nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (latest)) .build_shared (); auto send2 = send_block_builder.make_block () .previous (send1->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 10000 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 10000 * nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send1->hash ())) .build_shared (); @@ -492,17 +489,16 @@ TEST (active_transactions, vote_replays) node_config.enable_voting = false; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node = *system.add_node (node_config); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_NE (nullptr, send1); auto open1 = builder.make_block () @@ -582,31 +578,27 @@ TEST (active_transactions, dropped_cleanup) flags.disable_request_loop = true; auto & node (*system.add_node (flags)); - nano::genesis genesis; - auto block = genesis.open; - block->sideband_set (nano::block_sideband (nano::dev::genesis->account (), 0, nano::dev::genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); - // Add to network filter to ensure proper cleanup after the election is dropped std::vector block_bytes; { nano::vectorstream stream (block_bytes); - block->serialize (stream); + nano::dev::genesis->serialize (stream); } ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); - node.block_confirm (block); + node.block_confirm (nano::dev::genesis); node.scheduler.flush (); - auto election = node.active.election (block->qualified_root ()); + auto election = node.active.election (nano::dev::genesis->qualified_root ()); ASSERT_NE (nullptr, election); // Not yet removed ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); - ASSERT_EQ (1, node.active.blocks.count (block->hash ())); + ASSERT_EQ (1, node.active.blocks.count (nano::dev::genesis->hash ())); // Now simulate dropping the election ASSERT_FALSE (election->confirmed ()); - node.active.erase (*block); + node.active.erase (*nano::dev::genesis); // The filter must have been cleared ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); @@ -615,17 +607,17 @@ TEST (active_transactions, dropped_cleanup) ASSERT_EQ (1, node.stats.count (nano::stat::type::election, nano::stat::detail::election_drop_all)); // Block cleared from active - ASSERT_EQ (0, node.active.blocks.count (block->hash ())); + ASSERT_EQ (0, node.active.blocks.count (nano::dev::genesis->hash ())); // Repeat test for a confirmed election ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); - node.block_confirm (block); + node.block_confirm (nano::dev::genesis); node.scheduler.flush (); - election = node.active.election (block->qualified_root ()); + election = node.active.election (nano::dev::genesis->qualified_root ()); ASSERT_NE (nullptr, election); election->force_confirm (); ASSERT_TRUE (election->confirmed ()); - node.active.erase (*block); + node.active.erase (*nano::dev::genesis); // The filter should not have been cleared ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); @@ -634,7 +626,7 @@ TEST (active_transactions, dropped_cleanup) ASSERT_EQ (1, node.stats.count (nano::stat::type::election, nano::stat::detail::election_drop_all)); // Block cleared from active - ASSERT_EQ (0, node.active.blocks.count (block->hash ())); + ASSERT_EQ (0, node.active.blocks.count (nano::dev::genesis->hash ())); } TEST (active_transactions, republish_winner) @@ -646,17 +638,16 @@ TEST (active_transactions, republish_winner) node_config.peering_port = nano::get_available_port (); auto & node2 = *system.add_node (node_config); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); @@ -668,12 +659,12 @@ TEST (active_transactions, republish_winner) { auto fork = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1 - i) + .balance (nano::dev::constants.genesis_amount - 1 - i) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (fork); } @@ -684,12 +675,12 @@ TEST (active_transactions, republish_winner) // Process new fork with vote to change winner auto fork = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (fork); @@ -712,17 +703,16 @@ TEST (active_transactions, fork_filter_cleanup) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config)); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); std::vector block_bytes; { @@ -735,12 +725,12 @@ TEST (active_transactions, fork_filter_cleanup) { auto fork = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1 - i) + .balance (nano::dev::constants.genesis_amount - 1 - i) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (fork); node1.block_processor.flush (); @@ -771,12 +761,11 @@ TEST (active_transactions, fork_replacement_tally) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config)); - nano::genesis genesis; size_t reps_count = 20; size_t const max_blocks = 10; std::vector keys (reps_count); - auto latest (genesis.hash ()); - auto balance (nano::dev::genesis_amount); + auto latest (nano::dev::genesis->hash ()); + auto balance (nano::dev::constants.genesis_amount); auto amount (node1.minimum_principal_weight ()); nano::state_block_builder builder; @@ -942,13 +931,12 @@ TEST (active_transactions, confirm_new) { nano::system system (1); auto & node1 = *system.nodes[0]; - nano::genesis genesis; auto send = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (nano::public_key ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send); node1.block_processor.flush (); @@ -970,26 +958,25 @@ TEST (active_transactions, conflicting_block_vote_existing_election) nano::node_flags node_flags; node_flags.disable_request_loop = true; auto & node = *system.add_node (node_flags); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto fork = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 200) + .balance (nano::dev::constants.genesis_amount - 200) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto vote_fork (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, std::numeric_limits::max (), fork)); @@ -1024,7 +1011,7 @@ TEST (active_transactions, activate_account_chain) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build (); @@ -1033,7 +1020,7 @@ TEST (active_transactions, activate_account_chain) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) .build (); @@ -1042,7 +1029,7 @@ TEST (active_transactions, activate_account_chain) .previous (send2->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 3) + .balance (nano::dev::constants.genesis_amount - 3) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send2->hash ())) .build (); @@ -1124,7 +1111,7 @@ TEST (active_transactions, activate_inactive) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -1133,7 +1120,7 @@ TEST (active_transactions, activate_inactive) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::keypair ().pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) .build_shared (); @@ -1185,7 +1172,7 @@ TEST (active_transactions, pessimistic_elections) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -1197,7 +1184,7 @@ TEST (active_transactions, pessimistic_elections) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) .build (); @@ -1324,7 +1311,7 @@ TEST (active_transactions, list_active) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -1336,7 +1323,7 @@ TEST (active_transactions, list_active) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) .build_shared (); @@ -1379,7 +1366,7 @@ TEST (active_transactions, vacancy) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -1417,7 +1404,7 @@ TEST (active_transactions, fifo) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key0.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -1430,7 +1417,7 @@ TEST (active_transactions, fifo) .previous (send0->hash ()) .representative (nano::dev::genesis_key.pub) .link (key1.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send0->hash ())) .build_shared (); diff --git a/nano/core_test/block_store.cpp b/nano/core_test/block_store.cpp index 2bd7952f65..85d1ad7050 100644 --- a/nano/core_test/block_store.cpp +++ b/nano/core_test/block_store.cpp @@ -324,14 +324,12 @@ TEST (block_store, genesis) nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; - auto hash (genesis.hash ()); nano::ledger_cache ledger_cache; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger_cache); nano::account_info info; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis->account (), info)); - ASSERT_EQ (hash, info.head); + ASSERT_EQ (nano::dev::genesis->hash (), info.head); auto block1 (store->block.get (transaction, info.head)); ASSERT_NE (nullptr, block1); auto receive1 (dynamic_cast (block1.get ())); @@ -342,7 +340,7 @@ TEST (block_store, genesis) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (store->confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (confirmation_height_info.height, 1); - ASSERT_EQ (confirmation_height_info.frontier, hash); + ASSERT_EQ (confirmation_height_info.frontier, nano::dev::genesis->hash ()); auto dev_pub_text (nano::dev::genesis_key.pub.to_string ()); auto dev_pub_account (nano::dev::genesis_key.pub.to_account ()); auto dev_prv_text (nano::dev::genesis_key.prv.to_string ()); @@ -661,7 +659,6 @@ TEST (mdb_block_store, supported_version_upgrades) } // Check that upgrading from an unsupported version is not supported auto path (nano::unique_path ()); - nano::genesis genesis; nano::logger_mt logger; { nano::mdb_store store (logger, path); @@ -693,7 +690,7 @@ TEST (mdb_block_store, supported_version_upgrades) ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "accounts_v1", MDB_CREATE, &store.accounts_v1_handle)); ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "open", MDB_CREATE, &store.open_blocks_handle)); modify_account_info_to_v14 (store, transaction, nano::dev::genesis->account (), 1, nano::dev::genesis->hash ()); - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::genesis ().open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); } // Upgrade should work @@ -880,7 +877,6 @@ TEST (block_store, cemented_count_cache) auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_TRUE (!store->init_error ()); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; nano::ledger_cache ledger_cache; store->initialize (transaction, ledger_cache); ASSERT_EQ (1, ledger_cache.cemented_count); @@ -890,8 +886,6 @@ TEST (block_store, block_random) { nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path ()); - ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; { nano::ledger_cache ledger_cache; auto transaction (store->tx_begin_write ()); @@ -900,7 +894,7 @@ TEST (block_store, block_random) auto transaction (store->tx_begin_read ()); auto block (store->block.random (transaction)); ASSERT_NE (nullptr, block); - ASSERT_EQ (*block, *genesis.open); + ASSERT_EQ (*block, *nano::dev::genesis); } TEST (block_store, pruned_random) @@ -908,7 +902,6 @@ TEST (block_store, pruned_random) nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::open_block block (0, 1, 0, nano::keypair ().prv, 0, 0); block.sideband_set ({}); auto hash1 (block.hash ()); @@ -970,9 +963,8 @@ TEST (block_store, state_block) nano::logger_mt logger; auto store = nano::make_store (logger, nano::unique_path ()); ASSERT_FALSE (store->init_error ()); - nano::genesis genesis; nano::keypair key1; - nano::state_block block1 (1, genesis.hash (), 3, 4, 6, key1.prv, key1.pub, 7); + nano::state_block block1 (1, nano::dev::genesis->hash (), 3, 4, 6, key1.prv, key1.pub, 7); block1.sideband_set ({}); { nano::ledger_cache ledger_cache; @@ -1005,7 +997,6 @@ TEST (mdb_block_store, sideband_height) return; } nano::logger_mt logger; - nano::genesis genesis; nano::keypair key1; nano::keypair key2; nano::keypair key3; @@ -1016,17 +1007,17 @@ TEST (mdb_block_store, sideband_height) auto transaction (store.tx_begin_write ()); store.initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send (genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); nano::receive_block receive (send.hash (), send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code); nano::change_block change (receive.hash (), 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (receive.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change).code); - nano::state_block state_send1 (nano::dev::genesis_key.pub, change.hash (), 0, nano::dev::genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change.hash ())); + nano::state_block state_send1 (nano::dev::genesis_key.pub, change.hash (), 0, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send1).code); - nano::state_block state_send2 (nano::dev::genesis_key.pub, state_send1.hash (), 0, nano::dev::genesis_amount - 2 * nano::Gxrb_ratio, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send1.hash ())); + nano::state_block state_send2 (nano::dev::genesis_key.pub, state_send1.hash (), 0, nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send2).code); - nano::state_block state_send3 (nano::dev::genesis_key.pub, state_send2.hash (), 0, nano::dev::genesis_amount - 3 * nano::Gxrb_ratio, key3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send2.hash ())); + nano::state_block state_send3 (nano::dev::genesis_key.pub, state_send2.hash (), 0, nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio, key3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_send3).code); nano::state_block state_open (key1.pub, 0, 0, nano::Gxrb_ratio, state_send1.hash (), key1.prv, key1.pub, *pool.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_open).code); @@ -1040,7 +1031,7 @@ TEST (mdb_block_store, sideband_height) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, state_receive).code); nano::open_block open (state_send3.hash (), nano::dev::genesis_key.pub, key3.pub, key3.prv, key3.pub, *pool.generate (key3.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code); - auto block1 (store.block.get (transaction, genesis.hash ())); + auto block1 (store.block.get (transaction, nano::dev::genesis->hash ())); ASSERT_EQ (block1->sideband ().height, 1); auto block2 (store.block.get (transaction, send.hash ())); ASSERT_EQ (block2->sideband ().height, 2); @@ -1271,12 +1262,11 @@ TEST (mdb_block_store, upgrade_v14_v15) } // Extract confirmation height to a separate database auto path (nano::unique_path ()); - nano::genesis genesis; nano::network_params network_params; nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send (genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); - nano::state_block epoch (nano::dev::genesis_key.pub, send.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); - nano::state_block state_send (nano::dev::genesis_key.pub, epoch.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch.hash ())); + nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::state_block epoch (nano::dev::genesis_key.pub, send.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); + nano::state_block state_send (nano::dev::genesis_key.pub, epoch.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch.hash ())); { nano::logger_mt logger; nano::mdb_store store (logger, path); @@ -1289,7 +1279,7 @@ TEST (mdb_block_store, upgrade_v14_v15) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (store.confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (confirmation_height_info.height, 1); - ASSERT_EQ (confirmation_height_info.frontier, genesis.hash ()); + ASSERT_EQ (confirmation_height_info.frontier, nano::dev::genesis->hash ()); // These databases get removed after an upgrade, so readd them ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "state_v1", MDB_CREATE, &store.state_blocks_v1_handle)); ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "accounts_v1", MDB_CREATE, &store.accounts_v1_handle)); @@ -1309,7 +1299,7 @@ TEST (mdb_block_store, upgrade_v14_v15) write_sideband_v14 (store, transaction, state_send, store.state_blocks_v1_handle); write_sideband_v14 (store, transaction, epoch, store.state_blocks_v1_handle); - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *genesis.open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); write_block_w_sideband_v18 (store, store.send_blocks_handle, transaction, send); // Remove from blocks table @@ -1347,7 +1337,7 @@ TEST (mdb_block_store, upgrade_v14_v15) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (store.confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (confirmation_height_info.height, 1); - ASSERT_EQ (confirmation_height_info.frontier, genesis.hash ()); + ASSERT_EQ (confirmation_height_info.frontier, nano::dev::genesis->hash ()); // accounts_v1, state_blocks_v1 & pending_v1 tables should be deleted auto error_get_accounts_v1 (mdb_get (store.env.tx (transaction), store.accounts_v1_handle, nano::mdb_val (nano::dev::genesis->account ()), value)); @@ -1385,7 +1375,6 @@ TEST (mdb_block_store, upgrade_v15_v16) auto path (nano::unique_path ()); nano::mdb_val value; { - nano::genesis genesis; nano::logger_mt logger; nano::mdb_store store (logger, path); nano::stat stats; @@ -1398,7 +1387,7 @@ TEST (mdb_block_store, upgrade_v15_v16) auto weight = ledger.cache.rep_weights.representation_get (nano::dev::genesis->account ()); ASSERT_EQ (MDB_SUCCESS, mdb_put (txn, store.representation_handle, nano::mdb_val (nano::dev::genesis->account ()), nano::mdb_val (nano::uint128_union (weight)), 0)); ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "open", MDB_CREATE, &store.open_blocks_handle)); - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *genesis.open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); // Lower the database to the previous version store.version.put (transaction, 15); // Confirm the rep weight exists in the database @@ -1428,17 +1417,15 @@ TEST (mdb_block_store, upgrade_v16_v17) // Don't test this in rocksdb mode return; } - nano::genesis genesis; nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block block1 (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); - nano::state_block block2 (nano::dev::genesis_key.pub, block1.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio - 1, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); - nano::state_block block3 (nano::dev::genesis_key.pub, block2.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio - 2, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block2.hash ())); + nano::state_block block1 (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::state_block block2 (nano::dev::genesis_key.pub, block1.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 1, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); + nano::state_block block3 (nano::dev::genesis_key.pub, block2.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 2, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block2.hash ())); auto code = [&block1, &block2, &block3] (auto confirmation_height, nano::block_hash const & expected_cemented_frontier) { auto path (nano::unique_path ()); nano::mdb_val value; { - nano::genesis genesis; nano::logger_mt logger; nano::mdb_store store (logger, path); nano::stat stats; @@ -1451,7 +1438,7 @@ TEST (mdb_block_store, upgrade_v16_v17) modify_confirmation_height_to_v15 (store, transaction, nano::dev::genesis->account (), confirmation_height); ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "open", MDB_CREATE, &store.open_blocks_handle)); - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *genesis.open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); ASSERT_FALSE (mdb_dbi_open (store.env.tx (transaction), "state_blocks", MDB_CREATE, &store.state_blocks_handle)); write_block_w_sideband_v18 (store, store.state_blocks_handle, transaction, block1); write_block_w_sideband_v18 (store, store.state_blocks_handle, transaction, block2); @@ -1479,7 +1466,7 @@ TEST (mdb_block_store, upgrade_v16_v17) }; code (0, nano::block_hash (0)); - code (1, genesis.hash ()); + code (1, nano::dev::genesis->hash ()); code (2, block1.hash ()); code (3, block2.hash ()); code (4, block3.hash ()); @@ -1493,22 +1480,21 @@ TEST (mdb_block_store, upgrade_v17_v18) return; } auto path (nano::unique_path ()); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; nano::keypair key3; nano::network_params network_params; nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send_zero (genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); - nano::state_block state_receive_zero (nano::dev::genesis_key.pub, send_zero.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, send_zero.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send_zero.hash ())); - nano::state_block epoch (nano::dev::genesis_key.pub, state_receive_zero.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_receive_zero.hash ())); - nano::state_block state_send (nano::dev::genesis_key.pub, epoch.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch.hash ())); - nano::state_block state_receive (nano::dev::genesis_key.pub, state_send.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, state_send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send.hash ())); - nano::state_block state_change (nano::dev::genesis_key.pub, state_receive.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_receive.hash ())); - nano::state_block state_send_change (nano::dev::genesis_key.pub, state_change.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_change.hash ())); + nano::send_block send_zero (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::state_block state_receive_zero (nano::dev::genesis_key.pub, send_zero.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, send_zero.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send_zero.hash ())); + nano::state_block epoch (nano::dev::genesis_key.pub, state_receive_zero.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_receive_zero.hash ())); + nano::state_block state_send (nano::dev::genesis_key.pub, epoch.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch.hash ())); + nano::state_block state_receive (nano::dev::genesis_key.pub, state_send.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, state_send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send.hash ())); + nano::state_block state_change (nano::dev::genesis_key.pub, state_receive.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_receive.hash ())); + nano::state_block state_send_change (nano::dev::genesis_key.pub, state_change.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_change.hash ())); nano::state_block epoch_first (key1.pub, 0, 0, 0, network_params.ledger.epochs.link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (key1.pub)); nano::state_block state_receive2 (key1.pub, epoch_first.hash (), key1.pub, nano::Gxrb_ratio, state_send_change.hash (), key1.prv, key1.pub, *pool.generate (epoch_first.hash ())); - nano::state_block state_send2 (nano::dev::genesis_key.pub, state_send_change.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send_change.hash ())); + nano::state_block state_send2 (nano::dev::genesis_key.pub, state_send_change.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_send_change.hash ())); nano::state_block state_open (key2.pub, 0, key2.pub, nano::Gxrb_ratio, state_send2.hash (), key2.prv, key2.pub, *pool.generate (key2.pub)); nano::state_block state_send_epoch_link (key2.pub, state_open.hash (), key2.pub, 0, network_params.ledger.epochs.link (nano::epoch::epoch_2), key2.prv, key2.pub, *pool.generate (state_open.hash ())); { @@ -1542,7 +1528,7 @@ TEST (mdb_block_store, upgrade_v17_v18) write_block_w_sideband_v18 (store, store.state_blocks_handle, transaction, epoch_first); write_block_w_sideband_v18 (store, store.state_blocks_handle, transaction, state_send2); write_block_w_sideband_v18 (store, store.state_blocks_handle, transaction, state_send_epoch_link); - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *genesis.open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); write_block_w_sideband_v18 (store, store.send_blocks_handle, transaction, send_zero); // Replace with the previous sideband version for state blocks @@ -1700,15 +1686,14 @@ TEST (mdb_block_store, upgrade_v18_v19) nano::keypair key1; nano::work_pool pool (std::numeric_limits::max ()); nano::network_params network_params; - nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); nano::receive_block receive (send.hash (), send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); nano::change_block change (receive.hash (), 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (receive.hash ())); - nano::state_block state_epoch (nano::dev::genesis_key.pub, change.hash (), 0, nano::dev::genesis_amount, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change.hash ())); - nano::state_block state_send (nano::dev::genesis_key.pub, state_epoch.hash (), 0, nano::dev::genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_epoch.hash ())); + nano::state_block state_epoch (nano::dev::genesis_key.pub, change.hash (), 0, nano::dev::constants.genesis_amount, network_params.ledger.epochs.link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change.hash ())); + nano::state_block state_send (nano::dev::genesis_key.pub, state_epoch.hash (), 0, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (state_epoch.hash ())); nano::state_block state_open (key1.pub, 0, 0, nano::Gxrb_ratio, state_send.hash (), key1.prv, key1.pub, *pool.generate (key1.pub)); { - nano::genesis genesis; nano::logger_mt logger; nano::mdb_store store (logger, path); nano::stat stats; @@ -1732,7 +1717,7 @@ TEST (mdb_block_store, upgrade_v18_v19) ASSERT_FALSE (mdb_dbi_open (txn, "state_blocks", MDB_CREATE, &store.state_blocks_handle)); // Modify blocks back to the old tables - write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *genesis.open); + write_block_w_sideband_v18 (store, store.open_blocks_handle, transaction, *nano::dev::genesis); write_block_w_sideband_v18 (store, store.send_blocks_handle, transaction, send); write_block_w_sideband_v18 (store, store.receive_blocks_handle, transaction, receive); write_block_w_sideband_v18 (store, store.change_blocks_handle, transaction, change); @@ -1790,7 +1775,6 @@ TEST (mdb_block_store, upgrade_v19_v20) return; } auto path (nano::unique_path ()); - nano::genesis genesis; nano::logger_mt logger; nano::stat stats; { @@ -1820,7 +1804,6 @@ TEST (mdb_block_store, upgrade_v20_v21) return; } auto path (nano::unique_path ()); - nano::genesis genesis; nano::logger_mt logger; nano::stat stats; { @@ -1867,7 +1850,6 @@ TEST (mdb_block_store, upgrade_backup) { nano::logger_mt logger; - nano::genesis genesis; nano::mdb_store store (logger, path); auto transaction (store.tx_begin_write ()); store.version.put (transaction, 14); @@ -1942,7 +1924,7 @@ TEST (block_store, final_vote) auto store = nano::make_store (logger, path); { - auto qualified_root = nano::genesis ().open->qualified_root (); + auto qualified_root = nano::dev::genesis->qualified_root (); auto transaction (store->tx_begin_write ()); store->final_vote.put (transaction, qualified_root, nano::block_hash (2)); ASSERT_EQ (store->final_vote.count (transaction), 1); diff --git a/nano/core_test/bootstrap.cpp b/nano/core_test/bootstrap.cpp index 22e2563535..3f78180981 100644 --- a/nano/core_test/bootstrap.cpp +++ b/nano/core_test/bootstrap.cpp @@ -64,10 +64,9 @@ TEST (bulk_pull, end_not_owned) system.nodes[0]->work_generate_blocking (open); ASSERT_EQ (nano::process_result::progress, system.nodes[0]->process (open).code); auto connection (std::make_shared (std::make_shared (*system.nodes[0]), system.nodes[0])); - nano::genesis genesis; auto req = std::make_unique (); req->start = key2.pub; - req->end = genesis.hash (); + req->end = nano::dev::genesis->hash (); connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); ASSERT_EQ (request->current, request->request->end); @@ -77,10 +76,9 @@ TEST (bulk_pull, none) { nano::system system (1); auto connection (std::make_shared (std::make_shared (*system.nodes[0]), system.nodes[0])); - nano::genesis genesis; auto req = std::make_unique (); req->start = nano::dev::genesis_key.pub; - req->end = genesis.hash (); + req->end = nano::dev::genesis->hash (); connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); auto block (request->get_next ()); @@ -107,15 +105,14 @@ TEST (bulk_pull, by_block) { nano::system system (1); auto connection (std::make_shared (std::make_shared (*system.nodes[0]), system.nodes[0])); - nano::genesis genesis; auto req = std::make_unique (); - req->start = genesis.hash (); + req->start = nano::dev::genesis->hash (); req->end.clear (); connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); auto block (request->get_next ()); ASSERT_NE (nullptr, block); - ASSERT_EQ (block->hash (), genesis.hash ()); + ASSERT_EQ (block->hash (), nano::dev::genesis->hash ()); block = request->get_next (); ASSERT_EQ (nullptr, block); @@ -125,15 +122,14 @@ TEST (bulk_pull, by_block_single) { nano::system system (1); auto connection (std::make_shared (std::make_shared (*system.nodes[0]), system.nodes[0])); - nano::genesis genesis; auto req = std::make_unique (); - req->start = genesis.hash (); - req->end = genesis.hash (); + req->start = nano::dev::genesis->hash (); + req->end = nano::dev::genesis->hash (); connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); auto block (request->get_next ()); ASSERT_NE (nullptr, block); - ASSERT_EQ (block->hash (), genesis.hash ()); + ASSERT_EQ (block->hash (), nano::dev::genesis->hash ()); block = request->get_next (); ASSERT_EQ (nullptr, block); @@ -143,7 +139,6 @@ TEST (bulk_pull, count_limit) { nano::system system (1); auto node0 (system.nodes[0]); - nano::genesis genesis; auto send1 (std::make_shared (node0->latest (nano::dev::genesis_key.pub), nano::dev::genesis_key.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (node0->latest (nano::dev::genesis_key.pub)))); ASSERT_EQ (nano::process_result::progress, node0->process (*send1).code); @@ -248,7 +243,6 @@ TEST (bootstrap_processor, process_state) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::state_block_builder builder; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); @@ -256,7 +250,7 @@ TEST (bootstrap_processor, process_state) .account (nano::dev::genesis_key.pub) .previous (node0->latest (nano::dev::genesis_key.pub)) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -266,7 +260,7 @@ TEST (bootstrap_processor, process_state) .account (nano::dev::genesis_key.pub) .previous (block1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (block1->hash ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -353,19 +347,18 @@ TEST (bootstrap_processor, DISABLED_pull_requeue_network_error) auto node1 (system.add_node (config, node_flags)); config.peering_port = nano::get_available_port (); auto node2 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; nano::state_block_builder builder; auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1->bootstrap_initiator.bootstrap (node2->network.endpoint ()); @@ -377,7 +370,7 @@ TEST (bootstrap_processor, DISABLED_pull_requeue_network_error) nano::unique_lock lock (node1->bootstrap_initiator.connections->mutex); ASSERT_FALSE (attempt->stopped); ++attempt->pulling; - node1->bootstrap_initiator.connections->pulls.emplace_back (nano::dev::genesis_key.pub, send1->hash (), genesis.hash (), attempt->incremental_id); + node1->bootstrap_initiator.connections->pulls.emplace_back (nano::dev::genesis_key.pub, send1->hash (), nano::dev::genesis->hash (), attempt->incremental_id); node1->bootstrap_initiator.connections->request_pull (lock); node2->stop (); } @@ -431,7 +424,7 @@ TEST (bootstrap_processor, push_diamond_pruning) ASSERT_EQ (nano::process_result::progress, node1->process (*open).code); // 1st bootstrap node1->bootstrap_initiator.bootstrap (node0->network.endpoint (), false); - ASSERT_TIMELY (10s, node0->balance (key.pub) == nano::dev::genesis_amount); + ASSERT_TIMELY (10s, node0->balance (key.pub) == nano::dev::constants.genesis_amount); // Process more blocks & prune old auto send2 (std::make_shared (open->hash (), nano::dev::genesis_key.pub, std::numeric_limits::max () - 100, key.prv, key.pub, *system.work.generate (open->hash ()))); ASSERT_EQ (nano::process_result::progress, node1->process (*send2).code); @@ -486,7 +479,6 @@ TEST (bootstrap_processor, lazy_hash) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -495,12 +487,12 @@ TEST (bootstrap_processor, lazy_hash) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -561,7 +553,6 @@ TEST (bootstrap_processor, lazy_hash_bootstrap_id) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -570,12 +561,12 @@ TEST (bootstrap_processor, lazy_hash_bootstrap_id) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -638,7 +629,6 @@ TEST (bootstrap_processor, lazy_hash_pruning) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.enable_pruning = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -647,19 +637,19 @@ TEST (bootstrap_processor, lazy_hash_pruning) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (send1->hash ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node0->work_generate_blocking (send1->hash ())) @@ -669,7 +659,7 @@ TEST (bootstrap_processor, lazy_hash_pruning) .account (nano::dev::genesis_key.pub) .previous (receive1->hash ()) .representative (key1.pub) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node0->work_generate_blocking (receive1->hash ())) @@ -679,7 +669,7 @@ TEST (bootstrap_processor, lazy_hash_pruning) .account (nano::dev::genesis_key.pub) .previous (change1->hash ()) .representative (key2.pub) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node0->work_generate_blocking (change1->hash ())) @@ -689,7 +679,7 @@ TEST (bootstrap_processor, lazy_hash_pruning) .account (nano::dev::genesis_key.pub) .previous (change2->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node0->work_generate_blocking (change2->hash ())) @@ -772,7 +762,6 @@ TEST (bootstrap_processor, lazy_max_pull_count) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -781,12 +770,12 @@ TEST (bootstrap_processor, lazy_max_pull_count) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -876,7 +865,6 @@ TEST (bootstrap_processor, lazy_unclear_state_link) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_legacy_bootstrap = true; auto node1 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key; // Generating test chain @@ -884,12 +872,12 @@ TEST (bootstrap_processor, lazy_unclear_state_link) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1->process (*send1).code); auto send2 = builder @@ -897,7 +885,7 @@ TEST (bootstrap_processor, lazy_unclear_state_link) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send1->hash ())) @@ -939,7 +927,6 @@ TEST (bootstrap_processor, lazy_unclear_state_link_not_existing) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_legacy_bootstrap = true; auto node1 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key, key2; // Generating test chain @@ -947,12 +934,12 @@ TEST (bootstrap_processor, lazy_unclear_state_link_not_existing) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1->process (*send1).code); auto open (std::make_shared (send1->hash (), key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub))); @@ -991,7 +978,6 @@ TEST (bootstrap_processor, DISABLED_lazy_destinations) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_legacy_bootstrap = true; auto node1 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key1, key2; // Generating test chain @@ -999,12 +985,12 @@ TEST (bootstrap_processor, DISABLED_lazy_destinations) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1->process (*send1).code); auto send2 = builder @@ -1012,7 +998,7 @@ TEST (bootstrap_processor, DISABLED_lazy_destinations) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send1->hash ())) @@ -1056,7 +1042,6 @@ TEST (bootstrap_processor, lazy_pruning_missing_block) node_flags.disable_legacy_bootstrap = true; node_flags.enable_pruning = true; auto node1 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key1, key2; // Generating test chain @@ -1064,12 +1049,12 @@ TEST (bootstrap_processor, lazy_pruning_missing_block) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1->process_active (send1); auto send2 = builder @@ -1077,7 +1062,7 @@ TEST (bootstrap_processor, lazy_pruning_missing_block) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send1->hash ())) @@ -1151,7 +1136,6 @@ TEST (bootstrap_processor, lazy_cancel) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node0 (system.add_node (config, node_flags)); - nano::genesis genesis; nano::keypair key1; // Generating test chain @@ -1159,12 +1143,12 @@ TEST (bootstrap_processor, lazy_cancel) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); // Start lazy bootstrap with last block in chain known @@ -1190,7 +1174,6 @@ TEST (bootstrap_processor, wallet_lazy_frontier) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_legacy_bootstrap = true; auto node0 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -1199,12 +1182,12 @@ TEST (bootstrap_processor, wallet_lazy_frontier) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -1269,7 +1252,6 @@ TEST (bootstrap_processor, wallet_lazy_pending) node_flags.disable_bootstrap_bulk_push_client = true; node_flags.disable_legacy_bootstrap = true; auto node0 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -1278,12 +1260,12 @@ TEST (bootstrap_processor, wallet_lazy_pending) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node0->work_generate_blocking (genesis.hash ())) + .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -1331,7 +1313,6 @@ TEST (bootstrap_processor, multiple_attempts) nano::node_flags node_flags; node_flags.disable_bootstrap_bulk_push_client = true; auto node1 = system.add_node (config, node_flags); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; // Generating test chain @@ -1340,12 +1321,12 @@ TEST (bootstrap_processor, multiple_attempts) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1->work_generate_blocking (genesis.hash ())) + .work (*node1->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder .make_block () @@ -1434,8 +1415,7 @@ TEST (frontier_req, begin) connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); ASSERT_EQ (nano::dev::genesis_key.pub, request->current); - nano::genesis genesis; - ASSERT_EQ (genesis.hash (), request->frontier); + ASSERT_EQ (nano::dev::genesis->hash (), request->frontier); } TEST (frontier_req, end) @@ -1455,16 +1435,15 @@ TEST (frontier_req, count) { nano::system system (1); auto node1 = system.nodes[0]; - nano::genesis genesis; // Public key FB93... after genesis in accounts table nano::keypair key1 ("ED5AE0A6505B14B67435C29FD9FEEBC26F597D147BC92F6D795FFAD7AFD3D967"); nano::state_block_builder builder; auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1529,8 +1508,7 @@ TEST (frontier_req, time_cutoff) connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); ASSERT_EQ (nano::dev::genesis_key.pub, request->current); - nano::genesis genesis; - ASSERT_EQ (genesis.hash (), request->frontier); + ASSERT_EQ (nano::dev::genesis->hash (), request->frontier); // Wait 4 seconds until age of account will be > 3 seconds std::this_thread::sleep_for (std::chrono::milliseconds (4100)); auto req2 (std::make_unique ()); @@ -1547,7 +1525,6 @@ TEST (frontier_req, confirmed_frontier) { nano::system system (1); auto node1 = system.nodes[0]; - nano::genesis genesis; nano::raw_key priv_key; // Public key before genesis in accounts table while (nano::pub_key (priv_key).number () >= nano::dev::genesis_key.pub.number ()) @@ -1565,9 +1542,9 @@ TEST (frontier_req, confirmed_frontier) auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key_before_genesis.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1579,7 +1556,7 @@ TEST (frontier_req, confirmed_frontier) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key_after_genesis.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1623,7 +1600,7 @@ TEST (frontier_req, confirmed_frontier) connection->requests.push (std::unique_ptr{}); auto request (std::make_shared (connection, std::move (req))); ASSERT_EQ (nano::dev::genesis_key.pub, request->current); - ASSERT_EQ (genesis.hash (), request->frontier); + ASSERT_EQ (nano::dev::genesis->hash (), request->frontier); // Request starting with account before genesis (confirmed only) auto connection2 (std::make_shared (std::make_shared (*node1), node1)); @@ -1637,7 +1614,7 @@ TEST (frontier_req, confirmed_frontier) connection2->requests.push (std::unique_ptr{}); auto request2 (std::make_shared (connection2, std::move (req2))); ASSERT_EQ (nano::dev::genesis_key.pub, request2->current); - ASSERT_EQ (genesis.hash (), request2->frontier); + ASSERT_EQ (nano::dev::genesis->hash (), request2->frontier); // Request starting with account after genesis (confirmed only) auto connection3 (std::make_shared (std::make_shared (*node1), node1)); diff --git a/nano/core_test/confirmation_height.cpp b/nano/core_test/confirmation_height.cpp index 28dbfabe82..8477919188 100644 --- a/nano/core_test/confirmation_height.cpp +++ b/nano/core_test/confirmation_height.cpp @@ -223,13 +223,12 @@ TEST (confirmation_height, gap_bootstrap) nano::node_flags node_flags; node_flags.confirmation_height_processor_mode = mode_a; auto & node1 = *system.add_node (node_flags); - nano::genesis genesis; nano::keypair destination; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); - auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 2 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send2); - auto send3 (std::make_shared (nano::dev::genesis->account (), send2->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 3 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send3 (std::make_shared (nano::dev::genesis->account (), send2->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send3); auto open1 (std::make_shared (send1->hash (), destination.pub, destination.pub, destination.prv, destination.pub, 0)); node1.work_generate_blocking (*open1); @@ -261,7 +260,7 @@ TEST (confirmation_height, gap_bootstrap) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (node1.store.confirmation_height.get (transaction, nano::dev::genesis_key.pub, confirmation_height_info)); ASSERT_EQ (1, confirmation_height_info.height); - ASSERT_EQ (genesis.hash (), confirmation_height_info.frontier); + ASSERT_EQ (nano::dev::genesis->hash (), confirmation_height_info.frontier); } // Now complete the chain where the block comes in on the bootstrap network. @@ -277,7 +276,7 @@ TEST (confirmation_height, gap_bootstrap) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (node1.store.confirmation_height.get (transaction, nano::dev::genesis_key.pub, confirmation_height_info)); ASSERT_EQ (1, confirmation_height_info.height); - ASSERT_EQ (genesis.hash (), confirmation_height_info.frontier); + ASSERT_EQ (nano::dev::genesis->hash (), confirmation_height_info.frontier); ASSERT_TRUE (node1.store.confirmation_height.get (transaction, destination.pub, confirmation_height_info)); ASSERT_EQ (0, confirmation_height_info.height); ASSERT_EQ (nano::block_hash (0), confirmation_height_info.frontier); @@ -304,18 +303,17 @@ TEST (confirmation_height, gap_live) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node = system.add_node (node_config, node_flags); node_config.peering_port = nano::get_available_port (); - node_config.receive_minimum = nano::dev::genesis_amount; // Prevent auto-receive & open1/receive1/receive2 blocks conflicts + node_config.receive_minimum = nano::dev::constants.genesis_amount; // Prevent auto-receive & open1/receive1/receive2 blocks conflicts system.add_node (node_config, node_flags); nano::keypair destination; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); system.wallet (1)->insert_adhoc (destination.prv); - nano::genesis genesis; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 1, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 1, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node->work_generate_blocking (*send1); - auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 2, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 2, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node->work_generate_blocking (*send2); - auto send3 (std::make_shared (nano::dev::genesis->account (), send2->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 3, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send3 (std::make_shared (nano::dev::genesis->account (), send2->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 3, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node->work_generate_blocking (*send3); auto open1 (std::make_shared (send1->hash (), destination.pub, destination.pub, destination.prv, destination.pub, 0)); @@ -478,10 +476,10 @@ TEST (confirmation_height, send_receive_self) auto node = system.add_node (node_config, node_flags); nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); - nano::send_block send1 (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send1 (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); nano::receive_block receive1 (send1.hash (), send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); - nano::send_block send2 (receive1.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive1.hash ())); - nano::send_block send3 (send2.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2.hash ())); + nano::send_block send2 (receive1.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive1.hash ())); + nano::send_block send3 (send2.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2.hash ())); nano::receive_block receive2 (send3.hash (), send2.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3.hash ())); auto receive3 = std::make_shared (receive2.hash (), send3.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive2.hash ())); @@ -543,8 +541,8 @@ TEST (confirmation_height, all_block_types) nano::keypair key1; nano::keypair key2; auto & store = node->store; - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - nano::send_block send1 (send.hash (), key2.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send1 (send.hash (), key2.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); nano::open_block open (send.hash (), nano::dev::genesis_key.pub, key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)); nano::state_block state_open (key2.pub, 0, 0, nano::Gxrb_ratio, send1.hash (), key2.prv, key2.pub, *system.work.generate (key2.pub)); @@ -569,7 +567,7 @@ TEST (confirmation_height, all_block_types) nano::state_block state_send3 (key2.pub, state_send2->hash (), 0, nano::Gxrb_ratio - 1, key1.pub, key2.prv, key2.pub, *system.work.generate (state_send2->hash ())); nano::state_block state_send4 (key1.pub, state_send1.hash (), 0, nano::Gxrb_ratio - 2, nano::dev::genesis_key.pub, key1.prv, key1.pub, *system.work.generate (state_send1.hash ())); - nano::state_block state_receive3 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2 + 1, state_send4.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); + nano::state_block state_receive3 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2 + 1, state_send4.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); { auto transaction (store.tx_begin_write ()); @@ -655,11 +653,10 @@ TEST (confirmation_height, conflict_rollback_cemented) auto node2 = system.add_node (node_flags); ASSERT_EQ (1, node1->network.size ()); nano::keypair key1; - nano::genesis genesis; - auto send1 (std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); nano::publish publish1 (send1); nano::keypair key2; - auto send2 (std::make_shared (genesis.hash (), key2.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send2 (std::make_shared (nano::dev::genesis->hash (), key2.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); nano::publish publish2 (send2); auto channel1 (node1->network.udp_channels.create (node1->network.endpoint ())); node1->network.inbound (publish1, channel1); @@ -676,7 +673,7 @@ TEST (confirmation_height, conflict_rollback_cemented) node1->block_processor.flush (); node2->network.inbound (publish1, channel2); node2->block_processor.flush (); - auto election (node2->active.election (nano::qualified_root (genesis.hash (), genesis.hash ()))); + auto election (node2->active.election (nano::qualified_root (nano::dev::genesis->hash (), nano::dev::genesis->hash ()))); ASSERT_NE (nullptr, election); ASSERT_EQ (1, election->votes ().size ()); // Force blocks to be cemented on both nodes @@ -695,7 +692,7 @@ TEST (confirmation_height, conflict_rollback_cemented) ASSERT_TIMELY (20s, sb.component ()->str ().find (rollback_log_entry) != std::string::npos); auto winner (*election->tally ().begin ()); ASSERT_EQ (*publish1.block, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); ASSERT_TRUE (node1->ledger.block_or_pruned_exists (publish1.block->hash ())); ASSERT_TRUE (node2->ledger.block_or_pruned_exists (publish2.block->hash ())); ASSERT_FALSE (node2->ledger.block_or_pruned_exists (publish1.block->hash ())); @@ -723,13 +720,12 @@ TEST (confirmation_heightDeathTest, rollback_added_block) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); nano::write_database_queue write_database_queue (false); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - auto send = std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); { auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); @@ -800,13 +796,12 @@ TEST (confirmation_heightDeathTest, modified_chain) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); nano::write_database_queue write_database_queue (false); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); { auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); @@ -871,13 +866,12 @@ TEST (confirmation_heightDeathTest, modified_chain_account_removed) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); nano::write_database_queue write_database_queue (false); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto open = std::make_shared (key1.pub, 0, 0, nano::Gxrb_ratio, send->hash (), key1.prv, key1.pub, *pool.generate (key1.pub)); { auto transaction (store->tx_begin_write ()); @@ -940,8 +934,8 @@ TEST (confirmation_height, pending_observer_callbacks) nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); nano::keypair key1; - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - auto send1 = std::make_shared (send.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + auto send1 = std::make_shared (send.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); { auto transaction = node->store.tx_begin_write (); @@ -982,13 +976,13 @@ TEST (confirmation_height, callback_confirmed_history) nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); nano::keypair key1; - auto send = std::make_shared (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + auto send = std::make_shared (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); { auto transaction = node->store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send).code); } - auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); + auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); add_callback_stats (*node); @@ -1063,9 +1057,9 @@ TEST (confirmation_height, dependent_election) nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); nano::keypair key1; - auto send = std::make_shared (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); - auto send2 = std::make_shared (send1->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ())); + auto send = std::make_shared (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); + auto send2 = std::make_shared (send1->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ())); { auto transaction = node->store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send).code); @@ -1115,22 +1109,22 @@ TEST (confirmation_height, cemented_gap_below_receive) nano::keypair key1; system.wallet (0)->insert_adhoc (key1.prv); - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - nano::send_block send1 (send.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send1 (send.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); nano::keypair dummy_key; - nano::send_block dummy_send (send1.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); + nano::send_block dummy_send (send1.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); nano::open_block open (send.hash (), nano::dev::genesis->account (), key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)); nano::receive_block receive1 (open.hash (), send1.hash (), key1.prv, key1.pub, *system.work.generate (open.hash ())); nano::send_block send2 (receive1.hash (), nano::dev::genesis_key.pub, nano::Gxrb_ratio, key1.prv, key1.pub, *system.work.generate (receive1.hash ())); nano::receive_block receive2 (dummy_send.hash (), send2.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send.hash ())); - nano::send_block dummy_send1 (receive2.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive2.hash ())); + nano::send_block dummy_send1 (receive2.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive2.hash ())); nano::keypair key2; system.wallet (0)->insert_adhoc (key2.prv); - nano::send_block send3 (dummy_send1.hash (), key2.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 4, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send1.hash ())); - nano::send_block dummy_send2 (send3.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 5, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3.hash ())); + nano::send_block send3 (dummy_send1.hash (), key2.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 4, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send1.hash ())); + nano::send_block dummy_send2 (send3.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 5, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3.hash ())); auto open1 = std::make_shared (send3.hash (), nano::dev::genesis->account (), key2.pub, key2.prv, key2.pub, *system.work.generate (key2.pub)); @@ -1200,22 +1194,22 @@ TEST (confirmation_height, cemented_gap_below_no_cache) nano::keypair key1; system.wallet (0)->insert_adhoc (key1.prv); - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - nano::send_block send1 (send.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send1 (send.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send.hash ())); nano::keypair dummy_key; - nano::send_block dummy_send (send1.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); + nano::send_block dummy_send (send1.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); nano::open_block open (send.hash (), nano::dev::genesis->account (), key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)); nano::receive_block receive1 (open.hash (), send1.hash (), key1.prv, key1.pub, *system.work.generate (open.hash ())); nano::send_block send2 (receive1.hash (), nano::dev::genesis_key.pub, nano::Gxrb_ratio, key1.prv, key1.pub, *system.work.generate (receive1.hash ())); nano::receive_block receive2 (dummy_send.hash (), send2.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send.hash ())); - nano::send_block dummy_send1 (receive2.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive2.hash ())); + nano::send_block dummy_send1 (receive2.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive2.hash ())); nano::keypair key2; system.wallet (0)->insert_adhoc (key2.prv); - nano::send_block send3 (dummy_send1.hash (), key2.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 4, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send1.hash ())); - nano::send_block dummy_send2 (send3.hash (), dummy_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 5, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3.hash ())); + nano::send_block send3 (dummy_send1.hash (), key2.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 4, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (dummy_send1.hash ())); + nano::send_block dummy_send2 (send3.hash (), dummy_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 5, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3.hash ())); auto open1 = std::make_shared (send3.hash (), nano::dev::genesis->account (), key2.pub, key2.prv, key2.pub, *system.work.generate (key2.pub)); @@ -1281,9 +1275,9 @@ TEST (confirmation_height, election_winner_details_clearing) nano::block_hash latest (node->latest (nano::dev::genesis_key.pub)); nano::keypair key1; - auto send = std::make_shared (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); - auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); - auto send2 = std::make_shared (send1->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ())); + auto send = std::make_shared (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send->hash ())); + auto send2 = std::make_shared (send1->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ())); { auto transaction = node->store.tx_begin_write (); @@ -1344,7 +1338,7 @@ TEST (confirmation_height, election_winner_details_clearing_node_process_confirm nano::system system (1); auto node = system.nodes.front (); - auto send = std::make_shared (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ())); + auto send = std::make_shared (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ())); // Add to election_winner_details. Use an unrealistic iteration so that it should fall into the else case and do a cleanup node->active.add_election_winner_details (send->hash (), nullptr); nano::election_status election; @@ -1364,7 +1358,6 @@ TEST (confirmation_height, unbounded_block_cache_iteration) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); nano::write_database_queue write_database_queue (false); @@ -1372,8 +1365,8 @@ TEST (confirmation_height, unbounded_block_cache_iteration) nano::work_pool pool (std::numeric_limits::max ()); nano::logging logging; nano::keypair key1; - auto send = std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); - auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send->hash ())); + auto send = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + auto send1 = std::make_shared (send->hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send->hash ())); { auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); @@ -1415,14 +1408,13 @@ TEST (confirmation_height, pruned_source) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; nano::write_database_queue write_database_queue (false); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1, key2; - auto send1 = std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 100, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + auto send1 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 100, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto open1 = std::make_shared (key1.pub, 0, key1.pub, 100, send1->hash (), key1.prv, key1.pub, *pool.generate (key1.pub)); auto send2 = std::make_shared (key1.pub, open1->hash (), key1.pub, 50, key2.pub, key1.prv, key1.pub, *pool.generate (open1->hash ())); auto send3 = std::make_shared (key1.pub, send2->hash (), key1.pub, 25, key2.pub, key1.prv, key1.pub, *pool.generate (send2->hash ())); diff --git a/nano/core_test/confirmation_solicitor.cpp b/nano/core_test/confirmation_solicitor.cpp index 8fd7a5aa75..fe9db15e91 100644 --- a/nano/core_test/confirmation_solicitor.cpp +++ b/nano/core_test/confirmation_solicitor.cpp @@ -19,7 +19,7 @@ TEST (confirmation_solicitor, batches) auto & node2 = *system.add_node (node_flags); auto channel1 (node2.network.udp_channels.create (node1.network.endpoint ())); // Solicitor will only solicit from this representative - nano::representative representative (nano::dev::genesis_key.pub, nano::dev::genesis_amount, channel1); + nano::representative representative (nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, channel1); std::vector representatives{ representative }; nano::confirmation_solicitor solicitor (node2.network, node2.config); solicitor.prepare (representatives); @@ -28,7 +28,7 @@ TEST (confirmation_solicitor, batches) ASSERT_EQ (channel1, representatives.front ().channel); ASSERT_EQ (nano::dev::genesis_key.pub, representatives.front ().account); ASSERT_TIMELY (3s, node2.network.size () == 1); - auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); + auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); send->sideband_set ({}); { nano::lock_guard guard (node2.active.mutex); @@ -63,7 +63,7 @@ TEST (confirmation_solicitor, different_hash) auto & node2 = *system.add_node (node_flags); auto channel1 (node2.network.udp_channels.create (node1.network.endpoint ())); // Solicitor will only solicit from this representative - nano::representative representative (nano::dev::genesis_key.pub, nano::dev::genesis_amount, channel1); + nano::representative representative (nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, channel1); std::vector representatives{ representative }; nano::confirmation_solicitor solicitor (node2.network, node2.config); solicitor.prepare (representatives); @@ -72,7 +72,7 @@ TEST (confirmation_solicitor, different_hash) ASSERT_EQ (channel1, representatives.front ().channel); ASSERT_EQ (nano::dev::genesis_key.pub, representatives.front ().account); ASSERT_TIMELY (3s, node2.network.size () == 1); - auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); + auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); send->sideband_set ({}); auto election (std::make_shared (node2, send, nullptr, nullptr, nano::election_behavior::normal)); // Add a vote for something else, not the winner @@ -108,7 +108,7 @@ TEST (confirmation_solicitor, bypass_max_requests_cap) ASSERT_EQ (max_representatives + 1, representatives.size ()); solicitor.prepare (representatives); ASSERT_TIMELY (3s, node2.network.size () == 1); - auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); + auto send (std::make_shared (nano::dev::genesis->hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); send->sideband_set ({}); auto election (std::make_shared (node2, send, nullptr, nullptr, nano::election_behavior::normal)); // Add a vote for something else, not the winner diff --git a/nano/core_test/conflicts.cpp b/nano/core_test/conflicts.cpp index cfbb4c3b6c..709c1b58ac 100644 --- a/nano/core_test/conflicts.cpp +++ b/nano/core_test/conflicts.cpp @@ -12,9 +12,8 @@ TEST (conflicts, start_stop) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); ASSERT_EQ (0, node1.active.size ()); @@ -30,14 +29,13 @@ TEST (conflicts, add_existing) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); node1.scheduler.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); nano::keypair key2; - auto send2 (std::make_shared (genesis.hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); send2->sideband_set ({}); node1.scheduler.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); node1.scheduler.flush (); @@ -55,9 +53,8 @@ TEST (conflicts, add_two) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); node1.block_confirm (send1); diff --git a/nano/core_test/election.cpp b/nano/core_test/election.cpp index 601e4426ae..386eb469bf 100644 --- a/nano/core_test/election.cpp +++ b/nano/core_test/election.cpp @@ -9,12 +9,10 @@ using namespace std::chrono_literals; TEST (election, construction) { nano::system system (1); - nano::genesis genesis; auto & node = *system.nodes[0]; - genesis.open->sideband_set (nano::block_sideband (nano::dev::genesis->account (), 0, nano::dev::genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); - node.block_confirm (genesis.open); + node.block_confirm (nano::dev::genesis); node.scheduler.flush (); - auto election = node.active.election (genesis.open->qualified_root ()); + auto election = node.active.election (nano::dev::genesis->qualified_root ()); election->transition_active (); } @@ -22,7 +20,7 @@ TEST (election, quorum_minimum_flip_success) { nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); - node_config.online_weight_minimum = nano::dev::genesis_amount; + node_config.online_weight_minimum = nano::dev::constants.genesis_amount; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (node_config); nano::keypair key1; @@ -68,7 +66,7 @@ TEST (election, quorum_minimum_flip_fail) { nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); - node_config.online_weight_minimum = nano::dev::genesis_amount; + node_config.online_weight_minimum = nano::dev::constants.genesis_amount; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (node_config); nano::keypair key1; @@ -114,7 +112,7 @@ TEST (election, quorum_minimum_confirm_success) { nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); - node_config.online_weight_minimum = nano::dev::genesis_amount; + node_config.online_weight_minimum = nano::dev::constants.genesis_amount; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (node_config); nano::keypair key1; @@ -147,7 +145,7 @@ TEST (election, quorum_minimum_confirm_fail) { nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); - node_config.online_weight_minimum = nano::dev::genesis_amount; + node_config.online_weight_minimum = nano::dev::constants.genesis_amount; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (node_config); nano::keypair key1; @@ -202,7 +200,7 @@ TEST (election, quorum_minimum_update_weight_before_quorum_checks) .account (key1.pub) .previous (0) .representative (key1.pub) - .balance (nano::dev::genesis_amount - amount) + .balance (nano::dev::constants.genesis_amount - amount) .link (send1->hash ()) .work (0) .sign (key1.prv, key1.pub) diff --git a/nano/core_test/election_scheduler.cpp b/nano/core_test/election_scheduler.cpp index 10e2c94be8..2769c71fbb 100644 --- a/nano/core_test/election_scheduler.cpp +++ b/nano/core_test/election_scheduler.cpp @@ -21,7 +21,7 @@ TEST (election_scheduler, activate_one_timely) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 ())) @@ -39,7 +39,7 @@ TEST (election_scheduler, activate_one_flush) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 ())) @@ -65,7 +65,7 @@ TEST (election_scheduler, no_vacancy) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -91,7 +91,7 @@ TEST (election_scheduler, no_vacancy) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) .link (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) .build_shared (); @@ -138,7 +138,7 @@ TEST (election_scheduler, flush_vacancy) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); diff --git a/nano/core_test/frontiers_confirmation.cpp b/nano/core_test/frontiers_confirmation.cpp index 8f5a39e9a5..1773b8a146 100644 --- a/nano/core_test/frontiers_confirmation.cpp +++ b/nano/core_test/frontiers_confirmation.cpp @@ -210,7 +210,6 @@ TEST (frontiers_confirmation, expired_optimistic_elections_removal) TEST (frontiers_confirmation, mode) { - nano::genesis genesis; nano::keypair key; nano::node_flags node_flags; // Always mode @@ -219,7 +218,7 @@ TEST (frontiers_confirmation, mode) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::always; auto node = system.add_node (node_config, node_flags); - nano::state_block send (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (genesis.hash ())); + nano::state_block send (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (nano::dev::genesis->hash ())); { auto transaction = node->store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); @@ -232,7 +231,7 @@ TEST (frontiers_confirmation, mode) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::automatic; auto node = system.add_node (node_config, node_flags); - nano::state_block send (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (genesis.hash ())); + nano::state_block send (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (nano::dev::genesis->hash ())); { auto transaction = node->store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); @@ -245,7 +244,7 @@ TEST (frontiers_confirmation, mode) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto node = system.add_node (node_config, node_flags); - nano::state_block send (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (genesis.hash ())); + nano::state_block send (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (nano::dev::genesis->hash ())); { auto transaction = node->store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); diff --git a/nano/core_test/gap_cache.cpp b/nano/core_test/gap_cache.cpp index 270e8203e9..88b77da5ea 100644 --- a/nano/core_test/gap_cache.cpp +++ b/nano/core_test/gap_cache.cpp @@ -67,10 +67,10 @@ TEST (gap_cache, gap_bootstrap) auto & node2 (*system.nodes[1]); nano::block_hash latest (node1.latest (nano::dev::genesis_key.pub)); nano::keypair key; - auto send (std::make_shared (latest, key.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest))); + auto send (std::make_shared (latest, key.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest))); node1.process (*send); - ASSERT_EQ (nano::dev::genesis_amount - 100, node1.balance (nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, node2.balance (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, node1.balance (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, node2.balance (nano::dev::genesis->account ())); // Confirm send block, allowing voting on the upcoming block node1.block_confirm (send); auto election = node1.active.election (send->qualified_root ()); @@ -81,9 +81,9 @@ TEST (gap_cache, gap_bootstrap) system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto latest_block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key.pub, 100)); ASSERT_NE (nullptr, latest_block); - ASSERT_EQ (nano::dev::genesis_amount - 200, node1.balance (nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, node2.balance (nano::dev::genesis->account ())); - ASSERT_TIMELY (10s, node2.balance (nano::dev::genesis->account ()) == nano::dev::genesis_amount - 200); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, node1.balance (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, node2.balance (nano::dev::genesis->account ())); + ASSERT_TIMELY (10s, node2.balance (nano::dev::genesis->account ()) == nano::dev::constants.genesis_amount - 200); } TEST (gap_cache, two_dependencies) @@ -91,8 +91,7 @@ TEST (gap_cache, two_dependencies) nano::system system (1); auto & node1 (*system.nodes[0]); nano::keypair key; - nano::genesis genesis; - auto send1 (std::make_shared (genesis.hash (), key.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); auto send2 (std::make_shared (send1->hash (), key.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); auto open (std::make_shared (send1->hash (), key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub))); ASSERT_EQ (0, node1.gap_cache.size ()); diff --git a/nano/core_test/ledger.cpp b/nano/core_test/ledger.cpp index f80296aa0d..7a03c408e1 100644 --- a/nano/core_test/ledger.cpp +++ b/nano/core_test/ledger.cpp @@ -46,13 +46,12 @@ TEST (ledger, genesis_balance) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); auto balance (ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, balance); + ASSERT_EQ (nano::dev::constants.genesis_amount, balance); auto amount (ledger.amount (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, amount); + ASSERT_EQ (nano::dev::constants.genesis_amount, amount); nano::account_info info; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis->account (), info)); ASSERT_EQ (1, ledger.cache.account_count); @@ -63,7 +62,7 @@ TEST (ledger, genesis_balance) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (store->confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (confirmation_height_info.height, 1); - ASSERT_EQ (confirmation_height_info.frontier, genesis.hash ()); + ASSERT_EQ (confirmation_height_info.frontier, nano::dev::genesis->hash ()); } TEST (ledger, process_modifies_sideband) @@ -73,10 +72,9 @@ TEST (ledger, process_modifies_sideband) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; store->initialize (store->tx_begin_write (), ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (store->tx_begin_write (), send1).code); ASSERT_EQ (send1.sideband ().timestamp, store->block.get (store->tx_begin_read (), send1.hash ())->sideband ().timestamp); } @@ -90,7 +88,6 @@ TEST (ledger, process_send) nano::stat stats; nano::ledger ledger (*store, stats); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::account_info info1; @@ -104,13 +101,13 @@ TEST (ledger, process_send) auto return1 (ledger.process (transaction, send)); ASSERT_EQ (nano::dev::genesis_key.pub, send.sideband ().account); ASSERT_EQ (2, send.sideband ().height); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.amount (transaction, hash1)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.amount (transaction, hash1)); ASSERT_TRUE (store->frontier.get (transaction, info1.head).is_zero ()); ASSERT_EQ (nano::dev::genesis_key.pub, store->frontier.get (transaction, hash1)); ASSERT_EQ (nano::process_result::progress, return1.code); ASSERT_EQ (nano::dev::genesis_key.pub, store->block.account_calculated (send)); ASSERT_EQ (50, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.account_pending (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.account_pending (transaction, key2.pub)); nano::account_info info2; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info2)); ASSERT_EQ (2, info2.block_count); @@ -126,17 +123,17 @@ TEST (ledger, process_send) auto return2 (ledger.process (transaction, open)); ASSERT_EQ (nano::process_result::progress, return2.code); ASSERT_EQ (key2.pub, open.sideband ().account); - ASSERT_EQ (nano::dev::genesis_amount - 50, open.sideband ().balance.number ()); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, open.sideband ().balance.number ()); ASSERT_EQ (1, open.sideband ().height); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.amount (transaction, hash2)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.amount (transaction, hash2)); ASSERT_EQ (nano::process_result::progress, return2.code); ASSERT_EQ (key2.pub, store->block.account_calculated (open)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.amount (transaction, hash2)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.amount (transaction, hash2)); ASSERT_EQ (key2.pub, store->frontier.get (transaction, hash2)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); ASSERT_EQ (0, ledger.account_pending (transaction, key2.pub)); ASSERT_EQ (50, ledger.weight (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (key2.pub)); nano::account_info info3; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info3)); auto latest2 (store->block.get (transaction, info3.head)); @@ -158,9 +155,9 @@ TEST (ledger, process_send) nano::pending_info pending1; ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending1)); ASSERT_EQ (nano::dev::genesis_key.pub, pending1.source); - ASSERT_EQ (nano::dev::genesis_amount - 50, pending1.amount.number ()); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, pending1.amount.number ()); ASSERT_EQ (0, ledger.account_balance (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.account_pending (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.account_pending (transaction, key2.pub)); ASSERT_EQ (50, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); ASSERT_EQ (50, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key2.pub)); @@ -168,7 +165,7 @@ TEST (ledger, process_send) ASSERT_FALSE (ledger.store.account.get (transaction, nano::dev::genesis_key.pub, info6)); ASSERT_EQ (hash1, info6.head); ASSERT_FALSE (ledger.rollback (transaction, info6.head)); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (nano::dev::genesis_key.pub, store->frontier.get (transaction, info1.head)); ASSERT_TRUE (store->frontier.get (transaction, hash1).is_zero ()); nano::account_info info7; @@ -177,7 +174,7 @@ TEST (ledger, process_send) ASSERT_EQ (info1.head, info7.head); nano::pending_info pending2; ASSERT_TRUE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash1), pending2)); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.account_pending (transaction, key2.pub)); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); } @@ -189,7 +186,6 @@ TEST (ledger, process_receive) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -206,10 +202,10 @@ TEST (ledger, process_receive) ASSERT_EQ (nano::process_result::progress, return1.code); ASSERT_EQ (key2.pub, store->block.account_calculated (open)); ASSERT_EQ (key2.pub, open.sideband ().account); - ASSERT_EQ (nano::dev::genesis_amount - 50, open.sideband ().balance.number ()); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, open.sideband ().balance.number ()); ASSERT_EQ (1, open.sideband ().height); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.amount (transaction, hash2)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.amount (transaction, hash2)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (key3.pub)); nano::send_block send2 (hash1, key2.pub, 25, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (hash1)); nano::block_hash hash3 (send2.hash ()); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); @@ -218,7 +214,7 @@ TEST (ledger, process_receive) ASSERT_EQ (key2.pub, store->frontier.get (transaction, hash2)); auto return2 (ledger.process (transaction, receive)); ASSERT_EQ (key2.pub, receive.sideband ().account); - ASSERT_EQ (nano::dev::genesis_amount - 25, receive.sideband ().balance.number ()); + ASSERT_EQ (nano::dev::constants.genesis_amount - 25, receive.sideband ().balance.number ()); ASSERT_EQ (2, receive.sideband ().height); ASSERT_EQ (25, ledger.amount (transaction, hash4)); ASSERT_TRUE (store->frontier.get (transaction, hash2).is_zero ()); @@ -228,16 +224,16 @@ TEST (ledger, process_receive) ASSERT_EQ (hash4, ledger.latest (transaction, key2.pub)); ASSERT_EQ (25, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.account_pending (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 25, ledger.account_balance (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 25, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 25, ledger.account_balance (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 25, ledger.weight (key3.pub)); ASSERT_FALSE (ledger.rollback (transaction, hash4)); ASSERT_TRUE (store->block.successor (transaction, hash2).is_zero ()); ASSERT_EQ (key2.pub, store->frontier.get (transaction, hash2)); ASSERT_TRUE (store->frontier.get (transaction, hash4).is_zero ()); ASSERT_EQ (25, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); ASSERT_EQ (25, ledger.account_pending (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (key3.pub)); ASSERT_EQ (hash2, ledger.latest (transaction, key2.pub)); nano::pending_info pending1; ASSERT_FALSE (ledger.store.pending.get (transaction, nano::pending_key (key2.pub, hash3), pending1)); @@ -253,7 +249,6 @@ TEST (ledger, rollback_receiver) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -269,14 +264,14 @@ TEST (ledger, rollback_receiver) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code); ASSERT_EQ (hash2, ledger.latest (transaction, key2.pub)); ASSERT_EQ (50, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.account_balance (transaction, key2.pub)); ASSERT_EQ (50, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (key3.pub)); ASSERT_FALSE (ledger.rollback (transaction, hash1)); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.account_balance (transaction, key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); nano::account_info info2; @@ -293,12 +288,11 @@ TEST (ledger, rollback_representation) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key5; - nano::change_block change1 (genesis.hash (), key5.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::change_block change1 (nano::dev::genesis->hash (), key5.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change1).code); nano::keypair key3; nano::change_block change2 (change1.hash (), key3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); @@ -314,7 +308,7 @@ TEST (ledger, rollback_representation) nano::receive_block receive1 (open.hash (), send2.hash (), key2.prv, key2.pub, *pool.generate (open.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_EQ (1, ledger.weight (key3.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 1, ledger.weight (key4.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 1, ledger.weight (key4.pub)); nano::account_info info1; ASSERT_FALSE (store->account.get (transaction, key2.pub, info1)); ASSERT_EQ (key4.pub, info1.representative); @@ -323,12 +317,12 @@ TEST (ledger, rollback_representation) ASSERT_FALSE (store->account.get (transaction, key2.pub, info2)); ASSERT_EQ (key4.pub, info2.representative); ASSERT_EQ (0, ledger.weight (key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (key4.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (key4.pub)); ASSERT_FALSE (ledger.rollback (transaction, open.hash ())); ASSERT_EQ (1, ledger.weight (key3.pub)); ASSERT_EQ (0, ledger.weight (key4.pub)); ledger.rollback (transaction, send1.hash ()); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (key3.pub)); nano::account_info info3; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info3)); ASSERT_EQ (key3.pub, info3.representative); @@ -336,7 +330,7 @@ TEST (ledger, rollback_representation) nano::account_info info4; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info4)); ASSERT_EQ (key5.pub, info4.representative); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (key5.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (key5.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); } @@ -347,11 +341,10 @@ TEST (ledger, receive_rollback) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send (genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send (nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); nano::receive_block receive (send.hash (), send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code); @@ -365,7 +358,6 @@ TEST (ledger, process_duplicate) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -388,12 +380,11 @@ TEST (ledger, representative_genesis) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub)); ASSERT_FALSE (latest.is_zero ()); - ASSERT_EQ (genesis.open->hash (), ledger.representative (transaction, latest)); + ASSERT_EQ (nano::dev::genesis->hash (), ledger.representative (transaction, latest)); } TEST (ledger, weight) @@ -403,10 +394,9 @@ TEST (ledger, weight) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); } TEST (ledger, representative_change) @@ -417,11 +407,10 @@ TEST (ledger, representative_change) nano::stat stats; nano::ledger ledger (*store, stats); nano::keypair key2; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key2.pub)); nano::account_info info1; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1)); @@ -434,7 +423,7 @@ TEST (ledger, representative_change) ASSERT_EQ (nano::process_result::progress, return1.code); ASSERT_EQ (nano::dev::genesis_key.pub, store->block.account_calculated (block)); ASSERT_EQ (0, ledger.weight (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (key2.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (key2.pub)); nano::account_info info2; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info2)); ASSERT_EQ (block.hash (), info2.head); @@ -444,7 +433,7 @@ TEST (ledger, representative_change) nano::account_info info3; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info3)); ASSERT_EQ (info1.head, info3.head); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key2.pub)); } @@ -457,7 +446,6 @@ TEST (ledger, send_fork) nano::ledger ledger (*store, stats); nano::keypair key2; nano::keypair key3; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -478,7 +466,6 @@ TEST (ledger, receive_fork) nano::ledger ledger (*store, stats); nano::keypair key2; nano::keypair key3; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -505,7 +492,6 @@ TEST (ledger, open_fork) nano::ledger ledger (*store, stats); nano::keypair key2; nano::keypair key3; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -538,42 +524,41 @@ TEST (ledger, representation) nano::stat stats; nano::ledger ledger (*store, stats); auto & rep_weights = ledger.cache.rep_weights; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - ASSERT_EQ (nano::dev::genesis_amount, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, rep_weights.representation_get (nano::dev::genesis_key.pub)); nano::keypair key2; - nano::send_block block1 (genesis.hash (), key2.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key2.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); - ASSERT_EQ (nano::dev::genesis_amount - 100, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, rep_weights.representation_get (nano::dev::genesis_key.pub)); nano::keypair key3; nano::open_block block2 (block1.hash (), key3.pub, key2.pub, key2.prv, key2.pub, *pool.generate (key2.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code); - ASSERT_EQ (nano::dev::genesis_amount - 100, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (100, rep_weights.representation_get (key3.pub)); - nano::send_block block3 (block1.hash (), key2.pub, nano::dev::genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); + nano::send_block block3 (block1.hash (), key2.pub, nano::dev::constants.genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block3).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (100, rep_weights.representation_get (key3.pub)); nano::receive_block block4 (block2.hash (), block3.hash (), key2.prv, key2.pub, *pool.generate (block2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block4).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (200, rep_weights.representation_get (key3.pub)); nano::keypair key4; nano::change_block block5 (block4.hash (), key4.pub, key2.prv, key2.pub, *pool.generate (block4.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block5).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (0, rep_weights.representation_get (key3.pub)); ASSERT_EQ (200, rep_weights.representation_get (key4.pub)); nano::keypair key5; nano::send_block block6 (block5.hash (), key5.pub, 100, key2.prv, key2.pub, *pool.generate (block5.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block6).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (0, rep_weights.representation_get (key3.pub)); ASSERT_EQ (100, rep_weights.representation_get (key4.pub)); @@ -581,7 +566,7 @@ TEST (ledger, representation) nano::keypair key6; nano::open_block block7 (block6.hash (), key6.pub, key5.pub, key5.prv, key5.pub, *pool.generate (key5.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block7).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (0, rep_weights.representation_get (key3.pub)); ASSERT_EQ (100, rep_weights.representation_get (key4.pub)); @@ -589,7 +574,7 @@ TEST (ledger, representation) ASSERT_EQ (100, rep_weights.representation_get (key6.pub)); nano::send_block block8 (block6.hash (), key5.pub, 0, key2.prv, key2.pub, *pool.generate (block6.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block8).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (0, rep_weights.representation_get (key3.pub)); ASSERT_EQ (0, rep_weights.representation_get (key4.pub)); @@ -597,7 +582,7 @@ TEST (ledger, representation) ASSERT_EQ (100, rep_weights.representation_get (key6.pub)); nano::receive_block block9 (block7.hash (), block8.hash (), key5.prv, key5.pub, *pool.generate (block7.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block9).code); - ASSERT_EQ (nano::dev::genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 200, rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, rep_weights.representation_get (key2.pub)); ASSERT_EQ (0, rep_weights.representation_get (key3.pub)); ASSERT_EQ (0, rep_weights.representation_get (key4.pub)); @@ -612,12 +597,11 @@ TEST (ledger, double_open) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key2; - nano::send_block send1 (genesis.hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::open_block open1 (send1.hash (), key2.pub, key2.pub, key2.prv, key2.pub, *pool.generate (key2.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -632,12 +616,11 @@ TEST (ledger, double_receive) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key2; - nano::send_block send1 (genesis.hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::open_block open1 (send1.hash (), key2.pub, key2.pub, key2.prv, key2.pub, *pool.generate (key2.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -651,9 +634,8 @@ TEST (votes, check_signature) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.online_weight_minimum = std::numeric_limits::max (); auto & node1 = *system.add_node (node_config); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); { auto transaction (node1.store.tx_begin_write ()); @@ -675,9 +657,8 @@ TEST (votes, add_one) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *send1).code); @@ -697,16 +678,15 @@ TEST (votes, add_one) nano::lock_guard guard (node1.active.mutex); auto winner (*election1->tally ().begin ()); ASSERT_EQ (*send1, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); } TEST (votes, add_two) { nano::system system{ 1 }; auto & node1 = *system.nodes[0]; - nano::genesis genesis; nano::keypair key1; - auto send1 = std::make_shared (genesis.hash (), key1.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + auto send1 = std::make_shared (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); node1.work_generate_blocking (*send1); auto transaction = node1.store.tx_begin_write (); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *send1).code); @@ -714,7 +694,7 @@ TEST (votes, add_two) node1.scheduler.flush (); auto election1 = node1.active.election (send1->qualified_root ()); nano::keypair key2; - auto send2 = std::make_shared (genesis.hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + auto send2 = std::make_shared (nano::dev::genesis->hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); auto vote2 = std::make_shared (key2.pub, key2.prv, 1, send2); ASSERT_EQ (nano::vote_code::vote, node1.active.vote (vote2)); auto vote1 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1, send1); @@ -735,7 +715,7 @@ TEST (votes, add_existing) { nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); - node_config.online_weight_minimum = nano::dev::genesis_amount; + node_config.online_weight_minimum = nano::dev::constants.genesis_amount; node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 = *system.add_node (node_config); nano::keypair key1; @@ -744,7 +724,7 @@ TEST (votes, add_existing) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) // No representative, blocks can't confirm - .balance (nano::dev::genesis_amount / 2 - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount / 2 - nano::Gxrb_ratio) .link (key1.pub) .work (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) @@ -764,7 +744,7 @@ TEST (votes, add_existing) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) // No representative, blocks can't confirm - .balance (nano::dev::genesis_amount / 2 - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount / 2 - nano::Gxrb_ratio) .link (key2.pub) .work (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) @@ -796,9 +776,8 @@ TEST (votes, add_old) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *send1).code); @@ -809,7 +788,7 @@ TEST (votes, add_old) auto channel (std::make_shared (node1)); node1.vote_processor.vote_blocking (vote1, channel); nano::keypair key2; - auto send2 (std::make_shared (genesis.hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send2); auto vote2 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1, send2)); { @@ -830,9 +809,8 @@ TEST (votes, add_old_different_account) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto send2 (std::make_shared (send1->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send2); @@ -871,9 +849,8 @@ TEST (votes, add_cooldown) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *send1).code); @@ -884,7 +861,7 @@ TEST (votes, add_cooldown) auto channel (std::make_shared (node1)); node1.vote_processor.vote_blocking (vote1, channel); nano::keypair key2; - auto send2 (std::make_shared (genesis.hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->hash (), key2.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send2); auto vote2 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 2, send2)); node1.vote_processor.vote_blocking (vote2, channel); @@ -901,13 +878,12 @@ TEST (ledger, successor) nano::system system (1); auto & node1 (*system.nodes[0]); nano::keypair key1; - nano::genesis genesis; - nano::send_block send1 (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + nano::send_block send1 (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); node1.work_generate_blocking (send1); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, send1).code); - ASSERT_EQ (send1, *node1.ledger.successor (transaction, nano::qualified_root (nano::root (0), genesis.hash ()))); - ASSERT_EQ (*genesis.open, *node1.ledger.successor (transaction, genesis.open->qualified_root ())); + ASSERT_EQ (send1, *node1.ledger.successor (transaction, nano::qualified_root (nano::root (0), nano::dev::genesis->hash ()))); + ASSERT_EQ (*nano::dev::genesis, *node1.ledger.successor (transaction, nano::dev::genesis->qualified_root ())); ASSERT_EQ (nullptr, node1.ledger.successor (transaction, nano::qualified_root (0))); } @@ -918,12 +894,11 @@ TEST (ledger, fail_change_old) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::change_block block (genesis.hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::change_block block (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block)); ASSERT_EQ (nano::process_result::progress, result1.code); auto result2 (ledger.process (transaction, block)); @@ -937,7 +912,6 @@ TEST (ledger, fail_change_gap_previous) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -954,12 +928,11 @@ TEST (ledger, fail_change_bad_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::change_block block (genesis.hash (), key1.pub, nano::keypair ().prv, 0, *pool.generate (genesis.hash ())); + nano::change_block block (nano::dev::genesis->hash (), key1.pub, nano::keypair ().prv, 0, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block)); ASSERT_EQ (nano::process_result::bad_signature, result1.code); } @@ -971,16 +944,15 @@ TEST (ledger, fail_change_fork) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::change_block block1 (genesis.hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::change_block block1 (nano::dev::genesis->hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::keypair key2; - nano::change_block block2 (genesis.hash (), key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::change_block block2 (nano::dev::genesis->hash (), key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result2 (ledger.process (transaction, block2)); ASSERT_EQ (nano::process_result::fork, result2.code); } @@ -992,12 +964,11 @@ TEST (ledger, fail_send_old) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block)); ASSERT_EQ (nano::process_result::progress, result1.code); auto result2 (ledger.process (transaction, block)); @@ -1011,7 +982,6 @@ TEST (ledger, fail_send_gap_previous) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -1028,12 +998,11 @@ TEST (ledger, fail_send_bad_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block (genesis.hash (), key1.pub, 1, nano::keypair ().prv, 0, *pool.generate (genesis.hash ())); + nano::send_block block (nano::dev::genesis->hash (), key1.pub, 1, nano::keypair ().prv, 0, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block)); ASSERT_EQ (nano::process_result::bad_signature, result1.code); } @@ -1045,12 +1014,11 @@ TEST (ledger, fail_send_negative_spend) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::keypair key2; nano::send_block block2 (block1.hash (), key2.pub, 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1064,15 +1032,14 @@ TEST (ledger, fail_send_fork) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::keypair key2; - nano::send_block block2 (genesis.hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block2 (nano::dev::genesis->hash (), key2.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, block2).code); } @@ -1083,12 +1050,11 @@ TEST (ledger, fail_open_old) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::open_block block2 (block1.hash (), 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code); @@ -1102,7 +1068,6 @@ TEST (ledger, fail_open_gap_source) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -1119,12 +1084,11 @@ TEST (ledger, fail_open_bad_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::open_block block2 (block1.hash (), 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); block2.signature.clear (); @@ -1138,12 +1102,11 @@ TEST (ledger, fail_open_fork_previous) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code); @@ -1161,12 +1124,11 @@ TEST (ledger, fail_open_account_mismatch) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::keypair badkey; nano::open_block block2 (block1.hash (), 1, badkey.pub, badkey.prv, badkey.pub, *pool.generate (badkey.pub)); @@ -1181,12 +1143,11 @@ TEST (ledger, fail_receive_old) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block1).code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, block2).code); @@ -1204,12 +1165,11 @@ TEST (ledger, fail_receive_gap_source) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1230,12 +1190,11 @@ TEST (ledger, fail_receive_overreceive) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::open_block block2 (block1.hash (), 1, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); @@ -1253,12 +1212,11 @@ TEST (ledger, fail_receive_bad_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1279,12 +1237,11 @@ TEST (ledger, fail_receive_gap_previous_opened) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1305,12 +1262,11 @@ TEST (ledger, fail_receive_gap_previous_unopened) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1328,12 +1284,11 @@ TEST (ledger, fail_receive_fork_previous) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1358,12 +1313,11 @@ TEST (ledger, fail_receive_received_source) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; - nano::send_block block1 (genesis.hash (), key1.pub, 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), key1.pub, 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); auto result1 (ledger.process (transaction, block1)); ASSERT_EQ (nano::process_result::progress, result1.code); nano::send_block block2 (block1.hash (), key1.pub, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); @@ -1407,7 +1361,6 @@ TEST (ledger, latest_root) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -1428,12 +1381,10 @@ TEST (ledger, change_representative_move_representation) nano::ledger ledger (*store, stats); nano::keypair key1; auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - auto hash1 (genesis.hash ()); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); - nano::send_block send (hash1, key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (hash1)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis_key.pub)); + nano::send_block send (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); ASSERT_EQ (0, ledger.weight (nano::dev::genesis_key.pub)); nano::keypair key2; @@ -1442,7 +1393,7 @@ TEST (ledger, change_representative_move_representation) nano::keypair key3; nano::open_block open (send.hash (), key3.pub, key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (key3.pub)); } TEST (ledger, send_open_receive_rollback) @@ -1453,16 +1404,15 @@ TEST (ledger, send_open_receive_rollback) nano::stat stats; nano::ledger ledger (*store, stats); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::account_info info1; ASSERT_FALSE (store->account.get (transaction, nano::dev::genesis_key.pub, info1)); nano::keypair key1; - nano::send_block send1 (info1.head, key1.pub, nano::dev::genesis_amount - 50, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (info1.head)); + nano::send_block send1 (info1.head, key1.pub, nano::dev::constants.genesis_amount - 50, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (info1.head)); auto return1 (ledger.process (transaction, send1)); ASSERT_EQ (nano::process_result::progress, return1.code); - nano::send_block send2 (send1.hash (), key1.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::send_block send2 (send1.hash (), key1.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); auto return2 (ledger.process (transaction, send2)); ASSERT_EQ (nano::process_result::progress, return2.code); nano::keypair key2; @@ -1474,34 +1424,34 @@ TEST (ledger, send_open_receive_rollback) ASSERT_EQ (nano::process_result::progress, return5.code); nano::keypair key3; ASSERT_EQ (100, ledger.weight (key2.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 100, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); nano::change_block change1 (send2.hash (), key3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); auto return6 (ledger.process (transaction, change1)); ASSERT_EQ (nano::process_result::progress, return6.code); ASSERT_EQ (100, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 100, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, ledger.weight (key3.pub)); ASSERT_FALSE (ledger.rollback (transaction, receive.hash ())); ASSERT_EQ (50, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 100, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, ledger.weight (key3.pub)); ASSERT_FALSE (ledger.rollback (transaction, open.hash ())); ASSERT_EQ (0, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 100, ledger.weight (key3.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, ledger.weight (key3.pub)); ASSERT_FALSE (ledger.rollback (transaction, change1.hash ())); ASSERT_EQ (0, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 100, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_FALSE (ledger.rollback (transaction, send2.hash ())); ASSERT_EQ (0, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 50, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 50, ledger.weight (nano::dev::genesis_key.pub)); ASSERT_FALSE (ledger.rollback (transaction, send1.hash ())); ASSERT_EQ (0, ledger.weight (key2.pub)); ASSERT_EQ (0, ledger.weight (key3.pub)); - ASSERT_EQ (nano::dev::genesis_amount - 0, ledger.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - 0, ledger.weight (nano::dev::genesis_key.pub)); } TEST (ledger, bootstrap_rep_weight) @@ -1513,7 +1463,6 @@ TEST (ledger, bootstrap_rep_weight) nano::ledger ledger (*store, stats); nano::account_info info1; nano::keypair key2; - nano::genesis genesis; nano::work_pool pool (std::numeric_limits::max ()); { auto transaction (store->tx_begin_write ()); @@ -1548,14 +1497,13 @@ TEST (ledger, block_destination_source) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair dest; - nano::uint128_t balance (nano::dev::genesis_amount); + nano::uint128_t balance (nano::dev::constants.genesis_amount); balance -= nano::Gxrb_ratio; - nano::send_block block1 (genesis.hash (), dest.pub, balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block block1 (nano::dev::genesis->hash (), dest.pub, balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); balance -= nano::Gxrb_ratio; nano::send_block block2 (block1.hash (), nano::dev::genesis->account (), balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (block1.hash ())); balance += nano::Gxrb_ratio; @@ -1594,11 +1542,10 @@ TEST (ledger, state_account) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_EQ (nano::dev::genesis->account (), ledger.account (transaction, send1.hash ())); } @@ -1610,33 +1557,32 @@ TEST (ledger, state_send_receive) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); ASSERT_EQ (2, send2->sideband ().height); ASSERT_TRUE (send2->sideband ().details.is_send); ASSERT_FALSE (send2->sideband ().details.is_receive); ASSERT_FALSE (send2->sideband ().details.is_epoch); - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store->block.exists (transaction, receive1.hash ())); auto receive2 (store->block.get (transaction, receive1.hash ())); ASSERT_NE (nullptr, receive2); ASSERT_EQ (receive1, *receive2); - ASSERT_EQ (nano::dev::genesis_amount, ledger.balance (transaction, receive1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.balance (transaction, receive1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); ASSERT_EQ (3, receive2->sideband ().height); @@ -1652,28 +1598,27 @@ TEST (ledger, state_receive) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store->block.exists (transaction, receive1.hash ())); auto receive2 (store->block.get (transaction, receive1.hash ())); ASSERT_NE (nullptr, receive2); ASSERT_EQ (receive1, *receive2); - ASSERT_EQ (nano::dev::genesis_amount, ledger.balance (transaction, receive1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.balance (transaction, receive1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (3, receive2->sideband ().height); ASSERT_FALSE (receive2->sideband ().details.is_send); ASSERT_TRUE (receive2->sideband ().details.is_receive); @@ -1687,21 +1632,20 @@ TEST (ledger, state_rep_change) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair rep; - nano::state_block change1 (nano::dev::genesis->account (), genesis.hash (), rep.pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block change1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change1).code); ASSERT_TRUE (store->block.exists (transaction, change1.hash ())); auto change2 (store->block.get (transaction, change1.hash ())); ASSERT_NE (nullptr, change2); ASSERT_EQ (change1, *change2); - ASSERT_EQ (nano::dev::genesis_amount, ledger.balance (transaction, change1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.balance (transaction, change1.hash ())); ASSERT_EQ (0, ledger.amount (transaction, change1.hash ())); ASSERT_EQ (0, ledger.weight (nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (rep.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (rep.pub)); ASSERT_EQ (2, change2->sideband ().height); ASSERT_FALSE (change2->sideband ().details.is_send); ASSERT_FALSE (change2->sideband ().details.is_receive); @@ -1715,20 +1659,19 @@ TEST (ledger, state_open) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (destination.pub, send1.hash ()))); nano::state_block open1 (destination.pub, 0, nano::dev::genesis->account (), nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -1739,7 +1682,7 @@ TEST (ledger, state_open) ASSERT_EQ (open1, *open2); ASSERT_EQ (nano::Gxrb_ratio, ledger.balance (transaction, open1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, open1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (ledger.cache.account_count, store->account.count (transaction)); ASSERT_EQ (1, open2->sideband ().height); ASSERT_FALSE (open2->sideband ().details.is_send); @@ -1755,13 +1698,12 @@ TEST (ledger, send_after_state_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::send_block send2 (send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - (2 * nano::Gxrb_ratio), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::send_block send2 (send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - (2 * nano::Gxrb_ratio), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, send2).code); } @@ -1773,11 +1715,10 @@ TEST (ledger, receive_after_state_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::receive_block receive1 (send1.hash (), send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, receive1).code); @@ -1791,11 +1732,10 @@ TEST (ledger, change_after_state_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::keypair rep; nano::change_block change1 (send1.hash (), rep.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); @@ -1809,20 +1749,19 @@ TEST (ledger, state_unreceivable_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::gap_source, ledger.process (transaction, receive1).code); } @@ -1833,20 +1772,19 @@ TEST (ledger, state_receive_bad_amount_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::balance_mismatch, ledger.process (transaction, receive1).code); } @@ -1857,14 +1795,13 @@ TEST (ledger, state_no_link_amount_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::keypair rep; - nano::state_block change1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block change1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::balance_mismatch, ledger.process (transaction, change1).code); } @@ -1875,19 +1812,18 @@ TEST (ledger, state_receive_wrong_account_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); nano::keypair key; nano::state_block receive1 (key.pub, 0, nano::dev::genesis->account (), nano::Gxrb_ratio, send1.hash (), key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::unreceivable, ledger.process (transaction, receive1).code); @@ -1900,12 +1836,11 @@ TEST (ledger, state_open_state_fork) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block open1 (destination.pub, 0, nano::dev::genesis->account (), nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -1921,12 +1856,11 @@ TEST (ledger, state_state_open_fork) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::open_block open1 (send1.hash (), nano::dev::genesis->account (), destination.pub, destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -1943,12 +1877,11 @@ TEST (ledger, state_open_previous_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block open1 (destination.pub, 1, nano::dev::genesis->account (), nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (1)); ASSERT_EQ (nano::process_result::gap_previous, ledger.process (transaction, open1).code); @@ -1961,12 +1894,11 @@ TEST (ledger, state_open_source_fail) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block open1 (destination.pub, 0, nano::dev::genesis->account (), 0, 0, destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::gap_source, ledger.process (transaction, open1).code); @@ -1979,21 +1911,20 @@ TEST (ledger, state_send_change) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair rep; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), rep.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); ASSERT_EQ (0, ledger.weight (nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (rep.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (rep.pub)); ASSERT_EQ (2, send2->sideband ().height); ASSERT_TRUE (send2->sideband ().details.is_send); ASSERT_FALSE (send2->sideband ().details.is_receive); @@ -2007,30 +1938,29 @@ TEST (ledger, state_receive_change) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.balance (transaction, send1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); nano::keypair rep; - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::constants.genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store->block.exists (transaction, receive1.hash ())); auto receive2 (store->block.get (transaction, receive1.hash ())); ASSERT_NE (nullptr, receive2); ASSERT_EQ (receive1, *receive2); - ASSERT_EQ (nano::dev::genesis_amount, ledger.balance (transaction, receive1.hash ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.balance (transaction, receive1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ())); ASSERT_EQ (0, ledger.weight (nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (rep.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (rep.pub)); ASSERT_EQ (3, receive2->sideband ().height); ASSERT_FALSE (receive2->sideband ().details.is_send); ASSERT_TRUE (receive2->sideband ().details.is_receive); @@ -2044,18 +1974,17 @@ TEST (ledger, state_open_old) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::open_block open1 (send1.hash (), nano::dev::genesis->account (), destination.pub, destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); ASSERT_EQ (nano::Gxrb_ratio, ledger.balance (transaction, open1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, open1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); } TEST (ledger, state_receive_old) @@ -2065,14 +1994,13 @@ TEST (ledger, state_receive_old) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - (2 * nano::Gxrb_ratio), destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - (2 * nano::Gxrb_ratio), destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); nano::open_block open1 (send1.hash (), nano::dev::genesis->account (), destination.pub, destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -2080,7 +2008,7 @@ TEST (ledger, state_receive_old) ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_EQ (2 * nano::Gxrb_ratio, ledger.balance (transaction, receive1.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); } TEST (ledger, state_rollback_send) @@ -2090,28 +2018,27 @@ TEST (ledger, state_rollback_send) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send2 (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send2); ASSERT_EQ (send1, *send2); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); nano::pending_info info; ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()), info)); ASSERT_EQ (nano::dev::genesis->account (), info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_FALSE (ledger.rollback (transaction, send1.hash ())); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); - ASSERT_TRUE (store->block.successor (transaction, genesis.hash ()).is_zero ()); + ASSERT_TRUE (store->block.successor (transaction, nano::dev::genesis->hash ()).is_zero ()); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); } @@ -2122,13 +2049,12 @@ TEST (ledger, state_rollback_receive) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), receive1.hash ()))); ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ())); @@ -2137,8 +2063,8 @@ TEST (ledger, state_rollback_receive) ASSERT_EQ (nano::dev::genesis->account (), info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_FALSE (store->block.exists (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); } @@ -2149,12 +2075,11 @@ TEST (ledger, state_rollback_received_send) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block receive1 (key.pub, 0, key.pub, nano::Gxrb_ratio, send1.hash (), key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); @@ -2163,8 +2088,8 @@ TEST (ledger, state_rollback_received_send) ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_FALSE (store->block.exists (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (0, ledger.account_balance (transaction, key.pub)); ASSERT_EQ (0, ledger.weight (key.pub)); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); @@ -2177,17 +2102,16 @@ TEST (ledger, state_rep_change_rollback) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair rep; - nano::state_block change1 (nano::dev::genesis->account (), genesis.hash (), rep.pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block change1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change1).code); ASSERT_FALSE (ledger.rollback (transaction, change1.hash ())); ASSERT_FALSE (store->block.exists (transaction, change1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (0, ledger.weight (rep.pub)); } @@ -2198,19 +2122,18 @@ TEST (ledger, state_open_rollback) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::state_block open1 (destination.pub, 0, nano::dev::genesis->account (), nano::Gxrb_ratio, send1.hash (), destination.prv, destination.pub, *pool.generate (destination.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); ASSERT_FALSE (ledger.rollback (transaction, open1.hash ())); ASSERT_FALSE (store->block.exists (transaction, open1.hash ())); ASSERT_EQ (0, ledger.account_balance (transaction, destination.pub)); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); nano::pending_info info; ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (destination.pub, send1.hash ()), info)); ASSERT_EQ (nano::dev::genesis->account (), info.source); @@ -2225,17 +2148,16 @@ TEST (ledger, state_send_change_rollback) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair rep; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), rep.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), rep.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_FALSE (ledger.rollback (transaction, send1.hash ())); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (0, ledger.weight (rep.pub)); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); } @@ -2247,19 +2169,18 @@ TEST (ledger, state_receive_change_rollback) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); nano::keypair rep; - nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send1.hash (), rep.pub, nano::dev::constants.genesis_amount, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_FALSE (ledger.rollback (transaction, receive1.hash ())); ASSERT_FALSE (store->block.exists (transaction, receive1.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (0, ledger.weight (rep.pub)); ASSERT_EQ (store->account.count (transaction), ledger.cache.account_count); } @@ -2271,19 +2192,18 @@ TEST (ledger, epoch_blocks_v1_general) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block epoch1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code); ASSERT_FALSE (epoch1.sideband ().details.is_send); ASSERT_FALSE (epoch1.sideband ().details.is_receive); ASSERT_TRUE (epoch1.sideband ().details.is_epoch); ASSERT_EQ (nano::epoch::epoch_1, epoch1.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, epoch1.sideband ().source_epoch); // Not used for epoch blocks - nano::state_block epoch2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block epoch2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, epoch2).code); nano::account_info genesis_info; ASSERT_FALSE (ledger.store.account.get (transaction, nano::dev::genesis->account (), genesis_info)); @@ -2301,7 +2221,7 @@ TEST (ledger, epoch_blocks_v1_general) ASSERT_EQ (nano::epoch::epoch_0, epoch1.sideband ().source_epoch); // Not used for epoch blocks nano::change_block change1 (epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, change1).code); - nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (send1.sideband ().details.is_send); ASSERT_FALSE (send1.sideband ().details.is_receive); @@ -2328,7 +2248,7 @@ TEST (ledger, epoch_blocks_v1_general) ASSERT_EQ (0, ledger.balance (transaction, epoch4.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.balance (transaction, receive2.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive2.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.weight (destination.pub)); ASSERT_FALSE (receive2.sideband ().details.is_send); ASSERT_TRUE (receive2.sideband ().details.is_receive); @@ -2342,24 +2262,23 @@ TEST (ledger, epoch_blocks_v2_general) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block epoch1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); // Trying to upgrade from epoch 0 to epoch 2. It is a requirement epoch upgrades are sequential unless the account is unopened ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, epoch1).code); // Set it to the first epoch and it should now succeed - epoch1 = nano::state_block (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, epoch1.work); + epoch1 = nano::state_block (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, epoch1.work); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code); ASSERT_EQ (nano::epoch::epoch_1, epoch1.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, epoch1.sideband ().source_epoch); // Not used for epoch blocks - nano::state_block epoch2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block epoch2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch2).code); ASSERT_EQ (nano::epoch::epoch_2, epoch2.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, epoch2.sideband ().source_epoch); // Not used for epoch blocks - nano::state_block epoch3 (nano::dev::genesis->account (), epoch2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch2.hash ())); + nano::state_block epoch3 (nano::dev::genesis->account (), epoch2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch2.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, epoch3).code); nano::account_info genesis_info; ASSERT_FALSE (ledger.store.account.get (transaction, nano::dev::genesis->account (), genesis_info)); @@ -2372,7 +2291,7 @@ TEST (ledger, epoch_blocks_v2_general) ASSERT_EQ (genesis_info.epoch (), nano::epoch::epoch_1); nano::change_block change1 (epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::block_position, ledger.process (transaction, change1).code); - nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_EQ (nano::epoch::epoch_1, send1.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, send1.sideband ().source_epoch); // Not used for send blocks @@ -2397,7 +2316,7 @@ TEST (ledger, epoch_blocks_v2_general) ASSERT_EQ (0, ledger.balance (transaction, epoch6.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.balance (transaction, receive2.hash ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.amount (transaction, receive2.hash ())); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.weight (nano::dev::genesis->account ())); ASSERT_EQ (nano::Gxrb_ratio, ledger.weight (destination.pub)); } @@ -2408,16 +2327,15 @@ TEST (ledger, epoch_blocks_receive_upgrade) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::state_block epoch1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block epoch1 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code); - nano::state_block send2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_EQ (nano::epoch::epoch_1, send2.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, send2.sideband ().source_epoch); // Not used for send blocks @@ -2454,14 +2372,14 @@ TEST (ledger, epoch_blocks_receive_upgrade) ASSERT_EQ (nano::process_result::unreceivable, ledger.process (transaction, open2).code); // Upgrade to epoch 2 and send to destination. Try to create an open block from an epoch 2 source block. nano::keypair destination3; - nano::state_block epoch2 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); + nano::state_block epoch2 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch2).code); - nano::state_block send4 (nano::dev::genesis->account (), epoch2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 3, destination3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch2.hash ())); + nano::state_block send4 (nano::dev::genesis->account (), epoch2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 3, destination3.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send4).code); nano::open_block open3 (send4.hash (), destination3.pub, destination3.pub, destination3.prv, destination3.pub, *pool.generate (destination3.pub)); ASSERT_EQ (nano::process_result::unreceivable, ledger.process (transaction, open3).code); // Send it to an epoch 1 account - nano::state_block send5 (nano::dev::genesis->account (), send4.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 4, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send4.hash ())); + nano::state_block send5 (nano::dev::genesis->account (), send4.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 4, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send4.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send5).code); ASSERT_FALSE (ledger.store.account.get (transaction, destination.pub, destination_info)); ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_1); @@ -2473,7 +2391,7 @@ TEST (ledger, epoch_blocks_receive_upgrade) ASSERT_EQ (destination_info.epoch (), nano::epoch::epoch_2); // Upgrade an unopened account straight to epoch 2 nano::keypair destination4; - nano::state_block send6 (nano::dev::genesis->account (), send5.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 5, destination4.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send5.hash ())); + nano::state_block send6 (nano::dev::genesis->account (), send5.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 5, destination4.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send5.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send6).code); nano::state_block epoch4 (destination4.pub, 0, 0, 0, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (destination4.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch4).code); @@ -2489,22 +2407,21 @@ TEST (ledger, epoch_blocks_fork) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; - nano::send_block send1 (genesis.hash (), nano::account (0), nano::dev::genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::account (0), nano::dev::constants.genesis_amount, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::state_block epoch1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, epoch1).code); - nano::state_block epoch2 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block epoch2 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, epoch2).code); - nano::state_block epoch3 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block epoch3 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch3).code); ASSERT_EQ (nano::epoch::epoch_1, epoch3.sideband ().details.epoch); ASSERT_EQ (nano::epoch::epoch_0, epoch3.sideband ().source_epoch); // Not used for epoch state blocks - nano::state_block epoch4 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block epoch4 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_2), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::fork, ledger.process (transaction, epoch2).code); } @@ -2513,13 +2430,12 @@ TEST (ledger, successor_epoch) nano::system system (1); auto & node1 (*system.nodes[0]); nano::keypair key1; - nano::genesis genesis; nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), key1.pub, nano::dev::genesis_amount - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), key1.pub, nano::dev::constants.genesis_amount - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); nano::state_block open (key1.pub, 0, key1.pub, 1, send1.hash (), key1.prv, key1.pub, *pool.generate (key1.pub)); nano::state_block change (key1.pub, open.hash (), key1.pub, 1, 0, key1.prv, key1.pub, *pool.generate (open.hash ())); auto open_hash = open.hash (); - nano::send_block send2 (send1.hash (), reinterpret_cast (open_hash), nano::dev::genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::send_block send2 (send1.hash (), reinterpret_cast (open_hash), nano::dev::constants.genesis_amount - 2, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); nano::state_block epoch_open (reinterpret_cast (open_hash), 0, 0, 0, node1.ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (open.hash ())); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, send1).code); @@ -2565,7 +2481,7 @@ TEST (ledger, epoch_open_pending) .account (nano::dev::genesis->account ()) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (nano::dev::genesis->hash ())) @@ -2580,7 +2496,6 @@ TEST (ledger, block_hash_account_conflict) nano::block_builder builder; nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; nano::work_pool pool (std::numeric_limits::max ()); @@ -2591,12 +2506,12 @@ TEST (ledger, block_hash_account_conflict) */ auto send1 = builder.state () .account (nano::dev::genesis->account ()) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*pool.generate (genesis.hash ())) + .work (*pool.generate (nano::dev::genesis->hash ())) .build_shared (); auto receive1 = builder.state () @@ -2673,20 +2588,19 @@ TEST (ledger, could_fit) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair destination; // Test legacy and state change blocks could_fit - nano::change_block change1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); - nano::state_block change2 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::change_block change1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); + nano::state_block change2 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_TRUE (ledger.could_fit (transaction, change1)); ASSERT_TRUE (ledger.could_fit (transaction, change2)); // Test legacy and state send nano::keypair key1; - nano::send_block send1 (change1.hash (), key1.pub, nano::dev::genesis_amount - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); - nano::state_block send2 (nano::dev::genesis->account (), change1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); + nano::send_block send1 (change1.hash (), key1.pub, nano::dev::constants.genesis_amount - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), change1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); ASSERT_FALSE (ledger.could_fit (transaction, send1)); ASSERT_FALSE (ledger.could_fit (transaction, send2)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change1).code); @@ -2708,7 +2622,7 @@ TEST (ledger, could_fit) ASSERT_TRUE (ledger.could_fit (transaction, open1)); ASSERT_TRUE (ledger.could_fit (transaction, open2)); // Create another send to receive - nano::state_block send3 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 2, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); + nano::state_block send3 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 2, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); // Test legacy and state receive nano::receive_block receive1 (open1.hash (), send3.hash (), key1.prv, key1.pub, *pool.generate (open1.hash ())); nano::state_block receive2 (key1.pub, open1.hash (), nano::dev::genesis->account (), 2, send3.hash (), key1.prv, key1.pub, *pool.generate (open1.hash ())); @@ -2732,9 +2646,8 @@ TEST (ledger, unchecked_epoch) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair destination; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto open1 (std::make_shared (destination.pub, 0, destination.pub, nano::Gxrb_ratio, send1->hash (), destination.prv, destination.pub, 0)); node1.work_generate_blocking (*open1); @@ -2772,9 +2685,8 @@ TEST (ledger, unchecked_epoch_invalid) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config)); - nano::genesis genesis; nano::keypair destination; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto open1 (std::make_shared (destination.pub, 0, destination.pub, nano::Gxrb_ratio, send1->hash (), destination.prv, destination.pub, 0)); node1.work_generate_blocking (*open1); @@ -2824,9 +2736,8 @@ TEST (ledger, unchecked_open) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair destination; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); auto open1 (std::make_shared (send1->hash (), destination.pub, destination.pub, destination.prv, destination.pub, 0)); node1.work_generate_blocking (*open1); @@ -2861,11 +2772,10 @@ TEST (ledger, unchecked_receive) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::keypair destination; - auto send1 (std::make_shared (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send1 (std::make_shared (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send1); - auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 2 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto send2 (std::make_shared (nano::dev::genesis->account (), send1->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio, destination.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*send2); auto open1 (std::make_shared (send1->hash (), destination.pub, destination.pub, destination.prv, destination.pub, 0)); node1.work_generate_blocking (*open1); @@ -2915,7 +2825,6 @@ TEST (ledger, confirmation_height_not_updated) nano::stat stats; nano::ledger ledger (*store, stats); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::account_info account_info; @@ -2925,11 +2834,11 @@ TEST (ledger, confirmation_height_not_updated) nano::confirmation_height_info confirmation_height_info; ASSERT_FALSE (store->confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (1, confirmation_height_info.height); - ASSERT_EQ (genesis.hash (), confirmation_height_info.frontier); + ASSERT_EQ (nano::dev::genesis->hash (), confirmation_height_info.frontier); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_FALSE (store->confirmation_height.get (transaction, nano::dev::genesis->account (), confirmation_height_info)); ASSERT_EQ (1, confirmation_height_info.height); - ASSERT_EQ (genesis.hash (), confirmation_height_info.frontier); + ASSERT_EQ (nano::dev::genesis->hash (), confirmation_height_info.frontier); nano::open_block open1 (send1.hash (), nano::dev::genesis->account (), key.pub, key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); ASSERT_TRUE (store->confirmation_height.get (transaction, key.pub, confirmation_height_info)); @@ -2941,32 +2850,31 @@ TEST (ledger, zero_rep) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::block_builder builder; auto block1 = builder.state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (0) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build (); auto transaction (node1.store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *block1).code); ASSERT_EQ (0, node1.ledger.cache.rep_weights.representation_get (nano::dev::genesis_key.pub)); - ASSERT_EQ (nano::dev::genesis_amount, node1.ledger.cache.rep_weights.representation_get (0)); + ASSERT_EQ (nano::dev::constants.genesis_amount, node1.ledger.cache.rep_weights.representation_get (0)); auto block2 = builder.state () .account (nano::dev::genesis_key.pub) .previous (block1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (block1->hash ())) .build (); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *block2).code); - ASSERT_EQ (nano::dev::genesis_amount, node1.ledger.cache.rep_weights.representation_get (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, node1.ledger.cache.rep_weights.representation_get (nano::dev::genesis_key.pub)); ASSERT_EQ (0, node1.ledger.cache.rep_weights.representation_get (0)); } @@ -2977,7 +2885,6 @@ TEST (ledger, work_validation) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; store->initialize (store->tx_begin_write (), ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::block_builder builder; @@ -3002,7 +2909,7 @@ TEST (ledger, work_validation) auto send = *builder.send () .previous (nano::dev::genesis->hash ()) .destination (gen.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (gen.prv, gen.pub) .work (0) .build (ec); @@ -3028,7 +2935,7 @@ TEST (ledger, work_validation) .account (gen.pub) .previous (change.hash ()) .representative (gen.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .link (key.pub) .sign (gen.prv, gen.pub) .work (0) @@ -3072,19 +2979,18 @@ TEST (ledger, dependents_confirmed) nano::stat stats; nano::ledger ledger (*store, stats); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); - ASSERT_TRUE (ledger.dependents_confirmed (transaction, *genesis.open)); + ASSERT_TRUE (ledger.dependents_confirmed (transaction, *nano::dev::genesis)); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; auto send1 = builder.state () .account (nano::dev::genesis->account ()) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*pool.generate (genesis.hash ())) + .work (*pool.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code); ASSERT_TRUE (ledger.dependents_confirmed (transaction, *send1)); @@ -3092,7 +2998,7 @@ TEST (ledger, dependents_confirmed) .account (nano::dev::genesis->account ()) .previous (send1->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 200) + .balance (nano::dev::constants.genesis_amount - 200) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (send1->hash ())) @@ -3146,25 +3052,24 @@ TEST (ledger, dependents_confirmed_pruning) nano::ledger ledger (*store, stats); ledger.pruning = true; auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; auto send1 = builder.state () .account (nano::dev::genesis->account ()) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*pool.generate (genesis.hash ())) + .work (*pool.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code); auto send2 = builder.state () .account (nano::dev::genesis->account ()) .previous (send1->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 200) + .balance (nano::dev::constants.genesis_amount - 200) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (send1->hash ())) @@ -3197,19 +3102,18 @@ TEST (ledger, block_confirmed) nano::stat stats; nano::ledger ledger (*store, stats); auto transaction (store->tx_begin_write ()); - nano::genesis genesis; store->initialize (transaction, ledger.cache); - ASSERT_TRUE (ledger.block_confirmed (transaction, genesis.open->hash ())); + ASSERT_TRUE (ledger.block_confirmed (transaction, nano::dev::genesis->hash ())); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key1; auto send1 = builder.state () .account (nano::dev::genesis->account ()) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*pool.generate (genesis.hash ())) + .work (*pool.generate (nano::dev::genesis->hash ())) .build (); // Must be safe against non-existing blocks ASSERT_FALSE (ledger.block_confirmed (transaction, send1->hash ())); @@ -3229,7 +3133,6 @@ TEST (ledger, cache) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; store->initialize (store->tx_begin_write (), ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::block_builder builder; @@ -3242,7 +3145,7 @@ TEST (ledger, cache) auto account_count = 1 + i; auto block_count = 1 + 2 * (i + 1) - 2; auto cemented_count = 1 + 2 * (i + 1) - 2; - auto genesis_weight = nano::dev::genesis_amount - i; + auto genesis_weight = nano::dev::constants.genesis_amount - i; auto pruned_count = i; auto cache_check = [&, i] (nano::ledger_cache const & cache_a) { @@ -3259,7 +3162,7 @@ TEST (ledger, cache) .account (nano::dev::genesis->account ()) .previous (latest) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - (i + 1)) + .balance (nano::dev::constants.genesis_amount - (i + 1)) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (latest)) @@ -3342,23 +3245,22 @@ TEST (ledger, pruning_action) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); auto send1_stored (store->block.get (transaction, send1.hash ())); ASSERT_NE (nullptr, send1_stored); ASSERT_EQ (send1, *send1_stored); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Pruning action ASSERT_EQ (1, ledger.pruning_action (transaction, send1.hash (), 1)); - ASSERT_EQ (0, ledger.pruning_action (transaction, genesis.hash (), 1)); + ASSERT_EQ (0, ledger.pruning_action (transaction, nano::dev::genesis->hash (), 1)); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_TRUE (ledger.block_or_pruned_exists (transaction, send1.hash ())); @@ -3367,10 +3269,10 @@ TEST (ledger, pruning_action) ASSERT_TRUE (ledger.block_or_pruned_exists (transaction, send1.hash ())); ledger.pruning = true; ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Receiving pruned block - nano::state_block receive1 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_TRUE (store->block.exists (transaction, receive1.hash ())); auto receive1_stored (store->block.get (transaction, receive1.hash ())); @@ -3399,18 +3301,17 @@ TEST (ledger, pruning_large_chain) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); size_t send_receive_pairs (20); - auto last_hash (genesis.hash ()); + auto last_hash (nano::dev::genesis->hash ()); for (auto i (0); i < send_receive_pairs; i++) { - nano::state_block send (nano::dev::genesis->account (), last_hash, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (last_hash)); + nano::state_block send (nano::dev::genesis->account (), last_hash, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (last_hash)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); ASSERT_TRUE (store->block.exists (transaction, send.hash ())); - nano::state_block receive (nano::dev::genesis->account (), send.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); + nano::state_block receive (nano::dev::genesis->account (), send.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, send.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code); ASSERT_TRUE (store->block.exists (transaction, receive.hash ())); last_hash = receive.hash (); @@ -3420,7 +3321,7 @@ TEST (ledger, pruning_large_chain) // Pruning action ASSERT_EQ (send_receive_pairs * 2, ledger.pruning_action (transaction, last_hash, 5)); ASSERT_TRUE (store->pruned.exists (transaction, last_hash)); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); ASSERT_FALSE (store->block.exists (transaction, last_hash)); ASSERT_EQ (store->pruned.count (transaction), ledger.cache.pruned_count); ASSERT_EQ (store->block.count (transaction), ledger.cache.block_count - ledger.cache.pruned_count); @@ -3436,16 +3337,15 @@ TEST (ledger, pruning_source_rollback) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block epoch1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block epoch1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, ledger.epoch_link (nano::epoch::epoch_1), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, epoch1).code); - nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), epoch1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (epoch1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Pruning action @@ -3454,14 +3354,14 @@ TEST (ledger, pruning_source_rollback) ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); ASSERT_FALSE (store->block.exists (transaction, epoch1.hash ())); ASSERT_TRUE (store->pruned.exists (transaction, epoch1.hash ())); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); nano::pending_info info; ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()), info)); ASSERT_EQ (nano::dev::genesis->account (), info.source); ASSERT_EQ (nano::Gxrb_ratio, info.amount.number ()); ASSERT_EQ (nano::epoch::epoch_1, info.epoch); // Receiving pruned block - nano::state_block receive1 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); + nano::state_block receive1 (nano::dev::genesis->account (), send2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); ASSERT_FALSE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); ASSERT_EQ (2, ledger.cache.pruned_count); @@ -3488,19 +3388,18 @@ TEST (ledger, pruning_source_rollback_legacy) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); nano::keypair key1; - nano::send_block send2 (send1.hash (), key1.pub, nano::dev::genesis_amount - 2 * nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::send_block send2 (send1.hash (), key1.pub, nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (key1.pub, send2.hash ()))); - nano::send_block send3 (send2.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - 3 * nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); + nano::send_block send3 (send2.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send3).code); ASSERT_TRUE (store->block.exists (transaction, send3.hash ())); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send3.hash ()))); @@ -3510,7 +3409,7 @@ TEST (ledger, pruning_source_rollback_legacy) ASSERT_TRUE (store->pruned.exists (transaction, send2.hash ())); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); nano::pending_info info1; ASSERT_FALSE (store->pending.get (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()), info1)); ASSERT_EQ (nano::dev::genesis->account (), info1.source); @@ -3567,11 +3466,10 @@ TEST (ledger, pruning_process_error) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_EQ (0, ledger.cache.pruned_count); ASSERT_EQ (2, ledger.cache.block_count); @@ -3582,7 +3480,7 @@ TEST (ledger, pruning_process_error) // Attempt to process pruned block again ASSERT_EQ (nano::process_result::old, ledger.process (transaction, send1).code); // Attept to process new block after pruned - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::gap_previous, ledger.process (transaction, send2).code); ASSERT_EQ (1, ledger.cache.pruned_count); ASSERT_EQ (2, ledger.cache.block_count); @@ -3596,19 +3494,18 @@ TEST (ledger, pruning_legacy_blocks) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; nano::keypair key1; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::send_block send1 (genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::send_block send1 (nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->pending.exists (transaction, nano::pending_key (nano::dev::genesis->account (), send1.hash ()))); nano::receive_block receive1 (send1.hash (), send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive1).code); nano::change_block change1 (receive1.hash (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (receive1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, change1).code); - nano::send_block send2 (change1.hash (), key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); + nano::send_block send2 (change1.hash (), key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (change1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); nano::open_block open1 (send2.hash (), nano::dev::genesis->account (), key1.pub, key1.prv, key1.pub, *pool.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open1).code); @@ -3617,7 +3514,7 @@ TEST (ledger, pruning_legacy_blocks) // Pruning action ASSERT_EQ (3, ledger.pruning_action (transaction, change1.hash (), 2)); ASSERT_EQ (1, ledger.pruning_action (transaction, open1.hash (), 1)); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); ASSERT_FALSE (store->block.exists (transaction, receive1.hash ())); @@ -3642,14 +3539,13 @@ TEST (ledger, pruning_safe_functions) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Pruning action @@ -3657,14 +3553,14 @@ TEST (ledger, pruning_safe_functions) ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_TRUE (ledger.block_or_pruned_exists (transaction, send1.hash ())); // true for pruned ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Safe ledger actions bool error (false); ASSERT_EQ (0, ledger.balance_safe (transaction, send1.hash (), error)); ASSERT_TRUE (error); error = false; - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio * 2, ledger.balance_safe (transaction, send2.hash (), error)); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, ledger.balance_safe (transaction, send2.hash (), error)); ASSERT_FALSE (error); error = false; ASSERT_EQ (0, ledger.amount_safe (transaction, send2.hash (), error)); @@ -3685,21 +3581,20 @@ TEST (ledger, hash_root_random) nano::stat stats; nano::ledger ledger (*store, stats); ledger.pruning = true; - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); - nano::state_block send1 (nano::dev::genesis->account (), genesis.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis->account (), nano::dev::genesis->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); ASSERT_TRUE (store->block.exists (transaction, send1.hash ())); - nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); + nano::state_block send2 (nano::dev::genesis->account (), send1.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio * 2, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Pruning action ASSERT_EQ (1, ledger.pruning_action (transaction, send1.hash (), 1)); ASSERT_FALSE (store->block.exists (transaction, send1.hash ())); ASSERT_TRUE (store->pruned.exists (transaction, send1.hash ())); - ASSERT_TRUE (store->block.exists (transaction, genesis.hash ())); + ASSERT_TRUE (store->block.exists (transaction, nano::dev::genesis->hash ())); ASSERT_TRUE (store->block.exists (transaction, send2.hash ())); // Test random block including pruned bool done (false); @@ -3724,7 +3619,6 @@ TEST (ledger, hash_root_random) TEST (ledger, migrate_lmdb_to_rocksdb) { auto path (nano::unique_path ()); - nano::genesis genesis; nano::logger_mt logger; boost::asio::ip::address_v6 address (boost::asio::ip::make_address_v6 ("::ffff:127.0.0.1")); uint16_t port = 100; @@ -3738,7 +3632,7 @@ TEST (ledger, migrate_lmdb_to_rocksdb) .previous (nano::dev::genesis->hash ()) .representative (0) .link (nano::account (10)) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -3810,7 +3704,6 @@ TEST (ledger, unconfirmed_frontiers) ASSERT_TRUE (!store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; store->initialize (store->tx_begin_write (), ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -3824,7 +3717,7 @@ TEST (ledger, unconfirmed_frontiers) .account (nano::dev::genesis->account ()) .previous (latest) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*pool.generate (latest)) diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index fd840137cb..f4754b9aba 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -205,17 +205,16 @@ TEST (network, send_discarded_publish) auto & node1 (*system.nodes[0]); auto & node2 (*system.nodes[1]); auto block (std::make_shared (1, 1, 2, nano::keypair ().prv, 4, *system.work.generate (nano::root (1)))); - nano::genesis genesis; { auto transaction (node1.store.tx_begin_read ()); node1.network.flood_block (block); - ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); - ASSERT_EQ (genesis.hash (), node2.latest (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node2.latest (nano::dev::genesis_key.pub)); } 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::dev::genesis_key.pub)); - ASSERT_EQ (genesis.hash (), node2.latest (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node2.latest (nano::dev::genesis_key.pub)); } TEST (network, send_invalid_publish) @@ -223,18 +222,17 @@ TEST (network, send_invalid_publish) nano::system system (2); auto & node1 (*system.nodes[0]); auto & node2 (*system.nodes[1]); - nano::genesis genesis; auto block (std::make_shared (1, 1, 20, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::root (1)))); { auto transaction (node1.store.tx_begin_read ()); node1.network.flood_block (block); - ASSERT_EQ (genesis.hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); - ASSERT_EQ (genesis.hash (), node2.latest (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node2.latest (nano::dev::genesis_key.pub)); } 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::dev::genesis_key.pub)); - ASSERT_EQ (genesis.hash (), node2.latest (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node1.ledger.latest (transaction, nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::genesis->hash (), node2.latest (nano::dev::genesis_key.pub)); } TEST (network, send_valid_confirm_ack) @@ -353,8 +351,7 @@ TEST (receivable_processor, confirm_insufficient_pos) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; - auto block1 (std::make_shared (genesis.hash (), 0, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto block1 (std::make_shared (nano::dev::genesis->hash (), 0, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*block1); ASSERT_EQ (nano::process_result::progress, node1.process (*block1).code); node1.scheduler.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); @@ -368,8 +365,7 @@ TEST (receivable_processor, confirm_sufficient_pos) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; - auto block1 (std::make_shared (genesis.hash (), 0, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); + auto block1 (std::make_shared (nano::dev::genesis->hash (), 0, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0)); node1.work_generate_blocking (*block1); ASSERT_EQ (nano::process_result::progress, node1.process (*block1).code); node1.scheduler.activate (nano::dev::genesis_key.pub, node1.store.tx_begin_read ()); @@ -947,8 +943,7 @@ TEST (network, duplicate_detection) auto & node0 (*system.add_node (node_flags)); auto & node1 (*system.add_node (node_flags)); auto udp_channel (std::make_shared (node0.network.udp_channels, node1.network.endpoint (), node1.network_params.protocol.protocol_version)); - nano::genesis genesis; - nano::publish publish (genesis.open); + nano::publish publish (nano::dev::genesis); // Publish duplicate detection through UDP ASSERT_EQ (0, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_publish)); @@ -970,8 +965,7 @@ TEST (network, duplicate_revert_publish) node_flags.block_processor_full_size = 0; auto & node (*system.add_node (node_flags)); ASSERT_TRUE (node.block_processor.full ()); - nano::genesis genesis; - nano::publish publish (genesis.open); + nano::publish publish (nano::dev::genesis); std::vector bytes; { nano::vectorstream stream (bytes); @@ -1000,8 +994,7 @@ TEST (network, duplicate_revert_publish) TEST (network, bandwidth_limiter) { nano::system system; - nano::genesis genesis; - nano::publish message (genesis.open); + nano::publish message (nano::dev::genesis); auto message_size = message.to_bytes ()->size (); auto message_limit = 4; // must be multiple of the number of channels nano::node_config node_config (nano::get_available_port (), system.logging); diff --git a/nano/core_test/network_filter.cpp b/nano/core_test/network_filter.cpp index 43ce1bfc96..90f29c5dad 100644 --- a/nano/core_test/network_filter.cpp +++ b/nano/core_test/network_filter.cpp @@ -8,7 +8,7 @@ TEST (network_filter, unit) { - nano::genesis genesis; + nano::ledger_constants constants{ nano::networks::nano_dev_network }; nano::network_filter filter (1); auto one_block = [&filter] (std::shared_ptr const & block_a, bool expect_duplicate_a) { nano::publish message (block_a); @@ -32,17 +32,17 @@ TEST (network_filter, unit) ASSERT_NE (nullptr, block); ASSERT_EQ (*block, *block_a); }; - one_block (genesis.open, false); + one_block (constants.genesis, false); for (int i = 0; i < 10; ++i) { - one_block (genesis.open, true); + one_block (constants.genesis, true); } nano::state_block_builder builder; auto new_block = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.open->hash ()) + .previous (constants.genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 10 * nano::xrb_ratio) + .balance (nano::dev::constants.genesis_amount - 10 * nano::xrb_ratio) .link (nano::public_key ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -55,14 +55,14 @@ TEST (network_filter, unit) } for (int i = 0; i < 100; ++i) { - one_block (genesis.open, false); + one_block (constants.genesis, false); one_block (new_block, false); } } TEST (network_filter, many) { - nano::genesis genesis; + nano::ledger_constants constants{ nano::networks::nano_dev_network }; nano::network_filter filter (4); nano::keypair key1; for (int i = 0; i < 100; ++i) @@ -70,9 +70,9 @@ TEST (network_filter, many) nano::state_block_builder builder; auto block = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.open->hash ()) + .previous (constants.genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - i * 10 * nano::xrb_ratio) + .balance (nano::dev::constants.genesis_amount - i * 10 * nano::xrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 640d895f6c..44486cb1f6 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -186,14 +186,13 @@ TEST (node, send_out_of_order) nano::system system (2); auto & node1 (*system.nodes[0]); nano::keypair key2; - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () .previous (send1->hash ()) @@ -212,7 +211,7 @@ TEST (node, send_out_of_order) node1.process_active (send3); node1.process_active (send2); node1.process_active (send1); - ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) { return node_a->balance (nano::dev::genesis_key.pub) == nano::dev::genesis_amount - node1.config.receive_minimum.number () * 3; })); + ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr const & node_a) { return node_a->balance (nano::dev::genesis_key.pub) == nano::dev::constants.genesis_amount - node1.config.receive_minimum.number () * 3; })); } TEST (node, quick_confirm) @@ -247,7 +246,7 @@ TEST (node, node_receive_quorum) auto send = nano::send_block_builder () .previous (previous) .destination (key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (previous)) .build_shared (); @@ -1050,21 +1049,20 @@ TEST (node, fork_publish) auto & node1 (*system.nodes[0]); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) .build_shared (); node1.work_generate_blocking (*send1); nano::keypair key2; auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) .build_shared (); @@ -1085,7 +1083,7 @@ TEST (node, fork_publish) ASSERT_EQ (send1->hash (), existing1->second.hash); auto winner (*election->tally ().begin ()); ASSERT_EQ (*send1, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); } ASSERT_TRUE (node0.expired ()); } @@ -1094,21 +1092,20 @@ TEST (node, fork_publish) TEST (node, fork_publish_inactive) { nano::system system (1); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (send1->block_work ()) .build_shared (); @@ -1133,22 +1130,21 @@ TEST (node, fork_keep) ASSERT_EQ (1, node1.network.size ()); nano::keypair key1; nano::keypair key2; - nano::genesis genesis; nano::send_block_builder builder; // send1 and send2 fork to different accounts auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); node1.block_processor.flush (); @@ -1163,7 +1159,7 @@ TEST (node, fork_keep) node1.block_processor.flush (); node2.process_active (send2); node2.block_processor.flush (); - auto election1 (node2.active.election (nano::qualified_root (genesis.hash (), genesis.hash ()))); + auto election1 (node2.active.election (nano::qualified_root (nano::dev::genesis->hash (), nano::dev::genesis->hash ()))); ASSERT_NE (nullptr, election1); ASSERT_EQ (1, election1->votes ().size ()); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send1->hash ())); @@ -1175,7 +1171,7 @@ TEST (node, fork_keep) // The vote should be in agreement with what we already have. auto winner (*election1->tally ().begin ()); ASSERT_EQ (*send1, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); ASSERT_TRUE (node1.store.block.exists (transaction0, send1->hash ())); ASSERT_TRUE (node2.store.block.exists (transaction1, send1->hash ())); } @@ -1187,23 +1183,22 @@ TEST (node, fork_flip) auto & node2 (*system.nodes[1]); ASSERT_EQ (1, node1.network.size ()); nano::keypair key1; - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::publish publish1 (send1); nano::keypair key2; auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::publish publish2 (send2); auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ())); @@ -1221,7 +1216,7 @@ TEST (node, fork_flip) node1.block_processor.flush (); node2.network.inbound (publish1, channel2); node2.block_processor.flush (); - auto election1 (node2.active.election (nano::qualified_root (genesis.hash (), genesis.hash ()))); + auto election1 (node2.active.election (nano::qualified_root (nano::dev::genesis->hash (), nano::dev::genesis->hash ()))); ASSERT_NE (nullptr, election1); ASSERT_EQ (1, election1->votes ().size ()); ASSERT_NE (nullptr, node1.block (publish1.block->hash ())); @@ -1229,7 +1224,7 @@ TEST (node, fork_flip) ASSERT_TIMELY (10s, node2.ledger.block_or_pruned_exists (publish1.block->hash ())); auto winner (*election1->tally ().begin ()); ASSERT_EQ (*publish1.block, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (publish1.block->hash ())); ASSERT_TRUE (node2.ledger.block_or_pruned_exists (publish1.block->hash ())); ASSERT_FALSE (node2.ledger.block_or_pruned_exists (publish2.block->hash ())); @@ -1255,29 +1250,28 @@ TEST (node, fork_multi_flip) auto & node2 (*system.add_node (node_config, node_flags, type)); ASSERT_EQ (1, node1.network.size ()); nano::keypair key1; - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::publish publish1 (send1); nano::keypair key2; auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::publish publish2 (send2); auto send3 = builder.make_block () .previous (publish2.block->hash ()) .destination (key2.pub) - .balance (nano::dev::genesis_amount - 100) + .balance (nano::dev::constants.genesis_amount - 100) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (publish2.block->hash ())) .build_shared (); @@ -1297,7 +1291,7 @@ TEST (node, fork_multi_flip) node1.block_processor.flush (); node2.network.inbound (publish1, node2.network.udp_channels.create (node2.network.endpoint ())); node2.block_processor.flush (); - auto election1 (node2.active.election (nano::qualified_root (genesis.hash (), genesis.hash ()))); + auto election1 (node2.active.election (nano::qualified_root (nano::dev::genesis->hash (), nano::dev::genesis->hash ()))); ASSERT_NE (nullptr, election1); ASSERT_EQ (1, election1->votes ().size ()); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (publish1.block->hash ())); @@ -1306,7 +1300,7 @@ TEST (node, fork_multi_flip) ASSERT_TIMELY (10s, node2.ledger.block_or_pruned_exists (publish1.block->hash ())); auto winner (*election1->tally ().begin ()); ASSERT_EQ (*publish1.block, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 100, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 100, winner.first); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (publish1.block->hash ())); ASSERT_TRUE (node2.ledger.block_or_pruned_exists (publish1.block->hash ())); ASSERT_FALSE (node2.ledger.block_or_pruned_exists (publish2.block->hash ())); @@ -1335,7 +1329,7 @@ TEST (node, fork_bootstrap_flip) auto send1 = builder.make_block () .previous (latest) .destination (key1.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system0.work.generate (latest)) .build_shared (); @@ -1343,7 +1337,7 @@ TEST (node, fork_bootstrap_flip) auto send2 = builder.make_block () .previous (latest) .destination (key2.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system0.work.generate (latest)) .build_shared (); @@ -1367,13 +1361,12 @@ TEST (node, fork_open) nano::system system (1); auto & node1 (*system.nodes[0]); nano::keypair key1; - nano::genesis genesis; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) .balance (0) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::publish publish1 (send1); auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ())); @@ -1424,15 +1417,14 @@ TEST (node, fork_open_flip) auto & node2 (*system.nodes[1]); ASSERT_EQ (1, node1.network.size ()); nano::keypair key1; - nano::genesis genesis; nano::keypair rep1; nano::keypair rep2; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); // A copy is necessary to avoid data races during ledger processing, which sets the sideband auto send1_copy (std::make_shared (*send1)); @@ -1484,7 +1476,7 @@ TEST (node, fork_open_flip) auto transaction2 (node2.store.tx_begin_read ()); auto winner (*election1->tally ().begin ()); ASSERT_EQ (*open1, *winner.second); - ASSERT_EQ (nano::dev::genesis_amount - 1, winner.first); + ASSERT_EQ (nano::dev::constants.genesis_amount - 1, winner.first); ASSERT_TRUE (node1.store.block.exists (transaction1, open1->hash ())); ASSERT_TRUE (node2.store.block.exists (transaction2, open1->hash ())); ASSERT_FALSE (node2.store.block.exists (transaction2, open2->hash ())); @@ -1511,7 +1503,7 @@ TEST (node, fork_no_vote_quorum) auto & node3 (*system.nodes[2]); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto key4 (system.wallet (0)->deterministic_insert ()); - system.wallet (0)->send_action (nano::dev::genesis_key.pub, key4, nano::dev::genesis_amount / 4); + system.wallet (0)->send_action (nano::dev::genesis_key.pub, key4, nano::dev::constants.genesis_amount / 4); auto key1 (system.wallet (1)->deterministic_insert ()); { auto transaction (system.wallet (1)->wallets.tx_begin_write ()); @@ -1523,7 +1515,7 @@ TEST (node, fork_no_vote_quorum) 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)); - nano::state_block send1 (nano::dev::genesis_key.pub, block->hash (), nano::dev::genesis_key.pub, (nano::dev::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), key1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (block->hash ())); + nano::state_block send1 (nano::dev::genesis_key.pub, block->hash (), nano::dev::genesis_key.pub, (nano::dev::constants.genesis_amount / 4) - (node1.config.receive_minimum.number () * 2), key1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (block->hash ())); ASSERT_EQ (nano::process_result::progress, node1.process (send1).code); ASSERT_EQ (nano::process_result::progress, node2.process (send1).code); ASSERT_EQ (nano::process_result::progress, node3.process (send1).code); @@ -1531,7 +1523,7 @@ TEST (node, fork_no_vote_quorum) auto send2 = nano::send_block_builder () .previous (block->hash ()) .destination (key2) - .balance ((nano::dev::genesis_amount / 4) - (node1.config.receive_minimum.number () * 2)) + .balance ((nano::dev::constants.genesis_amount / 4) - (node1.config.receive_minimum.number () * 2)) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (block->hash ())) .build_shared (); @@ -1561,7 +1553,6 @@ TEST (node, DISABLED_fork_pre_confirm) auto & node0 (*system.nodes[0]); auto & node1 (*system.nodes[1]); auto & node2 (*system.nodes[2]); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; system.wallet (1)->insert_adhoc (key1.prv); @@ -1575,10 +1566,10 @@ TEST (node, DISABLED_fork_pre_confirm) auto transaction (system.wallet (2)->wallets.tx_begin_write ()); system.wallet (2)->store.representative_set (transaction, key2.pub); } - auto block0 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, nano::dev::genesis_amount / 3)); + auto block0 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, nano::dev::constants.genesis_amount / 3)); ASSERT_NE (nullptr, block0); ASSERT_TIMELY (30s, node0.balance (key1.pub) != 0); - auto block1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, nano::dev::genesis_amount / 3)); + auto block1 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, nano::dev::constants.genesis_amount / 3)); ASSERT_NE (nullptr, block1); ASSERT_TIMELY (30s, node0.balance (key2.pub) != 0); nano::keypair key3; @@ -1630,15 +1621,14 @@ TEST (node, DISABLED_fork_stale) std::shared_ptr channel (std::make_shared (node2.network.udp_channels, node1.network.endpoint (), node2.network_params.protocol.protocol_version)); auto vote = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, std::vector ()); node2.rep_crawler.response (channel, vote); - nano::genesis genesis; nano::keypair key1; nano::keypair key2; nano::state_block_builder builder; auto send3 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Mxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Mxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1655,7 +1645,7 @@ TEST (node, DISABLED_fork_stale) .account (nano::dev::genesis_key.pub) .previous (send3->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Mxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Mxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1665,7 +1655,7 @@ TEST (node, DISABLED_fork_stale) .account (nano::dev::genesis_key.pub) .previous (send3->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Mxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Mxrb_ratio) .link (key2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (0) @@ -1964,7 +1954,7 @@ TEST (node, bootstrap_fork_open) auto send0 = *builder.send () .previous (nano::dev::genesis->hash ()) .destination (key0.pub) - .balance (nano::dev::genesis_amount - 500) + .balance (nano::dev::constants.genesis_amount - 500) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build (); @@ -2020,7 +2010,7 @@ TEST (node, bootstrap_confirm_frontiers) auto send0 = nano::send_block_builder () .previous (nano::dev::genesis->hash ()) .destination (key0.pub) - .balance (nano::dev::genesis_amount - 500) + .balance (nano::dev::constants.genesis_amount - 500) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node0->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); @@ -2082,7 +2072,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::dev::genesis->account (), nano::Mxrb_ratio)); - ASSERT_TIMELY (10s, node0.balance (nano::dev::genesis->account ()) == nano::dev::genesis_amount); + ASSERT_TIMELY (10s, node0.balance (nano::dev::genesis->account ()) == nano::dev::constants.genesis_amount); } // Test that nodes can track nodes that have rep weight for priority broadcasting @@ -2127,7 +2117,6 @@ TEST (node, rep_weight) auto & node1 = *add_node (); auto & node2 = *add_node (); auto & node3 = *add_node (); - nano::genesis genesis; nano::keypair keypair1; nano::keypair keypair2; nano::block_builder builder; @@ -2136,12 +2125,12 @@ TEST (node, rep_weight) std::shared_ptr block1 = builder .state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - amount_not_pr) + .balance (nano::dev::constants.genesis_amount - amount_not_pr) .link (keypair1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build (); std::shared_ptr block2 = builder .state () @@ -2158,7 +2147,7 @@ TEST (node, rep_weight) .account (nano::dev::genesis_key.pub) .previous (block1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - amount_not_pr - amount_pr) + .balance (nano::dev::constants.genesis_amount - amount_not_pr - amount_pr) .link (keypair2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (block1->hash ())) @@ -2187,9 +2176,9 @@ TEST (node, rep_weight) ASSERT_NE (nullptr, channel2); std::shared_ptr channel3 = nano::establish_tcp (system, node, node3.network.endpoint ()); ASSERT_NE (nullptr, channel3); - auto vote0 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, genesis.open); - auto vote1 = std::make_shared (keypair1.pub, keypair1.prv, 0, genesis.open); - auto vote2 = std::make_shared (keypair2.pub, keypair2.prv, 0, genesis.open); + auto vote0 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, nano::dev::genesis); + auto vote1 = std::make_shared (keypair1.pub, keypair1.prv, 0, nano::dev::genesis); + auto vote2 = std::make_shared (keypair2.pub, keypair2.prv, 0, nano::dev::genesis); node.rep_crawler.response (channel1, vote0); node.rep_crawler.response (channel2, vote1); node.rep_crawler.response (channel3, vote2); @@ -2211,19 +2200,18 @@ TEST (node, rep_remove) nano::node_flags node_flags; node_flags.disable_udp = false; auto & node = *system.add_node (node_flags); - nano::genesis genesis; nano::keypair keypair1; nano::keypair keypair2; nano::block_builder builder; std::shared_ptr block1 = builder .state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - node.minimum_principal_weight () * 2) + .balance (nano::dev::constants.genesis_amount - node.minimum_principal_weight () * 2) .link (keypair1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build (); std::shared_ptr block2 = builder .state () @@ -2240,7 +2228,7 @@ TEST (node, rep_remove) .account (nano::dev::genesis_key.pub) .previous (block1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - node.minimum_principal_weight () * 4) + .balance (nano::dev::constants.genesis_amount - node.minimum_principal_weight () * 4) .link (keypair2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (block1->hash ())) @@ -2266,7 +2254,7 @@ TEST (node, rep_remove) nano::endpoint endpoint0 (boost::asio::ip::address_v6::loopback (), nano::get_available_port ()); std::shared_ptr channel0 (std::make_shared (node.network.udp_channels, endpoint0, node.network_params.protocol.protocol_version)); auto channel_udp = node.network.udp_channels.insert (endpoint0, node.network_params.protocol.protocol_version); - auto vote1 = std::make_shared (keypair1.pub, keypair1.prv, 0, genesis.open); + auto vote1 = std::make_shared (keypair1.pub, keypair1.prv, 0, nano::dev::genesis); ASSERT_FALSE (node.rep_crawler.response (channel0, vote1)); ASSERT_TIMELY (5s, node.rep_crawler.representative_count () == 1); auto reps (node.rep_crawler.representatives (1)); @@ -2287,13 +2275,13 @@ TEST (node, rep_remove) system.wallet (1)->insert_adhoc (nano::dev::genesis_key.prv); auto channel1 (node.network.find_channel (node1->network.endpoint ())); ASSERT_NE (nullptr, channel1); - auto vote2 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, genesis.open); + auto vote2 = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, nano::dev::genesis); node.rep_crawler.response (channel1, vote2); ASSERT_TIMELY (10s, node.rep_crawler.representative_count () == 1); // Add inactive TCP representative channel auto node2 (std::make_shared (system.io_ctx, nano::unique_path (), nano::node_config (nano::get_available_port (), system.logging), system.work)); std::weak_ptr node_w (node.shared ()); - auto vote3 = std::make_shared (keypair2.pub, keypair2.prv, 0, genesis.open); + auto vote3 = std::make_shared (keypair2.pub, keypair2.prv, 0, nano::dev::genesis); node.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w, &vote3] (std::shared_ptr const & channel2) { if (auto node_l = node_w.lock ()) { @@ -2477,11 +2465,11 @@ TEST (node, online_reps) auto vote (std::make_shared ()); ASSERT_EQ (0, node1.online_reps.online ()); node1.online_reps.observe (nano::dev::genesis_key.pub); - ASSERT_EQ (nano::dev::genesis_amount, node1.online_reps.online ()); + ASSERT_EQ (nano::dev::constants.genesis_amount, node1.online_reps.online ()); // 1 minimum, 1 maximum ASSERT_EQ (node1.config.online_weight_minimum, node1.online_reps.trended ()); node1.online_reps.sample (); - ASSERT_EQ (nano::dev::genesis_amount, node1.online_reps.trended ()); + ASSERT_EQ (nano::dev::constants.genesis_amount, node1.online_reps.trended ()); node1.online_reps.clear (); // 2 minimum, 1 maximum node1.online_reps.sample (); @@ -2507,7 +2495,7 @@ TEST (node, online_reps_rep_crawler) node1.rep_crawler.active.insert (nano::dev::genesis->hash ()); } node1.vote_processor.vote_blocking (vote, std::make_shared (node1)); - ASSERT_EQ (nano::dev::genesis_amount, node1.online_reps.online ()); + ASSERT_EQ (nano::dev::constants.genesis_amount, node1.online_reps.online ()); } } @@ -2518,17 +2506,16 @@ TEST (node, online_reps_election) flags.disable_rep_crawler = true; auto & node1 = *system.add_node (flags); // Start election - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1.work_generate_blocking (genesis.hash ())) + .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); node1.block_processor.flush (); @@ -2538,7 +2525,7 @@ TEST (node, online_reps_election) auto vote = std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::milliseconds_since_epoch (), std::vector{ send1->hash () }); ASSERT_EQ (0, node1.online_reps.online ()); node1.vote_processor.vote_blocking (vote, std::make_shared (node1)); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, node1.online_reps.online ()); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, node1.online_reps.online ()); } TEST (node, block_confirm) @@ -2556,18 +2543,17 @@ TEST (node, block_confirm) nano::system system (2, type, node_flags); auto & node1 (*system.nodes[0]); auto & node2 (*system.nodes[1]); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; system.wallet (1)->insert_adhoc (nano::dev::genesis_key.prv); auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1.work_generate_blocking (genesis.hash ())) + .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); // A copy is necessary to avoid data races during ledger processing, which sets the sideband auto send1_copy = builder.make_block () @@ -2637,18 +2623,17 @@ TEST (node, confirm_quorum) { nano::system system (1); auto & node1 = *system.nodes[0]; - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); // Put greater than node.delta () in pending so quorum can't be reached nano::amount new_balance = node1.online_reps.delta () - nano::Gxrb_ratio; auto send1 = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .balance (new_balance) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1.work_generate_blocking (genesis.hash ())) + .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, new_balance.number ()); @@ -2665,24 +2650,23 @@ TEST (node, local_votes_cache) nano::system system; nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; - node_config.receive_minimum = nano::dev::genesis_amount; + node_config.receive_minimum = nano::dev::constants.genesis_amount; auto & node (*system.add_node (node_config)); - nano::genesis genesis; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -2691,7 +2675,7 @@ TEST (node, local_votes_cache) .account (nano::dev::genesis_key.pub) .previous (send2->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 3 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send2->hash ())) @@ -2753,17 +2737,16 @@ TEST (node, local_votes_cache_batch) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); ASSERT_GE (node.network_params.voting.max_cache, 2); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; auto send1 = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); node.confirmation_height_processor.add (send1); @@ -2772,7 +2755,7 @@ TEST (node, local_votes_cache_batch) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -2822,30 +2805,29 @@ TEST (node, local_votes_cache_generate_new_vote) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); // Repsond with cached vote - nano::confirm_req message1 (genesis.open); + nano::confirm_req message1 (nano::dev::genesis); auto channel (node.network.udp_channels.create (node.network.endpoint ())); node.network.inbound (message1, channel); - ASSERT_TIMELY (3s, !node.history.votes (genesis.open->root (), genesis.open->hash ()).empty ()); - auto votes1 (node.history.votes (genesis.open->root (), genesis.open->hash ())); + ASSERT_TIMELY (3s, !node.history.votes (nano::dev::genesis->root (), nano::dev::genesis->hash ()).empty ()); + auto votes1 (node.history.votes (nano::dev::genesis->root (), nano::dev::genesis->hash ())); ASSERT_EQ (1, votes1.size ()); ASSERT_EQ (1, votes1[0]->blocks.size ()); - ASSERT_EQ (genesis.open->hash (), boost::get (votes1[0]->blocks[0])); + ASSERT_EQ (nano::dev::genesis->hash (), boost::get (votes1[0]->blocks[0])); ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::requests, nano::stat::detail::requests_generated_votes) == 1); auto send1 = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node.process (*send1).code); // One of the hashes is cached - std::vector> roots_hashes{ std::make_pair (genesis.open->hash (), genesis.open->root ()), std::make_pair (send1->hash (), send1->root ()) }; + std::vector> roots_hashes{ std::make_pair (nano::dev::genesis->hash (), nano::dev::genesis->root ()), std::make_pair (send1->hash (), send1->root ()) }; nano::confirm_req message2 (roots_hashes); node.network.inbound (message2, channel); ASSERT_TIMELY (3s, !node.history.votes (send1->root (), send1->hash ()).empty ()); @@ -2853,7 +2835,7 @@ TEST (node, local_votes_cache_generate_new_vote) ASSERT_EQ (1, votes2.size ()); ASSERT_EQ (1, votes2[0]->blocks.size ()); ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::requests, nano::stat::detail::requests_generated_votes) == 2); - ASSERT_FALSE (node.history.votes (genesis.open->root (), genesis.open->hash ()).empty ()); + ASSERT_FALSE (node.history.votes (nano::dev::genesis->root (), nano::dev::genesis->hash ()).empty ()); ASSERT_FALSE (node.history.votes (send1->root (), send1->hash ()).empty ()); // First generated + again cached + new generated ASSERT_TIMELY (3s, 3 == node.stats.count (nano::stat::type::message, nano::stat::detail::confirm_ack, nano::stat::dir::out)); @@ -2872,25 +2854,24 @@ TEST (node, local_votes_cache_fork) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node1 (*system.add_node (node_config, node_flags)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto send1 = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node1.work_generate_blocking (genesis.hash ())) + .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto send1_fork = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1.work_generate_blocking (genesis.hash ())) + .work (*node1.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1.process (*send1).code); // Cache vote @@ -2916,21 +2897,20 @@ TEST (node, vote_republish) nano::keypair key2; // by not setting a private key on node1's wallet, it is stopped from voting system.wallet (1)->insert_adhoc (key2.prv); - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number () * 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); ASSERT_TIMELY (5s, node2.block (send1->hash ())); @@ -2959,7 +2939,7 @@ TEST (node, vote_by_hash_bundle) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .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 ())) @@ -2971,7 +2951,7 @@ TEST (node, vote_by_hash_bundle) auto block = builder.make_block () .from (*blocks.back ()) .previous (blocks.back ()->hash ()) - .balance (nano::dev::genesis_amount - i) + .balance (nano::dev::constants.genesis_amount - i) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (blocks.back ()->hash ())) .build_shared (); @@ -3010,21 +2990,20 @@ TEST (node, vote_by_hash_republish) auto & node2 = *system.nodes[1]; nano::keypair key2; system.wallet (1)->insert_adhoc (key2.prv); - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number () * 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); ASSERT_TIMELY (5s, node2.active.active (*send1)); @@ -3050,22 +3029,21 @@ TEST (node, vote_by_hash_epoch_block_republish) auto & node2 (*system.nodes[1]); nano::keypair key2; system.wallet (1)->insert_adhoc (key2.prv); - nano::genesis genesis; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto epoch1 = nano::state_block_builder () .account (nano::dev::genesis->account ()) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .link (node1.ledger.epoch_link (nano::epoch::epoch_1)) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); node1.process_active (send1); ASSERT_TIMELY (5s, node2.active.active (*send1)); @@ -3091,17 +3069,16 @@ TEST (node, epoch_conflict_confirm) node_config.peering_port = nano::get_available_port (); auto node1 = system.add_node (node_config); nano::keypair key; - nano::genesis genesis; nano::keypair epoch_signer (nano::dev::genesis_key); nano::state_block_builder builder; auto send = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto open = builder.make_block () .account (key.pub) @@ -3125,7 +3102,7 @@ TEST (node, epoch_conflict_confirm) .account (nano::dev::genesis_key.pub) .previous (send->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .link (open->hash ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (send->hash ())) @@ -3188,21 +3165,20 @@ TEST (node, fork_invalid_block_signature) auto & node1 (*system.add_node (node_flags)); auto & node2 (*system.add_node (node_flags)); nano::keypair key2; - nano::genesis genesis; nano::send_block_builder builder; auto send1 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key2.pub) .balance (std::numeric_limits::max () - node1.config.receive_minimum.number () * 2) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2_corrupt (std::make_shared (*send2)); send2_corrupt->signature = nano::signature (123); @@ -3226,33 +3202,32 @@ TEST (node, fork_election_invalid_block_signature) { nano::system system (1); auto & node1 (*system.nodes[0]); - nano::genesis genesis; nano::block_builder builder; auto send1 = builder.state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .build_shared (); auto send2 = builder.state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .build_shared (); auto send3 = builder.state () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .sign (nano::dev::genesis_key.prv, 0) // Invalid signature .build_shared (); auto channel1 (node1.network.udp_channels.create (node1.network.endpoint ())); @@ -3281,7 +3256,7 @@ TEST (node, block_processor_signatures) .account (nano::dev::genesis_key.pub) .previous (latest) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1.work_generate_blocking (latest)) @@ -3290,7 +3265,7 @@ TEST (node, block_processor_signatures) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key2.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1.work_generate_blocking (send1->hash ())) @@ -3299,7 +3274,7 @@ TEST (node, block_processor_signatures) .account (nano::dev::genesis_key.pub) .previous (send2->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 3 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio) .link (key3.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1.work_generate_blocking (send2->hash ())) @@ -3309,7 +3284,7 @@ TEST (node, block_processor_signatures) .account (nano::dev::genesis_key.pub) .previous (send3->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 4 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 4 * nano::Gxrb_ratio) .link (key3.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1.work_generate_blocking (send3->hash ())) @@ -3320,7 +3295,7 @@ TEST (node, block_processor_signatures) .account (nano::dev::genesis_key.pub) .previous (send3->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 5 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 5 * nano::Gxrb_ratio) .link (key3.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1.work_generate_blocking (send3->hash ())) @@ -3388,16 +3363,15 @@ TEST (node, block_processor_reject_state) { nano::system system (1); auto & node (*system.nodes[0]); - nano::genesis genesis; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); send1->signature.bytes[0] ^= 1; ASSERT_FALSE (node.ledger.block_or_pruned_exists (send1->hash ())); @@ -3407,12 +3381,12 @@ TEST (node, block_processor_reject_state) ASSERT_FALSE (node.ledger.block_or_pruned_exists (send1->hash ())); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); node.process_active (send2); auto flushed2 = std::async (std::launch::async, [&node] { node.block_processor.flush (); }); @@ -3427,22 +3401,21 @@ TEST (node, block_processor_full) node_flags.force_use_write_database_queue = true; node_flags.block_processor_full_size = 3; auto & node = *system.add_node (nano::node_config (nano::get_available_port (), system.logging), node_flags); - nano::genesis genesis; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -3451,7 +3424,7 @@ TEST (node, block_processor_full) .account (nano::dev::genesis_key.pub) .previous (send2->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 3 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send2->hash ())) @@ -3474,22 +3447,21 @@ TEST (node, block_processor_half_full) node_flags.block_processor_full_size = 6; node_flags.force_use_write_database_queue = true; auto & node = *system.add_node (nano::node_config (nano::get_available_port (), system.logging), node_flags); - nano::genesis genesis; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); auto send2 = builder.make_block () .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -3498,7 +3470,7 @@ TEST (node, block_processor_half_full) .account (nano::dev::genesis_key.pub) .previous (send2->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 3 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send2->hash ())) @@ -3520,14 +3492,13 @@ TEST (node, confirm_back) nano::system system (1); nano::keypair key; auto & node (*system.nodes[0]); - nano::genesis genesis; auto genesis_start_balance (node.balance (nano::dev::genesis_key.pub)); auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key.pub) .balance (genesis_start_balance - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); nano::state_block_builder builder; auto open = builder.make_block () @@ -3723,7 +3694,6 @@ TEST (node, dont_write_lock_node) nano::logger_mt logger; auto store = nano::make_store (logger, path, false, true); { - nano::genesis genesis; nano::ledger_cache ledger_cache; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger_cache); @@ -3776,17 +3746,16 @@ TEST (node, bidirectional_tcp) ASSERT_EQ (node1->network.endpoint (), list2[0]->get_endpoint ()); ASSERT_EQ (node1->node_id.pub, list2[0]->get_node_id ()); // Test block propagation from node 1 - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node1->work_generate_blocking (genesis.hash ())) + .work (*node1->work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); node1->process_active (send1); node1->block_processor.flush (); @@ -3817,7 +3786,7 @@ TEST (node, bidirectional_tcp) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node1->work_generate_blocking (send1->hash ())) @@ -3877,7 +3846,7 @@ TEST (node, aggressive_flooding) ASSERT_TIMELY (10s, std::all_of (nodes_wallets.begin (), nodes_wallets.end (), [] (auto const & node_wallet) { return node_wallet.first->rep_crawler.principal_representatives ().size () != 0; })); // Send a large amount to create a principal representative in each node - auto large_amount = (nano::dev::genesis_amount / 2) / nodes_wallets.size (); + auto large_amount = (nano::dev::constants.genesis_amount / 2) / nodes_wallets.size (); std::vector> genesis_blocks; for (auto & node_wallet : nodes_wallets) { @@ -3977,7 +3946,7 @@ TEST (node, rollback_vote_self) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - weight) + .balance (nano::dev::constants.genesis_amount - weight) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -4066,7 +4035,7 @@ TEST (node, rollback_gap_source) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -4163,7 +4132,7 @@ TEST (node, dependency_graph) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key1.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -4192,7 +4161,7 @@ TEST (node, dependency_graph) .from (*gen_send1) .previous (gen_send1->hash ()) .link (key1_send1->hash ()) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (gen_send1->hash ())) .build (); @@ -4365,7 +4334,7 @@ TEST (node, dependency_graph_frontier) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key1.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -4394,7 +4363,7 @@ TEST (node, dependency_graph_frontier) .from (*gen_send1) .previous (gen_send1->hash ()) .link (key1_send1->hash ()) - .balance (nano::dev::genesis_amount) + .balance (nano::dev::constants.genesis_amount) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (gen_send1->hash ())) .build (); @@ -4528,7 +4497,7 @@ TEST (node, deferred_dependent_elections) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) .link (key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); @@ -4659,7 +4628,7 @@ TEST (rep_crawler, recently_confirmed) nano::system system (1); auto & node1 (*system.nodes[0]); ASSERT_EQ (1, node1.ledger.cache.block_count); - auto const block = nano::genesis ().open; + auto const block = nano::dev::genesis; node1.active.add_recently_confirmed (block->qualified_root (), block->hash ()); auto & node2 (*system.add_node ()); system.wallet (1)->insert_adhoc (nano::dev::genesis_key.prv); @@ -4698,14 +4667,13 @@ TEST (node, pruning_automatic) nano::node_flags node_flags; node_flags.enable_pruning = true; auto & node1 = *system.add_node (node_config, node_flags); - nano::genesis genesis; nano::keypair key1; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = nano::send_block_builder () .previous (send1->hash ()) @@ -4738,7 +4706,7 @@ TEST (node, pruning_automatic) ASSERT_TIMELY (2s, node1.store.pruned.count (node1.store.tx_begin_read ()) == 1); // Transaction commit ASSERT_EQ (1, node1.ledger.cache.pruned_count); ASSERT_EQ (3, node1.ledger.cache.block_count); - ASSERT_TRUE (node1.ledger.block_or_pruned_exists (genesis.hash ())); + ASSERT_TRUE (node1.ledger.block_or_pruned_exists (nano::dev::genesis->hash ())); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send1->hash ())); // true for pruned ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send2->hash ())); } @@ -4751,14 +4719,13 @@ TEST (node, pruning_age) nano::node_flags node_flags; node_flags.enable_pruning = true; auto & node1 = *system.add_node (node_config, node_flags); - nano::genesis genesis; nano::keypair key1; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = nano::send_block_builder () .previous (send1->hash ()) @@ -4795,7 +4762,7 @@ TEST (node, pruning_age) node1.ledger_pruning (1, true, false); ASSERT_EQ (1, node1.ledger.cache.pruned_count); ASSERT_EQ (3, node1.ledger.cache.block_count); - ASSERT_TRUE (node1.ledger.block_or_pruned_exists (genesis.hash ())); + ASSERT_TRUE (node1.ledger.block_or_pruned_exists (nano::dev::genesis->hash ())); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send1->hash ())); // true for pruned ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send2->hash ())); } @@ -4808,14 +4775,13 @@ TEST (node, pruning_depth) nano::node_flags node_flags; node_flags.enable_pruning = true; auto & node1 = *system.add_node (node_config, node_flags); - nano::genesis genesis; nano::keypair key1; auto send1 = nano::send_block_builder () - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .destination (key1.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); auto send2 = nano::send_block_builder () .previous (send1->hash ()) @@ -4848,7 +4814,7 @@ TEST (node, pruning_depth) node1.ledger_pruning (1, true, false); ASSERT_EQ (1, node1.ledger.cache.pruned_count); ASSERT_EQ (3, node1.ledger.cache.block_count); - ASSERT_TRUE (node1.ledger.block_or_pruned_exists (genesis.hash ())); + ASSERT_TRUE (node1.ledger.block_or_pruned_exists (nano::dev::genesis->hash ())); ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send1->hash ())); // true for pruned ASSERT_TRUE (node1.ledger.block_or_pruned_exists (send2->hash ())); } diff --git a/nano/core_test/processor_service.cpp b/nano/core_test/processor_service.cpp index 9d93cddd19..aa5b98d6a7 100644 --- a/nano/core_test/processor_service.cpp +++ b/nano/core_test/processor_service.cpp @@ -14,7 +14,6 @@ TEST (processor_service, bad_send_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); @@ -33,7 +32,6 @@ TEST (processor_service, bad_receive_signature) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); diff --git a/nano/core_test/request_aggregator.cpp b/nano/core_test/request_aggregator.cpp index 664ddd6a96..a8ca77e15a 100644 --- a/nano/core_test/request_aggregator.cpp +++ b/nano/core_test/request_aggregator.cpp @@ -13,9 +13,8 @@ TEST (request_aggregator, one) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (nano::dev::genesis->hash ()))); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); auto channel (node.network.udp_channels.create (node.network.endpoint ())); @@ -49,18 +48,17 @@ TEST (request_aggregator, one_update) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; auto send1 = nano::state_block_builder () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); node.confirmation_height_processor.add (send1); @@ -69,7 +67,7 @@ TEST (request_aggregator, one_update) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -115,18 +113,17 @@ TEST (request_aggregator, two) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key1; nano::state_block_builder builder; auto send1 = builder.make_block () .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .link (key1.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*node.work_generate_blocking (genesis.hash ())) + .work (*node.work_generate_blocking (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); node.confirmation_height_processor.add (send1); @@ -135,7 +132,7 @@ TEST (request_aggregator, two) .account (nano::dev::genesis_key.pub) .previous (send1->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2) + .balance (nano::dev::constants.genesis_amount - 2) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*node.work_generate_blocking (send1->hash ())) @@ -192,9 +189,8 @@ TEST (request_aggregator, two_endpoints) auto & node1 (*system.add_node (node_config, node_flags)); node_config.peering_port = nano::get_available_port (); auto & node2 (*system.add_node (node_config, node_flags)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 1, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 1, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1.work_generate_blocking (nano::dev::genesis->hash ()))); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); ASSERT_EQ (nano::process_result::progress, node1.ledger.process (node1.store.tx_begin_write (), *send1).code); @@ -224,11 +220,10 @@ TEST (request_aggregator, split) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); std::vector> request; std::vector> blocks; - auto previous = genesis.hash (); + auto previous = nano::dev::genesis->hash (); // Add max_vbh + 1 blocks and request votes for them for (size_t i (0); i <= max_vbh; ++i) { @@ -238,7 +233,7 @@ TEST (request_aggregator, split) .account (nano::dev::genesis_key.pub) .previous (previous) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - (i + 1)) + .balance (nano::dev::constants.genesis_amount - (i + 1)) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (previous)) @@ -278,9 +273,8 @@ TEST (request_aggregator, channel_lifetime) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (nano::dev::genesis->hash ()))); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); @@ -299,9 +293,8 @@ TEST (request_aggregator, channel_update) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (nano::dev::genesis->hash ()))); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); @@ -328,9 +321,8 @@ TEST (request_aggregator, channel_max_queue) node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; node_config.max_queued_requests = 1; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (nano::dev::genesis->hash ()))); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); @@ -346,9 +338,8 @@ TEST (request_aggregator, unique) nano::node_config node_config (nano::get_available_port (), system.logging); node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; auto & node (*system.add_node (node_config)); - nano::genesis genesis; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node.work_generate_blocking (nano::dev::genesis->hash ()))); ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code); std::vector> request; request.emplace_back (send1->hash (), send1->root ()); @@ -371,13 +362,12 @@ TEST (request_aggregator, cannot_vote) auto & node (*system.add_node (flags)); // This prevents activation of blocks which are cemented node.confirmation_height_processor.cemented_observers.clear (); - nano::genesis genesis; 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::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .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 ())) diff --git a/nano/core_test/system.cpp b/nano/core_test/system.cpp index 446e185f1a..015a81ddc7 100644 --- a/nano/core_test/system.cpp +++ b/nano/core_test/system.cpp @@ -29,7 +29,7 @@ TEST (system, system_genesis) for (auto & i : system.nodes) { auto transaction (i->store.tx_begin_read ()); - ASSERT_EQ (nano::dev::genesis_amount, i->ledger.account_balance (transaction, nano::dev::genesis->account ())); + ASSERT_EQ (nano::dev::constants.genesis_amount, i->ledger.account_balance (transaction, nano::dev::genesis->account ())); } } @@ -40,7 +40,7 @@ TEST (system, DISABLED_generate_send_existing) nano::thread_runner runner (system.io_ctx, node1.config.io_threads); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair stake_preserver; - auto send_block (system.wallet (0)->send_action (nano::dev::genesis->account (), stake_preserver.pub, nano::dev::genesis_amount / 3 * 2, true)); + auto send_block (system.wallet (0)->send_action (nano::dev::genesis->account (), stake_preserver.pub, nano::dev::constants.genesis_amount / 3 * 2, true)); nano::account_info info1; { auto transaction (node1.store.tx_begin_read ()); @@ -71,7 +71,7 @@ TEST (system, DISABLED_generate_send_existing) ASSERT_FALSE (node1.store.account.get (transaction, nano::dev::genesis_key.pub, info2)); } ASSERT_EQ (info1.block_count + 2, info2.block_count); - ASSERT_EQ (info2.balance, nano::dev::genesis_amount / 3); + ASSERT_EQ (info2.balance, nano::dev::constants.genesis_amount / 3); { auto transaction (node1.store.tx_begin_read ()); ASSERT_NE (node1.ledger.amount (transaction, info2.head), 0); @@ -94,7 +94,7 @@ TEST (system, DISABLED_generate_send_new) ASSERT_EQ (node1.store.account.end (), iterator1); } nano::keypair stake_preserver; - auto send_block (system.wallet (0)->send_action (nano::dev::genesis->account (), stake_preserver.pub, nano::dev::genesis_amount / 3 * 2, true)); + auto send_block (system.wallet (0)->send_action (nano::dev::genesis->account (), stake_preserver.pub, nano::dev::constants.genesis_amount / 3 * 2, true)); { auto transaction (node1.store.tx_begin_write ()); auto open_block (std::make_shared (send_block->hash (), nano::dev::genesis->account (), stake_preserver.pub, stake_preserver.prv, stake_preserver.pub, 0)); @@ -136,7 +136,7 @@ TEST (system, rep_initialize_one) nano::keypair key; system.ledger_initialization_set ({ key }); auto node = system.add_node (); - ASSERT_EQ (nano::dev::genesis_amount, node->balance (key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount, node->balance (key.pub)); } TEST (system, rep_initialize_two) @@ -146,8 +146,8 @@ TEST (system, rep_initialize_two) nano::keypair key1; system.ledger_initialization_set ({ key0, key1 }); auto node = system.add_node (); - ASSERT_EQ (nano::dev::genesis_amount / 2, node->balance (key0.pub)); - ASSERT_EQ (nano::dev::genesis_amount / 2, node->balance (key1.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount / 2, node->balance (key0.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount / 2, node->balance (key1.pub)); } TEST (system, rep_initialize_one_reserve) @@ -156,7 +156,7 @@ TEST (system, rep_initialize_one_reserve) nano::keypair key; system.ledger_initialization_set ({ key }, nano::Gxrb_ratio); auto node = system.add_node (); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio, node->balance (key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio, node->balance (key.pub)); ASSERT_EQ (nano::Gxrb_ratio, node->balance (nano::dev::genesis_key.pub)); } @@ -167,8 +167,8 @@ TEST (system, rep_initialize_two_reserve) nano::keypair key1; system.ledger_initialization_set ({ key0, key1 }, nano::Gxrb_ratio); auto node = system.add_node (); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node->balance (key0.pub)); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node->balance (key1.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node->balance (key0.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node->balance (key1.pub)); } TEST (system, rep_initialize_many) @@ -178,9 +178,9 @@ TEST (system, rep_initialize_many) nano::keypair key1; system.ledger_initialization_set ({ key0, key1 }, nano::Gxrb_ratio); auto node0 = system.add_node (); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node0->balance (key0.pub)); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node0->balance (key1.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node0->balance (key0.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node0->balance (key1.pub)); auto node1 = system.add_node (); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node1->balance (key0.pub)); - ASSERT_EQ ((nano::dev::genesis_amount - nano::Gxrb_ratio) / 2, node1->balance (key1.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node1->balance (key0.pub)); + ASSERT_EQ ((nano::dev::constants.genesis_amount - nano::Gxrb_ratio) / 2, node1->balance (key1.pub)); } diff --git a/nano/core_test/vote_processor.cpp b/nano/core_test/vote_processor.cpp index b89f7e94c9..b81d53e5f9 100644 --- a/nano/core_test/vote_processor.cpp +++ b/nano/core_test/vote_processor.cpp @@ -11,9 +11,8 @@ TEST (vote_processor, codes) { nano::system system (1); auto & node (*system.nodes[0]); - nano::genesis genesis; nano::keypair key; - auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ genesis.open->hash () })); + auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ nano::dev::genesis->hash () })); auto vote_invalid = std::make_shared (*vote); vote_invalid->signature.bytes[0] ^= 1; auto channel (std::make_shared (node)); @@ -28,9 +27,8 @@ TEST (vote_processor, codes) ASSERT_EQ (nano::vote_code::indeterminate, node.vote_processor.vote_blocking (vote, channel)); // First vote from an account for an ongoing election - genesis.open->sideband_set (nano::block_sideband (nano::dev::genesis->account (), 0, nano::dev::genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); - node.block_confirm (genesis.open); - ASSERT_NE (nullptr, node.active.election (genesis.open->qualified_root ())); + node.block_confirm (nano::dev::genesis); + ASSERT_NE (nullptr, node.active.election (nano::dev::genesis->qualified_root ())); ASSERT_EQ (nano::vote_code::vote, node.vote_processor.vote_blocking (vote, channel)); // Processing the same vote is a replay @@ -46,7 +44,7 @@ TEST (vote_processor, codes) ASSERT_EQ (nano::vote_code::vote, node.vote_processor.vote_blocking (vote, channel)); // Once the election is removed (confirmed / dropped) the vote is again indeterminate - node.active.erase (*genesis.open); + node.active.erase (*nano::dev::genesis); ASSERT_EQ (nano::vote_code::indeterminate, node.vote_processor.vote_blocking (vote, channel)); } @@ -54,8 +52,7 @@ TEST (vote_processor, flush) { nano::system system (1); auto & node (*system.nodes[0]); - nano::genesis genesis; - auto vote (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1, std::vector{ genesis.open->hash () })); + auto vote (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 1, std::vector{ nano::dev::genesis->hash () })); auto channel (std::make_shared (node)); for (unsigned i = 0; i < 2000; ++i) { @@ -71,16 +68,14 @@ TEST (vote_processor, invalid_signature) { nano::system system{ 1 }; auto & node = *system.nodes[0]; - nano::genesis genesis; nano::keypair key; - auto vote = std::make_shared (key.pub, key.prv, 1, std::vector{ genesis.open->hash () }); + auto vote = std::make_shared (key.pub, key.prv, 1, std::vector{ nano::dev::genesis->hash () }); auto vote_invalid = std::make_shared (*vote); vote_invalid->signature.bytes[0] ^= 1; auto channel = std::make_shared (node); - genesis.open->sideband_set (nano::block_sideband (nano::dev::genesis->account (), 0, nano::dev::genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); - node.block_confirm (genesis.open); - auto election = node.active.election (genesis.open->qualified_root ()); + node.block_confirm (nano::dev::genesis); + auto election = node.active.election (nano::dev::genesis->qualified_root ()); ASSERT_TRUE (election); ASSERT_EQ (1, election->votes ().size ()); node.vote_processor.vote (vote_invalid, channel); @@ -97,9 +92,8 @@ TEST (vote_processor, no_capacity) nano::node_flags node_flags; node_flags.vote_processor_capacity = 0; auto & node (*system.add_node (node_flags)); - nano::genesis genesis; nano::keypair key; - auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ genesis.open->hash () })); + auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ nano::dev::genesis->hash () })); auto channel (std::make_shared (node)); ASSERT_TRUE (node.vote_processor.vote (vote, channel)); } @@ -110,9 +104,8 @@ TEST (vote_processor, overflow) nano::node_flags node_flags; node_flags.vote_processor_capacity = 1; auto & node (*system.add_node (node_flags)); - nano::genesis genesis; nano::keypair key; - auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ genesis.open->hash () })); + auto vote (std::make_shared (key.pub, key.prv, 1, std::vector{ nano::dev::genesis->hash () })); auto channel (std::make_shared (node)); // No way to lock the processor, but queueing votes in quick succession must result in overflow @@ -262,14 +255,14 @@ TEST (vote_processor, no_broadcast_local) .account (key.pub) .representative (nano::dev::genesis_key.pub) .previous (0) - .balance (nano::dev::genesis_amount - 2 * node.config.vote_minimum.number ()) + .balance (nano::dev::constants.genesis_amount - 2 * node.config.vote_minimum.number ()) .link (send->hash ()) .sign (key.prv, key.pub) .work (*system.work.generate (key.pub)) .build (ec); ASSERT_FALSE (ec); ASSERT_EQ (nano::process_result::progress, node.process_local (open).code); - ASSERT_EQ (nano::dev::genesis_amount - node.config.vote_minimum.number (), node.weight (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - node.config.vote_minimum.number (), node.weight (nano::dev::genesis_key.pub)); node.block_confirm (open); // Insert account in wallet system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); diff --git a/nano/core_test/voting.cpp b/nano/core_test/voting.cpp index be22842475..bf6cbedcbc 100644 --- a/nano/core_test/voting.cpp +++ b/nano/core_test/voting.cpp @@ -168,7 +168,7 @@ TEST (vote_spacing, vote_generator) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 ())) @@ -177,7 +177,7 @@ TEST (vote_spacing, vote_generator) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio - 1) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 1) .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 ())) @@ -211,7 +211,7 @@ TEST (vote_spacing, rapid) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .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 ())) @@ -220,7 +220,7 @@ TEST (vote_spacing, rapid) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio - 1) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 1) .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 ())) diff --git a/nano/core_test/wallet.cpp b/nano/core_test/wallet.cpp index ec504d7d44..99a8779114 100644 --- a/nano/core_test/wallet.cpp +++ b/nano/core_test/wallet.cpp @@ -169,7 +169,7 @@ TEST (wallet, insufficient_spend_one) system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, 500)); ASSERT_NE (nullptr, block); - ASSERT_EQ (nullptr, system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, nano::dev::genesis_amount)); + ASSERT_EQ (nullptr, system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, nano::dev::constants.genesis_amount)); } TEST (wallet, spend_all_one) @@ -636,7 +636,7 @@ TEST (wallet, work) nano::system system (1); auto wallet (system.wallet (0)); wallet->insert_adhoc (nano::dev::genesis_key.prv); - nano::genesis genesis; + wallet->insert_adhoc (nano::dev::genesis_key.prv); auto done (false); system.deadline_set (20s); while (!done) @@ -645,7 +645,7 @@ TEST (wallet, work) uint64_t work (0); if (!wallet->store.work_get (transaction, nano::dev::genesis_key.pub, work)) { - done = nano::work_difficulty (genesis.open->work_version (), genesis.hash (), work) >= system.nodes[0]->default_difficulty (genesis.open->work_version ()); + done = nano::work_difficulty (nano::dev::genesis->work_version (), nano::dev::genesis->hash (), work) >= system.nodes[0]->default_difficulty (nano::dev::genesis->work_version ()); } ASSERT_NO_ERROR (system.poll ()); } @@ -837,7 +837,7 @@ TEST (wallet, send_race) for (auto i (1); i < 60; ++i) { ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev::genesis_key.pub, key2.pub, nano::Gxrb_ratio)); - ASSERT_EQ (nano::dev::genesis_amount - nano::Gxrb_ratio * i, system.nodes[0]->balance (nano::dev::genesis_key.pub)); + ASSERT_EQ (nano::dev::constants.genesis_amount - nano::Gxrb_ratio * i, system.nodes[0]->balance (nano::dev::genesis_key.pub)); } } @@ -1166,7 +1166,7 @@ TEST (wallet, search_pending) .account (nano::dev::genesis->account ()) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - node.config.receive_minimum.number ()) + .balance (nano::dev::constants.genesis_amount - node.config.receive_minimum.number ()) .link (nano::dev::genesis->account ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) @@ -1193,7 +1193,7 @@ TEST (wallet, search_pending) // Pending search should create the receive block ASSERT_EQ (2, node.ledger.cache.block_count); ASSERT_FALSE (wallet.search_pending (wallet.wallets.tx_begin_read ())); - ASSERT_TIMELY (3s, node.balance (nano::dev::genesis->account ()) == nano::dev::genesis_amount); + ASSERT_TIMELY (3s, node.balance (nano::dev::genesis->account ()) == nano::dev::constants.genesis_amount); auto receive_hash = node.ledger.latest (node.store.tx_begin_read (), nano::dev::genesis->account ()); auto receive = node.block (receive_hash); ASSERT_NE (nullptr, receive); diff --git a/nano/core_test/wallets.cpp b/nano/core_test/wallets.cpp index e7703f995b..2929e15bc2 100644 --- a/nano/core_test/wallets.cpp +++ b/nano/core_test/wallets.cpp @@ -97,8 +97,7 @@ TEST (wallets, vote_minimum) auto & node1 (*system.nodes[0]); nano::keypair key1; nano::keypair key2; - nano::genesis genesis; - nano::state_block send1 (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, std::numeric_limits::max () - node1.config.vote_minimum.number (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ())); + nano::state_block send1 (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, std::numeric_limits::max () - node1.config.vote_minimum.number (), key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, node1.process (send1).code); nano::state_block open1 (key1.pub, 0, key1.pub, node1.config.vote_minimum.number (), send1.hash (), key1.prv, key1.pub, *system.work.generate (key1.pub)); ASSERT_EQ (nano::process_result::progress, node1.process (open1).code); @@ -169,7 +168,7 @@ TEST (wallets, search_pending) .account (nano::dev::genesis->account ()) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis->account ()) - .balance (nano::dev::genesis_amount - node.config.receive_minimum.number ()) + .balance (nano::dev::constants.genesis_amount - node.config.receive_minimum.number ()) .link (nano::dev::genesis->account ()) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (nano::dev::genesis->hash ())) @@ -210,7 +209,7 @@ TEST (wallets, search_pending) { node.wallets.search_pending (wallet_id); } - ASSERT_TIMELY (3s, node.balance (nano::dev::genesis->account ()) == nano::dev::genesis_amount); + ASSERT_TIMELY (3s, node.balance (nano::dev::genesis->account ()) == nano::dev::constants.genesis_amount); auto receive_hash = node.ledger.latest (node.store.tx_begin_read (), nano::dev::genesis->account ()); auto receive = node.block (receive_hash); ASSERT_NE (nullptr, receive); diff --git a/nano/core_test/websocket.cpp b/nano/core_test/websocket.cpp index 90970b34ee..1dc15e078a 100644 --- a/nano/core_test/websocket.cpp +++ b/nano/core_test/websocket.cpp @@ -83,7 +83,7 @@ TEST (websocket, confirmation) nano::keypair key; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - auto balance = nano::dev::genesis_amount; + auto balance = nano::dev::constants.genesis_amount; auto send_amount = node1->online_reps.delta () + 1; // Quick-confirm a block, legacy blocks should work without filtering { @@ -140,8 +140,7 @@ TEST (websocket, stopped_election) // Create election, then erase it, causing a websocket message to be emitted nano::keypair key1; - nano::genesis genesis; - auto send1 (std::make_shared (genesis.hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis->hash (), key1.pub, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); nano::publish publish1 (send1); auto channel1 (node1->network.udp_channels.create (node1->network.endpoint ())); node1->network.inbound (publish1, channel1); @@ -186,7 +185,7 @@ TEST (websocket, confirmation_options) // Confirm a state block for an in-wallet account system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key; - auto balance = nano::dev::genesis_amount; + auto balance = nano::dev::constants.genesis_amount; auto send_amount = node1->online_reps.delta () + 1; nano::block_hash previous (node1->latest (nano::dev::genesis_key.pub)); { @@ -320,7 +319,7 @@ TEST (websocket, confirmation_options_votes) // Confirm a state block for an in-wallet account system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::keypair key; - auto balance = nano::dev::genesis_amount; + auto balance = nano::dev::constants.genesis_amount; auto send_amount = node1->config.online_weight_minimum.number () + 1; nano::block_hash previous (node1->latest (nano::dev::genesis_key.pub)); { @@ -422,7 +421,6 @@ TEST (websocket, confirmation_options_update) // Confirm a block system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); - nano::genesis genesis; nano::keypair key; nano::state_block_builder builder; auto previous (node1->latest (nano::dev::genesis_key.pub)); @@ -430,7 +428,7 @@ TEST (websocket, confirmation_options_update) .account (nano::dev::genesis_key.pub) .previous (previous) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (previous)) @@ -448,7 +446,7 @@ TEST (websocket, confirmation_options_update) .account (nano::dev::genesis_key.pub) .previous (previous) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) + .balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (previous)) @@ -490,7 +488,7 @@ TEST (websocket, vote) .account (nano::dev::genesis_key.pub) .previous (previous) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - (node1->online_reps.delta () + 1)) + .balance (nano::dev::constants.genesis_amount - (node1->online_reps.delta () + 1)) .link (key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) .work (*system.work.generate (previous)) @@ -532,8 +530,7 @@ TEST (websocket, vote_options_type) ASSERT_TIMELY (5s, ack_ready); // Custom made votes for simplicity - nano::genesis genesis; - auto vote (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, genesis.open)); + auto vote (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, 0, nano::dev::genesis)); nano::websocket::message_builder builder; auto msg (builder.vote_received (vote, nano::vote_code::replay)); node1->websocket_server->broadcast (msg); @@ -582,7 +579,7 @@ TEST (websocket, vote_options_representatives) // Quick-confirm a block nano::keypair key; - auto balance = nano::dev::genesis_amount; + auto balance = nano::dev::constants.genesis_amount; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto send_amount = node1->online_reps.delta () + 1; auto confirm_block = [&] () { @@ -913,15 +910,14 @@ TEST (websocket, new_unconfirmed_block) nano::state_block_builder builder; // Process a new block - nano::genesis genesis; auto send1 = builder .account (nano::dev::genesis_key.pub) - .previous (genesis.hash ()) + .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .link (nano::dev::genesis_key.pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) - .work (*system.work.generate (genesis.hash ())) + .work (*system.work.generate (nano::dev::genesis->hash ())) .build_shared (); ASSERT_EQ (nano::process_result::progress, node1->process_local (send1).code); diff --git a/nano/node/bootstrap/bootstrap_lazy.cpp b/nano/node/bootstrap/bootstrap_lazy.cpp index d30a7d1895..e7fa1198d1 100644 --- a/nano/node/bootstrap/bootstrap_lazy.cpp +++ b/nano/node/bootstrap/bootstrap_lazy.cpp @@ -247,7 +247,7 @@ bool nano::bootstrap_attempt_lazy::process_block_lazy (std::shared_ptrsource ().is_zero () && !node->ledger.block_or_pruned_exists (block_a->source ()) && block_a->source () != node->network_params.ledger.genesis_account ()) + if (!block_a->source ().is_zero () && !node->ledger.block_or_pruned_exists (block_a->source ()) && block_a->source () != node->network_params.ledger.genesis->account ()) { lazy_add (block_a->source (), retry_limit); } diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index b8c76d3735..e72153fd2c 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -574,10 +574,10 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map { auto transaction (node.node->store.tx_begin_write ()); auto conf_height_reset_num = 0; - if (account == node.node->network_params.ledger.genesis_account ()) + if (account == node.node->network_params.ledger.genesis->account ()) { conf_height_reset_num = 1; - node.node->store.confirmation_height.put (transaction, account, { confirmation_height_info.height, node.node->network_params.ledger.genesis_hash () }); + node.node->store.confirmation_height.put (transaction, account, { confirmation_height_info.height, node.node->network_params.ledger.genesis->hash () }); } else { @@ -1307,7 +1307,7 @@ void reset_confirmation_heights (nano::write_transaction const & transaction, na // Then make sure the confirmation height of the genesis account open block is 1 nano::network_params network_params; - store.confirmation_height.put (transaction, network_params.ledger.genesis_account (), { 1, network_params.ledger.genesis_hash () }); + store.confirmation_height.put (transaction, network_params.ledger.genesis->account (), { 1, network_params.ledger.genesis->hash () }); } bool is_using_rocksdb (boost::filesystem::path const & data_path, boost::program_options::variables_map const & vm, std::error_code & ec) diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 6e386042ca..9dd69a31aa 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -1041,11 +1041,11 @@ void nano::json_handler::active_difficulty () void nano::json_handler::available_supply () { - auto genesis_balance (node.balance (node.network_params.ledger.genesis_account ())); // Cold storage genesis + auto genesis_balance (node.balance (node.network_params.ledger.genesis->account ())); // Cold storage genesis auto landing_balance (node.balance (nano::account ("059F68AAB29DE0D3A27443625C7EA9CDDB6517A8B76FE37727EF6A4D76832AD5"))); // Active unavailable account auto faucet_balance (node.balance (nano::account ("8E319CE6F3025E5B2DF66DA7AB1467FE48F1679C13DD43BFDB29FA2E9FC40D3B"))); // Faucet account auto burned_balance ((node.balance_pending (nano::account (0), false)).second); // Burning 0 account - auto available (nano::dev::genesis_amount - genesis_balance - landing_balance - faucet_balance - burned_balance); + auto available (nano::dev::constants.genesis_amount - genesis_balance - landing_balance - faucet_balance - burned_balance); response_l.put ("available", available.convert_to ()); response_errors (); } @@ -2318,7 +2318,7 @@ class history_visitor : public nano::block_visitor // Report opens as a receive tree.put ("type", "receive"); } - if (block_a.hashables.source != network_params.ledger.genesis_account ()) + if (block_a.hashables.source != network_params.ledger.genesis->account ()) { bool error_or_pruned (false); auto amount (handler.node.ledger.amount_safe (transaction, hash, error_or_pruned).convert_to ()); @@ -2334,8 +2334,8 @@ class history_visitor : public nano::block_visitor } else { - tree.put ("account", network_params.ledger.genesis_account ().to_account ()); - tree.put ("amount", nano::dev::genesis_amount.convert_to ()); + tree.put ("account", network_params.ledger.genesis->account ().to_account ()); + tree.put ("amount", nano::dev::constants.genesis_amount.convert_to ()); } } void change_block (nano::change_block const & block_a) @@ -3263,7 +3263,7 @@ void nano::json_handler::receive () bool generate_work (work == 0); // Disable work generation if "work" option is provided auto response_a (response); wallet->receive_async ( - hash, representative, nano::dev::genesis_amount, account, [response_a] (std::shared_ptr const & block_a) { + hash, representative, nano::dev::constants.genesis_amount, account, [response_a] (std::shared_ptr const & block_a) { if (block_a != nullptr) { boost::property_tree::ptree response_l; @@ -4146,7 +4146,7 @@ void nano::json_handler::version () response_l.put ("node_vendor", boost::str (boost::format ("Nano %1%") % NANO_VERSION_STRING)); response_l.put ("store_vendor", node.store.vendor_get ()); response_l.put ("network", node.network_params.network.get_current_network_as_string ()); - response_l.put ("network_identifier", node.network_params.ledger.genesis_hash ().to_string ()); + response_l.put ("network_identifier", node.network_params.ledger.genesis->hash ().to_string ()); response_l.put ("build_info", BUILD_INFO); response_errors (); } diff --git a/nano/node/node.cpp b/nano/node/node.cpp index c28a3e57ce..bf740dbf6c 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1318,7 +1318,7 @@ void nano::node::process_confirmed_data (nano::transaction const & transaction_a bool error (false); auto previous_balance (ledger.balance_safe (transaction_a, previous, error)); auto block_balance (store.block.balance_calculated (block_a)); - if (hash_a != ledger.network_params.ledger.genesis_account ()) + if (hash_a != ledger.network_params.ledger.genesis->account ()) { if (!error) { @@ -1331,7 +1331,7 @@ void nano::node::process_confirmed_data (nano::transaction const & transaction_a } else { - amount_a = nano::dev::genesis_amount; + amount_a = nano::dev::constants.genesis_amount; } if (auto state = dynamic_cast (block_a.get ())) { diff --git a/nano/node/nodeconfig.cpp b/nano/node/nodeconfig.cpp index c422bf7ec1..15afe8f1c0 100644 --- a/nano/node/nodeconfig.cpp +++ b/nano/node/nodeconfig.cpp @@ -40,7 +40,7 @@ nano::node_config::node_config (uint16_t peering_port_a, nano::logging const & l { case nano::networks::nano_dev_network: enable_voting = true; - preconfigured_representatives.push_back (network_params.ledger.genesis_account ()); + preconfigured_representatives.push_back (network_params.ledger.genesis->account ()); break; case nano::networks::nano_beta_network: { @@ -63,7 +63,7 @@ nano::node_config::node_config (uint16_t peering_port_a, nano::logging const & l break; case nano::networks::nano_test_network: preconfigured_peers.push_back (default_test_peer_network); - preconfigured_representatives.push_back (network_params.ledger.genesis_account ()); + preconfigured_representatives.push_back (network_params.ledger.genesis->account ()); break; default: debug_assert (false); diff --git a/nano/node/telemetry.cpp b/nano/node/telemetry.cpp index 35144862a7..84a6c288ef 100644 --- a/nano/node/telemetry.cpp +++ b/nano/node/telemetry.cpp @@ -92,7 +92,7 @@ bool nano::telemetry::verify_message (nano::telemetry_ack const & message_a, nan if (!remove_channel) { // Check for different genesis blocks - remove_channel = (message_a.data.genesis_block != network_params.ledger.genesis_hash ()); + remove_channel = (message_a.data.genesis_block != network_params.ledger.genesis->hash ()); if (remove_channel) { stats.inc (nano::stat::type::telemetry, nano::stat::detail::different_genesis_hash); @@ -634,7 +634,7 @@ nano::telemetry_data nano::local_telemetry_data (nano::ledger const & ledger_a, telemetry_data.protocol_version = network_params_a.protocol.protocol_version; telemetry_data.uptime = std::chrono::duration_cast (std::chrono::steady_clock::now () - statup_time_a).count (); telemetry_data.unchecked_count = ledger_a.store.unchecked.count (ledger_a.store.tx_begin_read ()); - telemetry_data.genesis_block = network_params_a.ledger.genesis_hash (); + telemetry_data.genesis_block = network_params_a.ledger.genesis->hash (); telemetry_data.peer_count = nano::narrow_cast (network_a.size ()); telemetry_data.account_count = ledger_a.cache.account_count; telemetry_data.major_version = nano::get_major_node_version (); diff --git a/nano/qt/qt.cpp b/nano/qt/qt.cpp index e1caab3edc..8001322621 100644 --- a/nano/qt/qt.cpp +++ b/nano/qt/qt.cpp @@ -544,7 +544,7 @@ class short_text_visitor : public nano::block_visitor { static nano::network_params params; type = "Receive"; - if (block_a.hashables.source != params.ledger.genesis_account ()) + if (block_a.hashables.source != params.ledger.genesis->account ()) { bool error_or_pruned (false); account = ledger.account_safe (transaction, block_a.hashables.source, error_or_pruned); @@ -556,8 +556,8 @@ class short_text_visitor : public nano::block_visitor } else { - account = params.ledger.genesis_account (); - amount = nano::dev::genesis_amount; + account = params.ledger.genesis->account (); + amount = nano::dev::constants.genesis_amount; } } void change_block (nano::change_block const & block_a) diff --git a/nano/qt_test/qt.cpp b/nano/qt_test/qt.cpp index 511cdf8fb0..4b26d8a532 100644 --- a/nano/qt_test/qt.cpp +++ b/nano/qt_test/qt.cpp @@ -562,9 +562,9 @@ TEST (history, pruned_source) auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub)); - nano::send_block send1 (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send1 (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send1).code); - nano::send_block send2 (send1.hash (), key.pub, nano::dev::genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); + nano::send_block send2 (send1.hash (), key.pub, nano::dev::constants.genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send2).code); nano::receive_block receive (send2.hash (), send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2.hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, receive).code); @@ -592,7 +592,7 @@ TEST (history, pruned_source) { auto transaction (store->tx_begin_write ()); auto latest (ledger.latest (transaction, nano::dev::genesis_key.pub)); - nano::state_block send (nano::dev::genesis_key.pub, latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 200, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::state_block send (nano::dev::genesis_key.pub, latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 200, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); auto latest_key (ledger.latest (transaction, key.pub)); nano::state_block receive (key.pub, latest_key, key.pub, 200, send.hash (), key.prv, key.pub, *system.work.generate (latest_key)); diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 49cb446cf8..c15820a5df 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -244,7 +244,7 @@ TEST (rpc, account_balance) .account (nano::dev::genesis_key.pub) .previous (nano::dev::genesis->hash ()) .representative (nano::dev::genesis_key.pub) - .balance (nano::dev::genesis_amount - 1) + .balance (nano::dev::constants.genesis_amount - 1) .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 ())) @@ -408,14 +408,14 @@ TEST (rpc, send) request.put ("source", nano::dev::genesis_key.pub.to_account ()); request.put ("destination", nano::dev::genesis_key.pub.to_account ()); request.put ("amount", "100"); - ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::genesis_amount); + ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::constants.genesis_amount); auto response (wait_response (system, rpc, request, 10s)); std::string block_text (response.get ("block")); nano::block_hash block; ASSERT_FALSE (block.decode_hex (block_text)); ASSERT_TRUE (node->ledger.block_or_pruned_exists (block)); ASSERT_EQ (node->latest (nano::dev::genesis_key.pub), block); - ASSERT_NE (node->balance (nano::dev::genesis_key.pub), nano::dev::genesis_amount); + ASSERT_NE (node->balance (nano::dev::genesis_key.pub), nano::dev::constants.genesis_amount); } TEST (rpc, send_fail) @@ -495,18 +495,18 @@ TEST (rpc, send_idempotent) request.put ("action", "send"); request.put ("source", nano::dev::genesis_key.pub.to_account ()); request.put ("destination", nano::account (0).to_account ()); - request.put ("amount", (nano::dev::genesis_amount - (nano::dev::genesis_amount / 4)).convert_to ()); + request.put ("amount", (nano::dev::constants.genesis_amount - (nano::dev::constants.genesis_amount / 4)).convert_to ()); request.put ("id", "123abc"); auto response (wait_response (system, rpc, request)); std::string block_text (response.get ("block")); nano::block_hash block; ASSERT_FALSE (block.decode_hex (block_text)); ASSERT_TRUE (node->ledger.block_or_pruned_exists (block)); - ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::genesis_amount / 4); + ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::constants.genesis_amount / 4); auto response2 (wait_response (system, rpc, request)); ASSERT_EQ ("", response2.get ("error", "")); ASSERT_EQ (block_text, response2.get ("block")); - ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::genesis_amount / 4); + ASSERT_EQ (node->balance (nano::dev::genesis_key.pub), nano::dev::constants.genesis_amount / 4); request.erase ("id"); request.put ("id", "456def"); auto response3 (wait_response (system, rpc, request)); @@ -1094,9 +1094,9 @@ TEST (rpc, history) auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->link ().as_account ())); ASSERT_NE (nullptr, receive); nano::genesis genesis; - nano::state_block usend (nano::dev::genesis->account (), node0->latest (nano::dev::genesis->account ()), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (node0->latest (nano::dev::genesis->account ()))); - nano::state_block ureceive (nano::dev::genesis->account (), usend.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, usend.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend.hash ())); - nano::state_block uchange (nano::dev::genesis->account (), ureceive.hash (), nano::keypair ().pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive.hash ())); + nano::state_block usend (nano::dev::genesis->account (), node0->latest (nano::dev::genesis->account ()), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (node0->latest (nano::dev::genesis->account ()))); + nano::state_block ureceive (nano::dev::genesis->account (), usend.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, usend.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend.hash ())); + nano::state_block uchange (nano::dev::genesis->account (), ureceive.hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive.hash ())); { auto transaction (node0->store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node0->ledger.process (transaction, usend).code); @@ -1135,7 +1135,7 @@ TEST (rpc, history) ASSERT_EQ (send->hash ().to_string (), std::get<3> (history_l[3])); ASSERT_EQ ("receive", std::get<0> (history_l[4])); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), std::get<1> (history_l[4])); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), std::get<2> (history_l[4])); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), std::get<2> (history_l[4])); ASSERT_EQ (genesis.hash ().to_string (), std::get<3> (history_l[4])); } @@ -1151,9 +1151,9 @@ TEST (rpc, account_history) auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->link ().as_account ())); ASSERT_NE (nullptr, receive); nano::genesis genesis; - nano::state_block usend (nano::dev::genesis->account (), node0->latest (nano::dev::genesis->account ()), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (node0->latest (nano::dev::genesis->account ()))); - nano::state_block ureceive (nano::dev::genesis->account (), usend.hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, usend.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend.hash ())); - nano::state_block uchange (nano::dev::genesis->account (), ureceive.hash (), nano::keypair ().pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive.hash ())); + nano::state_block usend (nano::dev::genesis->account (), node0->latest (nano::dev::genesis->account ()), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (node0->latest (nano::dev::genesis->account ()))); + nano::state_block ureceive (nano::dev::genesis->account (), usend.hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, usend.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend.hash ())); + nano::state_block uchange (nano::dev::genesis->account (), ureceive.hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive.hash ())); { auto transaction (node0->store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node0->ledger.process (transaction, usend).code); @@ -1197,7 +1197,7 @@ TEST (rpc, account_history) ASSERT_EQ ("3", std::get<4> (history_l[3])); ASSERT_EQ ("receive", std::get<0> (history_l[4])); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), std::get<1> (history_l[4])); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), std::get<2> (history_l[4])); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), std::get<2> (history_l[4])); ASSERT_EQ (genesis.hash ().to_string (), std::get<3> (history_l[4])); ASSERT_EQ ("1", std::get<4> (history_l[4])); // change block (height 2) is skipped } @@ -1287,13 +1287,13 @@ TEST (rpc, history_pruning) nano::genesis genesis; auto change (std::make_shared (genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work.generate (genesis.hash ()))); node0->process_active (change); - auto send (std::make_shared (change->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - node0->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work.generate (change->hash ()))); + auto send (std::make_shared (change->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - node0->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work.generate (change->hash ()))); node0->process_active (send); auto receive (std::make_shared (send->hash (), send->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work.generate (send->hash ()))); node0->process_active (receive); - auto usend (std::make_shared (nano::dev::genesis->account (), receive->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (receive->hash ()))); - auto ureceive (std::make_shared (nano::dev::genesis->account (), usend->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount, usend->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend->hash ()))); - auto uchange (std::make_shared (nano::dev::genesis->account (), ureceive->hash (), nano::keypair ().pub, nano::dev::genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive->hash ()))); + auto usend (std::make_shared (nano::dev::genesis->account (), receive->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis->account (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (receive->hash ()))); + auto ureceive (std::make_shared (nano::dev::genesis->account (), usend->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount, usend->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (usend->hash ()))); + auto uchange (std::make_shared (nano::dev::genesis->account (), ureceive->hash (), nano::keypair ().pub, nano::dev::constants.genesis_amount, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node0->work_generate_blocking (ureceive->hash ()))); node0->process_active (usend); node0->process_active (ureceive); node0->process_active (uchange); @@ -1498,7 +1498,7 @@ TEST (rpc, process_block_async) ASSERT_EQ (ec.message (), response.get ("error")); } - auto state_send (std::make_shared (nano::dev::genesis_key.pub, latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 100, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest))); + auto state_send (std::make_shared (nano::dev::genesis_key.pub, latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest))); std::string json1; state_send->serialize_json (json1); request.put ("block", json1); @@ -1554,7 +1554,7 @@ TEST (rpc, process_subtype_send) auto [rpc, rpc_ctx] = add_rpc (system, node1); nano::keypair key; auto latest (node1->latest (nano::dev::genesis_key.pub)); - nano::state_block send (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); + nano::state_block send (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); boost::property_tree::ptree request; request.put ("action", "process"); std::string json; @@ -1580,7 +1580,7 @@ TEST (rpc, process_subtype_open) auto & node2 = *system.add_node (); nano::keypair key; auto latest (node1->latest (nano::dev::genesis_key.pub)); - auto send = std::make_shared (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); + auto send = std::make_shared (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); ASSERT_EQ (nano::process_result::progress, node1->process (*send).code); ASSERT_EQ (nano::process_result::progress, node2.process (*send).code); auto [rpc, rpc_ctx] = add_rpc (system, node1); @@ -1610,12 +1610,12 @@ TEST (rpc, process_subtype_receive) auto node1 = add_ipc_enabled_node (system); auto & node2 = *system.add_node (); auto latest (node1->latest (nano::dev::genesis_key.pub)); - auto send = std::make_shared (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); + auto send = std::make_shared (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest)); ASSERT_EQ (nano::process_result::progress, node1->process (*send).code); ASSERT_EQ (nano::process_result::progress, node2.process (*send).code); auto [rpc, rpc_ctx] = add_rpc (system, node1); node1->scheduler.manual (send); - nano::state_block receive (nano::dev::genesis_key.pub, send->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount, send->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (send->hash ())); + nano::state_block receive (nano::dev::genesis_key.pub, send->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount, send->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (send->hash ())); boost::property_tree::ptree request; request.put ("action", "process"); std::string json; @@ -1644,7 +1644,7 @@ TEST (rpc, process_ledger_insufficient_work) auto latest (node->latest (nano::dev::genesis_key.pub)); auto min_difficulty = node->network_params.network.publish_thresholds.entry; auto max_difficulty = node->network_params.network.publish_thresholds.epoch_1; - nano::state_block send (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, system.work_generate_limited (latest, min_difficulty, max_difficulty)); + nano::state_block send (nano::dev::genesis->account (), latest, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, system.work_generate_limited (latest, min_difficulty, max_difficulty)); ASSERT_LT (send.difficulty (), max_difficulty); ASSERT_GE (send.difficulty (), min_difficulty); boost::property_tree::ptree request; @@ -1885,7 +1885,7 @@ TEST (rpc, search_pending) system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto wallet (node->wallets.items.begin ()->first.to_string ()); auto latest (node->latest (nano::dev::genesis_key.pub)); - nano::send_block block (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - node->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (latest)); + nano::send_block block (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - node->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (latest)); { auto transaction (node->store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, block).code); @@ -1895,7 +1895,7 @@ TEST (rpc, search_pending) request.put ("action", "search_pending"); request.put ("wallet", wallet); auto response (wait_response (system, rpc, request)); - ASSERT_TIMELY (10s, node->balance (nano::dev::genesis_key.pub) == nano::dev::genesis_amount); + ASSERT_TIMELY (10s, node->balance (nano::dev::genesis_key.pub) == nano::dev::constants.genesis_amount); } TEST (rpc, version) @@ -2338,7 +2338,7 @@ TEST (rpc, block_count_pruning) node_flags.enable_pruning = true; auto node1 = add_ipc_enabled_node (system, node_config, node_flags); auto latest (node1->latest (nano::dev::genesis_key.pub)); - auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); + auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); node1->process_active (send1); auto receive1 (std::make_shared (send1->hash (), send1->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (send1->hash ()))); node1->process_active (receive1); @@ -2886,7 +2886,7 @@ TEST (rpc, republish) request.put ("action", "republish"); request.put ("hash", send.hash ().to_string ()); auto response (wait_response (system, rpc, request)); - ASSERT_TIMELY (10s, system.nodes[1]->balance (nano::dev::genesis_key.pub) != nano::dev::genesis_amount); + ASSERT_TIMELY (10s, system.nodes[1]->balance (nano::dev::genesis_key.pub) != nano::dev::constants.genesis_amount); auto & blocks_node (response.get_child ("blocks")); std::vector blocks; for (auto i (blocks_node.begin ()), n (blocks_node.end ()); i != n; ++i) @@ -3430,7 +3430,7 @@ TEST (rpc, search_pending_all) auto node = add_ipc_enabled_node (system); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto latest (node->latest (nano::dev::genesis_key.pub)); - nano::send_block block (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - node->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (latest)); + nano::send_block block (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - node->config.receive_minimum.number (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (latest)); { auto transaction (node->store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, block).code); @@ -3439,7 +3439,7 @@ TEST (rpc, search_pending_all) boost::property_tree::ptree request; request.put ("action", "search_pending_all"); auto response (wait_response (system, rpc, request)); - ASSERT_TIMELY (10s, node->balance (nano::dev::genesis_key.pub) == nano::dev::genesis_amount); + ASSERT_TIMELY (10s, node->balance (nano::dev::genesis_key.pub) == nano::dev::constants.genesis_amount); } TEST (rpc, wallet_republish) @@ -3783,7 +3783,7 @@ TEST (rpc, json_block_input) auto node1 = add_ipc_enabled_node (system); nano::keypair key; system.wallet (0)->insert_adhoc (key.prv); - nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); auto [rpc, rpc_ctx] = add_rpc (system, node1); boost::property_tree::ptree request; request.put ("action", "sign"); @@ -3841,7 +3841,7 @@ TEST (rpc, blocks_info) std::string account_text (blocks.second.get ("block_account")); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), account_text); std::string amount_text (blocks.second.get ("amount")); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), amount_text); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), amount_text); std::string blocks_text (blocks.second.get ("contents")); ASSERT_FALSE (blocks_text.empty ()); boost::optional pending (blocks.second.get_optional ("pending")); @@ -3849,7 +3849,7 @@ TEST (rpc, blocks_info) boost::optional source (blocks.second.get_optional ("source_account")); ASSERT_FALSE (source.is_initialized ()); std::string balance_text (blocks.second.get ("balance")); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), balance_text); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), balance_text); ASSERT_TRUE (blocks.second.get ("confirmed")); // Genesis block is confirmed by default std::string successor_text (blocks.second.get ("successor")); ASSERT_EQ (nano::block_hash (0).to_string (), successor_text); // Genesis block doesn't have successor yet @@ -3960,14 +3960,14 @@ TEST (rpc, block_info_successor) std::string account_text (response.get ("block_account")); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), account_text); std::string amount_text (response.get ("amount")); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), amount_text); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), amount_text); } TEST (rpc, block_info_pruning) { nano::system system; nano::node_config node_config0 (nano::get_available_port (), system.logging); - node_config0.receive_minimum = nano::dev::genesis_amount; // Prevent auto-receive & receive1 block conflicts + node_config0.receive_minimum = nano::dev::constants.genesis_amount; // Prevent auto-receive & receive1 block conflicts auto & node0 = *system.add_node (node_config0); nano::node_config node_config1 (nano::get_available_port (), system.logging); node_config1.enable_voting = false; // Remove after allowing pruned voting @@ -3975,7 +3975,7 @@ TEST (rpc, block_info_pruning) node_flags.enable_pruning = true; auto node1 = add_ipc_enabled_node (system, node_config1, node_flags); auto latest (node1->latest (nano::dev::genesis_key.pub)); - auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); + auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); node1->process_active (send1); auto receive1 (std::make_shared (send1->hash (), send1->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (send1->hash ()))); node1->process_active (receive1); @@ -4010,7 +4010,7 @@ TEST (rpc, block_info_pruning) ASSERT_FALSE (json_error); ASSERT_EQ (receive1->full_hash (), receive_from_json.full_hash ()); std::string balance_text (response2.get ("balance")); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), balance_text); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), balance_text); ASSERT_TRUE (response2.get ("confirmed")); std::string successor_text (response2.get ("successor")); ASSERT_EQ (successor_text, nano::block_hash (0).to_string ()); // receive1 block doesn't have successor yet @@ -4020,7 +4020,7 @@ TEST (rpc, pruned_exists) { nano::system system; nano::node_config node_config0 (nano::get_available_port (), system.logging); - node_config0.receive_minimum = nano::dev::genesis_amount; // Prevent auto-receive & receive1 block conflicts + node_config0.receive_minimum = nano::dev::constants.genesis_amount; // Prevent auto-receive & receive1 block conflicts auto & node0 = *system.add_node (node_config0); nano::node_config node_config1 (nano::get_available_port (), system.logging); node_config1.enable_voting = false; // Remove after allowing pruned voting @@ -4028,7 +4028,7 @@ TEST (rpc, pruned_exists) node_flags.enable_pruning = true; auto node1 = add_ipc_enabled_node (system, node_config1, node_flags); auto latest (node1->latest (nano::dev::genesis_key.pub)); - auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); + auto send1 (std::make_shared (latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (latest))); node1->process_active (send1); auto receive1 (std::make_shared (send1->hash (), send1->hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node1->work_generate_blocking (send1->hash ()))); node1->process_active (receive1); @@ -4095,7 +4095,7 @@ TEST (rpc, ledger) auto node = add_ipc_enabled_node (system); nano::keypair key; auto latest (node->latest (nano::dev::genesis_key.pub)); - auto genesis_balance (nano::dev::genesis_amount); + auto genesis_balance (nano::dev::constants.genesis_amount); auto send_amount (genesis_balance - 100); genesis_balance -= send_amount; nano::send_block send (latest, key.pub, genesis_balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (latest)); @@ -4321,7 +4321,7 @@ TEST (rpc, block_create_state) request.put ("account", nano::dev::genesis_key.pub.to_account ()); request.put ("previous", genesis.hash ().to_string ()); request.put ("representative", nano::dev::genesis_key.pub.to_account ()); - request.put ("balance", (nano::dev::genesis_amount - nano::Gxrb_ratio).convert_to ()); + request.put ("balance", (nano::dev::constants.genesis_amount - nano::Gxrb_ratio).convert_to ()); request.put ("link", key.pub.to_account ()); request.put ("work", nano::to_string_hex (*node->work_generate_blocking (genesis.hash ()))); auto response (wait_response (system, rpc, request)); @@ -4406,7 +4406,7 @@ TEST (rpc, block_create_state_request_work) request.put ("wallet", node->wallets.items.begin ()->first.to_string ()); request.put ("account", nano::dev::genesis_key.pub.to_account ()); request.put ("representative", nano::dev::genesis_key.pub.to_account ()); - request.put ("balance", (nano::dev::genesis_amount - nano::Gxrb_ratio).convert_to ()); + request.put ("balance", (nano::dev::constants.genesis_amount - nano::Gxrb_ratio).convert_to ()); request.put ("link", key.pub.to_account ()); request.put ("previous", previous); auto response (wait_response (system, rpc, request)); @@ -4718,7 +4718,7 @@ TEST (rpc, online_reps) auto send_block (system.wallet (0)->send_action (nano::dev::genesis_key.pub, key.pub, nano::Gxrb_ratio)); ASSERT_NE (nullptr, send_block); ASSERT_TIMELY (10s, !node2->online_reps.list ().empty ()); - ASSERT_EQ (node2->online_reps.online (), nano::dev::genesis_amount - nano::Gxrb_ratio); + ASSERT_EQ (node2->online_reps.online (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio); auto [rpc, rpc_ctx] = add_rpc (system, node2); boost::property_tree::ptree request; request.put ("action", "representatives_online"); @@ -4786,7 +4786,7 @@ TEST (rpc, confirmation_height_currently_processing) { auto transaction = node->store.tx_begin_write (); nano::keypair key1; - nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash)); + nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio - 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); previous_genesis_chain_hash = send.hash (); } @@ -4856,7 +4856,7 @@ TEST (rpc, confirmation_history) ASSERT_EQ (block->hash ().to_string (), hash); nano::amount tally_num; tally_num.decode_dec (tally); - debug_assert (tally_num == nano::dev::genesis_amount || tally_num == (nano::dev::genesis_amount - nano::Gxrb_ratio)); + debug_assert (tally_num == nano::dev::constants.genesis_amount || tally_num == (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)); system.stop (); } @@ -4887,7 +4887,7 @@ TEST (rpc, confirmation_history_hash) ASSERT_EQ (send2->hash ().to_string (), hash); nano::amount tally_num; tally_num.decode_dec (tally); - debug_assert (tally_num == nano::dev::genesis_amount || tally_num == (nano::dev::genesis_amount - nano::Gxrb_ratio) || tally_num == (nano::dev::genesis_amount - 2 * nano::Gxrb_ratio) || tally_num == (nano::dev::genesis_amount - 3 * nano::Gxrb_ratio)); + debug_assert (tally_num == nano::dev::constants.genesis_amount || tally_num == (nano::dev::constants.genesis_amount - nano::Gxrb_ratio) || tally_num == (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio) || tally_num == (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio)); system.stop (); } @@ -4897,7 +4897,7 @@ TEST (rpc, block_confirm) auto node = add_ipc_enabled_node (system); system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); nano::genesis genesis; - auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (genesis.hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, nano::dev::genesis_key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *node->work_generate_blocking (genesis.hash ()))); { auto transaction (node->store.tx_begin_write ()); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send1).code); @@ -5220,7 +5220,7 @@ TEST (rpc, wallet_history) // Genesis block ASSERT_EQ ("receive", std::get<0> (history_l[3])); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), std::get<1> (history_l[3])); - ASSERT_EQ (nano::dev::genesis_amount.convert_to (), std::get<2> (history_l[3])); + ASSERT_EQ (nano::dev::constants.genesis_amount.convert_to (), std::get<2> (history_l[3])); ASSERT_EQ (nano::dev::genesis->hash ().to_string (), std::get<3> (history_l[3])); ASSERT_EQ (nano::dev::genesis_key.pub.to_account (), std::get<4> (history_l[3])); } @@ -5230,7 +5230,7 @@ TEST (rpc, sign_hash) nano::system system; auto node1 = add_ipc_enabled_node (system); nano::keypair key; - nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); auto [rpc, rpc_ctx] = add_rpc (system, node1); boost::property_tree::ptree request; request.put ("action", "sign"); @@ -5253,7 +5253,7 @@ TEST (rpc, sign_block) auto node1 = add_ipc_enabled_node (system); nano::keypair key; system.wallet (0)->insert_adhoc (key.prv); - nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); + nano::state_block send (nano::dev::genesis->account (), node1->latest (nano::dev::genesis_key.pub), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, 0); auto [rpc, rpc_ctx] = add_rpc (system, node1); boost::property_tree::ptree request; request.put ("action", "sign"); @@ -5642,14 +5642,14 @@ TEST (rpc, epoch_upgrade) auto node = add_ipc_enabled_node (system); nano::keypair key1, key2, key3; nano::keypair epoch_signer (nano::dev::genesis_key); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); // to opened account + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); // to opened account ASSERT_EQ (nano::process_result::progress, node->process (*send1).code); - auto send2 (std::make_shared (nano::dev::genesis_key.pub, send1->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); // to unopened account (pending) + auto send2 (std::make_shared (nano::dev::genesis_key.pub, send1->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); // to unopened account (pending) ASSERT_EQ (nano::process_result::progress, node->process (*send2).code); - auto send3 (std::make_shared (nano::dev::genesis_key.pub, send2->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 3, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2->hash ()))); // to burn (0) + auto send3 (std::make_shared (nano::dev::genesis_key.pub, send2->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 3, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2->hash ()))); // to burn (0) ASSERT_EQ (nano::process_result::progress, node->process (*send3).code); nano::account max_account (std::numeric_limits::max ()); - auto send4 (std::make_shared (nano::dev::genesis_key.pub, send3->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 4, max_account, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3->hash ()))); // to max account + auto send4 (std::make_shared (nano::dev::genesis_key.pub, send3->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 4, max_account, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3->hash ()))); // to max account ASSERT_EQ (nano::process_result::progress, node->process (*send4).code); auto open (std::make_shared (key1.pub, 0, key1.pub, 1, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub))); ASSERT_EQ (nano::process_result::progress, node->process (*open).code); @@ -5691,9 +5691,9 @@ TEST (rpc, epoch_upgrade) rpc_ctx->io_scope->reset (); // Epoch 2 upgrade auto genesis_latest (node->latest (nano::dev::genesis_key.pub)); - auto send5 (std::make_shared (nano::dev::genesis_key.pub, genesis_latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 5, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis_latest))); // to burn (0) + auto send5 (std::make_shared (nano::dev::genesis_key.pub, genesis_latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 5, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis_latest))); // to burn (0) ASSERT_EQ (nano::process_result::progress, node->process (*send5).code); - auto send6 (std::make_shared (nano::dev::genesis_key.pub, send5->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 6, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send5->hash ()))); // to key1 (again) + auto send6 (std::make_shared (nano::dev::genesis_key.pub, send5->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 6, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send5->hash ()))); // to key1 (again) ASSERT_EQ (nano::process_result::progress, node->process (*send6).code); auto key1_latest (node->latest (key1.pub)); auto send7 (std::make_shared (key1.pub, key1_latest, key1.pub, 0, key3.pub, key1.prv, key1.pub, *system.work.generate (key1_latest))); // to key3 @@ -5736,14 +5736,14 @@ TEST (rpc, epoch_upgrade_multithreaded) auto node = add_ipc_enabled_node (system, node_config); nano::keypair key1, key2, key3; nano::keypair epoch_signer (nano::dev::genesis_key); - auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); // to opened account + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 1, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); // to opened account ASSERT_EQ (nano::process_result::progress, node->process (*send1).code); - auto send2 (std::make_shared (nano::dev::genesis_key.pub, send1->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); // to unopened account (pending) + auto send2 (std::make_shared (nano::dev::genesis_key.pub, send1->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 2, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); // to unopened account (pending) ASSERT_EQ (nano::process_result::progress, node->process (*send2).code); - auto send3 (std::make_shared (nano::dev::genesis_key.pub, send2->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 3, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2->hash ()))); // to burn (0) + auto send3 (std::make_shared (nano::dev::genesis_key.pub, send2->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 3, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send2->hash ()))); // to burn (0) ASSERT_EQ (nano::process_result::progress, node->process (*send3).code); nano::account max_account (std::numeric_limits::max ()); - auto send4 (std::make_shared (nano::dev::genesis_key.pub, send3->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 4, max_account, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3->hash ()))); // to max account + auto send4 (std::make_shared (nano::dev::genesis_key.pub, send3->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 4, max_account, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send3->hash ()))); // to max account ASSERT_EQ (nano::process_result::progress, node->process (*send4).code); auto open (std::make_shared (key1.pub, 0, key1.pub, 1, send1->hash (), key1.prv, key1.pub, *system.work.generate (key1.pub))); ASSERT_EQ (nano::process_result::progress, node->process (*open).code); @@ -5784,9 +5784,9 @@ TEST (rpc, epoch_upgrade_multithreaded) rpc_ctx->io_scope->reset (); // Epoch 2 upgrade auto genesis_latest (node->latest (nano::dev::genesis_key.pub)); - auto send5 (std::make_shared (nano::dev::genesis_key.pub, genesis_latest, nano::dev::genesis_key.pub, nano::dev::genesis_amount - 5, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis_latest))); // to burn (0) + auto send5 (std::make_shared (nano::dev::genesis_key.pub, genesis_latest, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 5, 0, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis_latest))); // to burn (0) ASSERT_EQ (nano::process_result::progress, node->process (*send5).code); - auto send6 (std::make_shared (nano::dev::genesis_key.pub, send5->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - 6, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send5->hash ()))); // to key1 (again) + auto send6 (std::make_shared (nano::dev::genesis_key.pub, send5->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - 6, key1.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send5->hash ()))); // to key1 (again) ASSERT_EQ (nano::process_result::progress, node->process (*send6).code); auto key1_latest (node->latest (key1.pub)); auto send7 (std::make_shared (key1.pub, key1_latest, key1.pub, 0, key3.pub, key1.prv, key1.pub, *system.work.generate (key1_latest))); // to key3 @@ -5829,7 +5829,7 @@ TEST (rpc, account_lazy_start) auto node1 = system.add_node (node_flags); nano::keypair key; // Generating test chain - auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); + auto send1 (std::make_shared (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ()))); ASSERT_EQ (nano::process_result::progress, node1->process (*send1).code); auto open (std::make_shared (send1->hash (), key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub))); ASSERT_EQ (nano::process_result::progress, node1->process (*open).code); @@ -5866,7 +5866,7 @@ TEST (rpc, receive) nano::keypair key1; wallet->insert_adhoc (key1.prv); auto send1 (wallet->send_action (nano::dev::genesis_key.pub, key1.pub, node->config.receive_minimum.number (), *node->work_generate_blocking (nano::dev::genesis->hash ()))); - ASSERT_TIMELY (5s, node->balance (nano::dev::genesis_key.pub) != nano::dev::genesis_amount); + ASSERT_TIMELY (5s, node->balance (nano::dev::genesis_key.pub) != nano::dev::constants.genesis_amount); ASSERT_TIMELY (10s, !node->store.account.exists (node->store.tx_begin_read (), key1.pub)); // Send below minimum receive amount auto send2 (wallet->send_action (nano::dev::genesis_key.pub, key1.pub, node->config.receive_minimum.number () - 1, *node->work_generate_blocking (send1->hash ()))); @@ -5907,7 +5907,7 @@ TEST (rpc, receive_unopened) // Test receiving for unopened account nano::keypair key1; auto send1 (wallet->send_action (nano::dev::genesis_key.pub, key1.pub, node->config.receive_minimum.number () - 1, *node->work_generate_blocking (nano::dev::genesis->hash ()))); - ASSERT_TIMELY (5s, !node->balance (nano::dev::genesis_key.pub) != nano::dev::genesis_amount); + ASSERT_TIMELY (5s, !node->balance (nano::dev::genesis_key.pub) != nano::dev::constants.genesis_amount); ASSERT_FALSE (node->store.account.exists (node->store.tx_begin_read (), key1.pub)); ASSERT_TRUE (node->store.block.exists (node->store.tx_begin_read (), send1->hash ())); wallet->insert_adhoc (key1.prv); // should not auto receive, amount sent was lower than minimum @@ -5969,7 +5969,7 @@ TEST (rpc, receive_work_disabled) ASSERT_TRUE (worker_node.work_generation_enabled ()); auto send1 (wallet->send_action (nano::dev::genesis_key.pub, key1.pub, node->config.receive_minimum.number () - 1, *worker_node.work_generate_blocking (genesis.hash ()), false)); ASSERT_TRUE (send1 != nullptr); - ASSERT_TIMELY (5s, node->balance (nano::dev::genesis_key.pub) != nano::dev::genesis_amount); + ASSERT_TIMELY (5s, node->balance (nano::dev::genesis_key.pub) != nano::dev::constants.genesis_amount); ASSERT_FALSE (node->store.account.exists (node->store.tx_begin_read (), key1.pub)); ASSERT_TRUE (node->store.block.exists (node->store.tx_begin_read (), send1->hash ())); wallet->insert_adhoc (key1.prv); @@ -6002,7 +6002,7 @@ TEST (rpc, receive_pruned) nano::keypair key1; wallet2->insert_adhoc (key1.prv); auto send1 (wallet1->send_action (nano::dev::genesis_key.pub, key1.pub, node2->config.receive_minimum.number (), *node2->work_generate_blocking (nano::dev::genesis->hash ()))); - ASSERT_TIMELY (5s, node2->balance (nano::dev::genesis_key.pub) != nano::dev::genesis_amount); + ASSERT_TIMELY (5s, node2->balance (nano::dev::genesis_key.pub) != nano::dev::constants.genesis_amount); ASSERT_TIMELY (10s, !node2->store.account.exists (node2->store.tx_begin_read (), key1.pub)); // Send below minimum receive amount auto send2 (wallet1->send_action (nano::dev::genesis_key.pub, key1.pub, node2->config.receive_minimum.number () - 1, *node2->work_generate_blocking (send1->hash ()))); @@ -6219,8 +6219,8 @@ TEST (rpc, confirmation_active) auto [rpc, rpc_ctx] = add_rpc (system, node1); nano::genesis genesis; - auto send1 (std::make_shared (genesis.hash (), nano::public_key (), nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); - auto send2 (std::make_shared (send1->hash (), nano::public_key (), nano::dev::genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); + auto send1 (std::make_shared (genesis.hash (), nano::public_key (), nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send2 (std::make_shared (send1->hash (), nano::public_key (), nano::dev::constants.genesis_amount - 200, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (send1->hash ()))); node1->process_active (send1); node1->process_active (send2); nano::blocks_confirm (*node1, { send1, send2 }); @@ -6248,7 +6248,7 @@ TEST (rpc, confirmation_info) auto [rpc, rpc_ctx] = add_rpc (system, node1); nano::genesis genesis; - auto send (std::make_shared (genesis.hash (), nano::public_key (), nano::dev::genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); + auto send (std::make_shared (genesis.hash (), nano::public_key (), nano::dev::constants.genesis_amount - 100, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ()))); node1->process_active (send); node1->block_processor.flush (); node1->scheduler.flush (); diff --git a/nano/secure/common.cpp b/nano/secure/common.cpp index f1a299967c..9ee6293853 100644 --- a/nano/secure/common.cpp +++ b/nano/secure/common.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -79,10 +80,9 @@ char const * live_canary_public_key_data = "7CBAF192A3763DAEC9F9BAC1B2CDF665D836 std::string const test_canary_public_key_data = nano::get_env_or_default ("NANO_TEST_CANARY_PUB", "3BAD2C554ACE05F5E528FBBCE79D51E552C55FA765CCFD89B289C4835DE5F04A"); // nano_1gxf7jcnomi7yqkkjyxwwygo5sckrohtgsgezp6u74g6ifgydw4cajwbk8bf } +nano::keypair nano::dev::genesis_key{ dev_private_key_data }; nano::ledger_constants nano::dev::constants{ nano::networks::nano_dev_network }; std::shared_ptr & nano::dev::genesis = nano::dev::constants.genesis; -nano::keypair nano::dev::genesis_key{ dev_private_key_data }; -nano::uint128_t nano::dev::genesis_amount{ std::numeric_limits::max () }; nano::network_params::network_params () : network_params (network_constants::active_network) @@ -117,6 +117,7 @@ nano::ledger_constants::ledger_constants (nano::networks network_a) : nano_live_genesis (parse_block_from_genesis_data (live_genesis_data)), nano_test_genesis (parse_block_from_genesis_data (test_genesis_data)), genesis (network_a == nano::networks::nano_dev_network ? nano_dev_genesis : network_a == nano::networks::nano_beta_network ? nano_beta_genesis : network_a == nano::networks::nano_test_network ? nano_test_genesis : nano_live_genesis), + genesis_amount{ std::numeric_limits::max () }, burn_account (0), nano_dev_final_votes_canary_account (dev_public_key_data), nano_beta_final_votes_canary_account (beta_canary_public_key_data), @@ -129,10 +130,15 @@ nano::ledger_constants::ledger_constants (nano::networks network_a) : nano_test_final_votes_canary_height (1), final_votes_canary_height (network_a == nano::networks::nano_dev_network ? nano_dev_final_votes_canary_height : network_a == nano::networks::nano_beta_network ? nano_beta_final_votes_canary_height : network_a == nano::networks::nano_test_network ? nano_test_final_votes_canary_height : nano_live_final_votes_canary_height) { + nano_beta_genesis->sideband_set (nano::block_sideband (nano_beta_genesis->account (), 0, nano::dev::constants.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); + nano_dev_genesis->sideband_set (nano::block_sideband (nano_dev_genesis->account (), 0, nano::dev::constants.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); + nano_live_genesis->sideband_set (nano::block_sideband (nano_live_genesis->account (), 0, nano::dev::constants.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); + nano_test_genesis->sideband_set (nano::block_sideband (nano_test_genesis->account (), 0, nano::dev::constants.genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); + nano::link epoch_link_v1; const char * epoch_message_v1 ("epoch v1 block"); strncpy ((char *)epoch_link_v1.bytes.data (), epoch_message_v1, epoch_link_v1.bytes.size ()); - epochs.add (nano::epoch::epoch_1, genesis_account (), epoch_link_v1); + epochs.add (nano::epoch::epoch_1, genesis->account (), epoch_link_v1); nano::link epoch_link_v2; nano::account nano_live_epoch_v2_signer; @@ -144,20 +150,6 @@ nano::ledger_constants::ledger_constants (nano::networks network_a) : epochs.add (nano::epoch::epoch_2, epoch_v2_signer, epoch_link_v2); } -nano::account nano::ledger_constants::genesis_account () const -{ - auto result = genesis->account (); - debug_assert (!result.is_zero ()); - return result; -} - -nano::block_hash nano::ledger_constants::genesis_hash () const -{ - auto result = genesis->hash (); - debug_assert (!result.is_zero ()); - return result; -} - nano::random_constants::random_constants () { nano::random_pool::generate_block (not_an_account.bytes.data (), not_an_account.bytes.size ()); diff --git a/nano/secure/common.hpp b/nano/secure/common.hpp index 572536062b..23c56511b4 100644 --- a/nano/secure/common.hpp +++ b/nano/secure/common.hpp @@ -368,8 +368,6 @@ class ledger_constants public: ledger_constants (nano::network_constants & network_constants); ledger_constants (nano::networks network_a); - nano::account genesis_account () const; - nano::block_hash genesis_hash () const; nano::keypair zero_key; nano::account nano_beta_account; nano::account nano_live_account; @@ -379,6 +377,7 @@ class ledger_constants std::shared_ptr nano_live_genesis; std::shared_ptr nano_test_genesis; std::shared_ptr genesis; + nano::uint128_t genesis_amount; nano::account burn_account; nano::account nano_dev_final_votes_canary_account; nano::account nano_beta_final_votes_canary_account; @@ -395,10 +394,9 @@ class ledger_constants namespace dev { + extern nano::keypair genesis_key; extern nano::ledger_constants constants; extern std::shared_ptr & genesis; - extern nano::keypair genesis_key; - extern nano::uint128_t genesis_amount; } /** Constants which depend on random values (this class should never be used globally due to CryptoPP globals potentially not being initialized) */ diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 551431da6d..90020bee0a 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1102,8 +1102,8 @@ nano::account nano::ledger::account_safe (nano::transaction const & transaction_ // Return amount decrease or increase for block nano::uint128_t nano::ledger::amount (nano::transaction const & transaction_a, nano::account const & account_a) { - release_assert (account_a == network_params.ledger.genesis_account ()); - return nano::dev::genesis_amount; + release_assert (account_a == network_params.ledger.genesis->account ()); + return nano::dev::constants.genesis_amount; } nano::uint128_t nano::ledger::amount (nano::transaction const & transaction_a, nano::block_hash const & hash_a) @@ -1204,7 +1204,7 @@ class dependent_block_visitor : public nano::block_visitor } void open_block (nano::open_block const & block_a) override { - if (block_a.source () != ledger.network_params.ledger.genesis_account ()) + if (block_a.source () != ledger.network_params.ledger.genesis->account ()) { result[0] = block_a.source (); } @@ -1342,7 +1342,7 @@ uint64_t nano::ledger::pruning_action (nano::write_transaction & transaction_a, { uint64_t pruned_count (0); nano::block_hash hash (hash_a); - while (!hash.is_zero () && hash != network_params.ledger.genesis_hash ()) + while (!hash.is_zero () && hash != network_params.ledger.genesis->hash ()) { auto block (store.block.get (transaction_a, hash)); if (block != nullptr) diff --git a/nano/secure/store_partial.hpp b/nano/secure/store_partial.hpp index 666a9b8d6b..58de2fb313 100644 --- a/nano/secure/store_partial.hpp +++ b/nano/secure/store_partial.hpp @@ -105,19 +105,18 @@ class store_partial : public store */ void initialize (nano::write_transaction const & transaction_a, nano::ledger_cache & ledger_cache_a) override { - auto & genesis = *network_params.ledger.genesis; - auto hash_l (genesis.hash ()); + debug_assert (network_params.ledger.genesis->has_sideband ()); debug_assert (account.begin (transaction_a) == account.end ()); - genesis.sideband_set (nano::block_sideband (network_params.ledger.genesis_account (), 0, nano::dev::genesis_amount, 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0)); - block.put (transaction_a, hash_l, genesis); + auto hash_l (network_params.ledger.genesis->hash ()); + block.put (transaction_a, hash_l, *network_params.ledger.genesis); ++ledger_cache_a.block_count; - confirmation_height.put (transaction_a, network_params.ledger.genesis_account (), nano::confirmation_height_info{ 1, genesis.hash () }); + confirmation_height.put (transaction_a, network_params.ledger.genesis->account (), nano::confirmation_height_info{ 1, network_params.ledger.genesis->hash () }); ++ledger_cache_a.cemented_count; - ledger_cache_a.final_votes_confirmation_canary = (network_params.ledger.final_votes_canary_account == network_params.ledger.genesis_account () && 1 >= network_params.ledger.final_votes_canary_height); - account.put (transaction_a, network_params.ledger.genesis_account (), { hash_l, network_params.ledger.genesis_account (), genesis.hash (), std::numeric_limits::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 }); + ledger_cache_a.final_votes_confirmation_canary = (network_params.ledger.final_votes_canary_account == network_params.ledger.genesis->account () && 1 >= network_params.ledger.final_votes_canary_height); + account.put (transaction_a, network_params.ledger.genesis->account (), { hash_l, network_params.ledger.genesis->account (), network_params.ledger.genesis->hash (), std::numeric_limits::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 }); ++ledger_cache_a.account_count; - ledger_cache_a.rep_weights.representation_put (network_params.ledger.genesis_account (), std::numeric_limits::max ()); - frontier.put (transaction_a, hash_l, network_params.ledger.genesis_account ()); + ledger_cache_a.rep_weights.representation_put (network_params.ledger.genesis->account (), std::numeric_limits::max ()); + frontier.put (transaction_a, hash_l, network_params.ledger.genesis->account ()); } bool root_exists (nano::transaction const & transaction_a, nano::root const & root_a) override diff --git a/nano/slow_test/node.cpp b/nano/slow_test/node.cpp index 0d03564aa4..8cec18da75 100644 --- a/nano/slow_test/node.cpp +++ b/nano/slow_test/node.cpp @@ -95,13 +95,12 @@ TEST (ledger, deep_account_compute) ASSERT_FALSE (store->init_error ()); nano::stat stats; nano::ledger ledger (*store, stats); - nano::genesis genesis; auto transaction (store->tx_begin_write ()); store->initialize (transaction, ledger.cache); nano::work_pool pool (std::numeric_limits::max ()); nano::keypair key; - auto balance (nano::dev::genesis_amount - 1); - nano::send_block send (genesis.hash (), key.pub, balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (genesis.hash ())); + auto balance (nano::dev::constants.genesis_amount - 1); + nano::send_block send (nano::dev::genesis->hash (), key.pub, balance, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (nano::dev::genesis->hash ())); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); nano::open_block open (send.hash (), nano::dev::genesis_key.pub, key.pub, key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, open).code); @@ -146,7 +145,7 @@ TEST (wallet, multithreaded_send_async) } })); } - ASSERT_TIMELY (1000s, system.nodes[0]->balance (nano::dev::genesis_key.pub) == (nano::dev::genesis_amount - 20 * 1000 * 1000)); + ASSERT_TIMELY (1000s, system.nodes[0]->balance (nano::dev::genesis_key.pub) == (nano::dev::constants.genesis_amount - 20 * 1000 * 1000)); } for (auto i (threads.begin ()), n (threads.end ()); i != n; ++i) { @@ -488,7 +487,7 @@ TEST (node, mass_vote_by_hash) std::vector> blocks; for (auto i (0); i < 10000; ++i) { - auto block (std::make_shared (nano::dev::genesis_key.pub, previous, nano::dev::genesis_key.pub, nano::dev::genesis_amount - (i + 1) * nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous))); + auto block (std::make_shared (nano::dev::genesis_key.pub, previous, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - (i + 1) * nano::Gxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous))); previous = block->hash (); blocks.push_back (block); } @@ -647,7 +646,7 @@ TEST (confirmation_height, long_chains) auto const num_blocks = nano::confirmation_height::unbounded_cutoff * 2 + 50; // First open the other account - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio + num_blocks + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio + num_blocks + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); nano::open_block open (send.hash (), nano::dev::genesis->account (), key1.pub, key1.prv, key1.pub, *system.work.generate (key1.pub)); { auto transaction = node->store.tx_begin_write (); @@ -662,7 +661,7 @@ TEST (confirmation_height, long_chains) auto transaction = node->store.tx_begin_write (); for (auto i = num_blocks - 1; i > 0; --i) { - nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio + i + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash)); + nano::send_block send (previous_genesis_chain_hash, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio + i + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); nano::receive_block receive (previous_destination_chain_hash, send.hash (), key1.prv, key1.pub, *system.work.generate (previous_destination_chain_hash)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, receive).code); @@ -674,11 +673,11 @@ TEST (confirmation_height, long_chains) // Send one from destination to genesis and pocket it nano::send_block send1 (previous_destination_chain_hash, nano::dev::genesis_key.pub, nano::Gxrb_ratio - 2, key1.prv, key1.pub, *system.work.generate (previous_destination_chain_hash)); - auto receive1 (std::make_shared (nano::dev::genesis_key.pub, previous_genesis_chain_hash, nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio + 1, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash))); + auto receive1 (std::make_shared (nano::dev::genesis_key.pub, previous_genesis_chain_hash, nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio + 1, send1.hash (), nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (previous_genesis_chain_hash))); // Unpocketed. Send to a non-existing account to prevent auto receives from the wallet adjusting expected confirmation height nano::keypair key2; - nano::state_block send2 (nano::dev::genesis->account (), receive1->hash (), nano::dev::genesis->account (), nano::dev::genesis_amount - nano::Gxrb_ratio, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive1->hash ())); + nano::state_block send2 (nano::dev::genesis->account (), receive1->hash (), nano::dev::genesis->account (), nano::dev::constants.genesis_amount - nano::Gxrb_ratio, key2.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (receive1->hash ())); { auto transaction = node->store.tx_begin_write (); @@ -734,11 +733,11 @@ TEST (confirmation_height, dynamic_algorithm) nano::keypair key; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); auto const num_blocks = nano::confirmation_height::unbounded_cutoff; - auto latest_genesis = nano::genesis ().open; + auto latest_genesis = nano::dev::genesis; std::vector> state_blocks; for (auto i = 0; i < num_blocks; ++i) { - auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis->hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - i - 1, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis->hash ()))); + auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - i - 1, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis->hash ()))); latest_genesis = send; state_blocks.push_back (send); } @@ -794,7 +793,7 @@ TEST (confirmation_height, dynamic_algorithm_no_transition_while_pending) auto add_block_to_genesis_chain = [&] (nano::write_transaction & transaction) { static int num = 0; - auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis, nano::dev::genesis_key.pub, nano::dev::genesis_amount - num - 1, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis))); + auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - num - 1, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis))); latest_genesis = send->hash (); state_blocks.push_back (send); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *send).code); @@ -873,7 +872,7 @@ TEST (confirmation_height, many_accounts_send_receive_self) nano::keypair key; keys.emplace_back (key); - nano::send_block send (latest_genesis, key.pub, nano::dev::genesis_amount - 1 - i, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis)); + nano::send_block send (latest_genesis, key.pub, nano::dev::constants.genesis_amount - 1 - i, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); auto open = std::make_shared (send.hash (), nano::dev::genesis_key.pub, key.pub, key.prv, key.pub, *system.work.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, *open).code); @@ -966,7 +965,6 @@ TEST (confirmation_height, many_accounts_send_receive_self_no_elections) auto path (nano::unique_path ()); auto store = nano::make_store (logger, path); ASSERT_TRUE (!store->init_error ()); - nano::genesis genesis; nano::stat stats; nano::ledger ledger (*store, stats); nano::write_database_queue write_database_queue (false); @@ -994,7 +992,7 @@ TEST (confirmation_height, many_accounts_send_receive_self_no_elections) { nano::keypair key; keys.emplace_back (key); - nano::send_block send (latest_genesis, key.pub, nano::dev::genesis_amount - 1 - i, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (latest_genesis)); + nano::send_block send (latest_genesis, key.pub, nano::dev::constants.genesis_amount - 1 - i, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *pool.generate (latest_genesis)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, send).code); auto open = std::make_shared (send.hash (), nano::dev::genesis_key.pub, key.pub, key.prv, key.pub, *pool.generate (key.pub)); ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *open).code); @@ -1305,14 +1303,13 @@ TEST (telemetry, under_load) auto node = system.add_node (node_config, node_flags); node_config.peering_port = nano::get_available_port (); auto node1 = system.add_node (node_config, node_flags); - nano::genesis genesis; nano::keypair key; nano::keypair key1; system.wallet (0)->insert_adhoc (nano::dev::genesis_key.prv); system.wallet (0)->insert_adhoc (key.prv); auto latest_genesis = node->latest (nano::dev::genesis_key.pub); auto num_blocks = 150000; - auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis, nano::dev::genesis_key.pub, nano::dev::genesis_amount - num_blocks, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis))); + auto send (std::make_shared (nano::dev::genesis_key.pub, latest_genesis, nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - num_blocks, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest_genesis))); node->process_active (send); latest_genesis = send->hash (); auto open (std::make_shared (key.pub, 0, key.pub, num_blocks, send->hash (), key.prv, key.pub, *system.work.generate (key.pub))); @@ -1329,7 +1326,7 @@ TEST (telemetry, under_load) } }; - std::thread thread1 (thread_func, nano::dev::genesis_key, latest_genesis, nano::dev::genesis_amount - num_blocks); + std::thread thread1 (thread_func, nano::dev::genesis_key, latest_genesis, nano::dev::constants.genesis_amount - num_blocks); std::thread thread2 (thread_func, key, latest_key, num_blocks); ASSERT_TIMELY (200s, node1->ledger.cache.block_count == num_blocks * 2 + 3); @@ -1446,8 +1443,7 @@ TEST (telemetry, many_nodes) // Give all nodes a non-default number of blocks nano::keypair key; - nano::genesis genesis; - nano::state_block send (nano::dev::genesis_key.pub, genesis.hash (), nano::dev::genesis_key.pub, nano::dev::genesis_amount - nano::Mxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (genesis.hash ())); + nano::state_block send (nano::dev::genesis_key.pub, nano::dev::genesis->hash (), nano::dev::genesis_key.pub, nano::dev::constants.genesis_amount - nano::Mxrb_ratio, key.pub, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (nano::dev::genesis->hash ())); for (auto node : system.nodes) { auto transaction (node->store.tx_begin_write ()); @@ -1497,7 +1493,7 @@ TEST (telemetry, many_nodes) ASSERT_EQ (data.pre_release_version, nano::get_pre_release_node_version ()); ASSERT_EQ (data.maker, 0); ASSERT_LT (data.uptime, 100); - ASSERT_EQ (data.genesis_block, genesis.hash ()); + ASSERT_EQ (data.genesis_block, nano::dev::genesis->hash ()); ASSERT_LE (data.timestamp, std::chrono::system_clock::now ()); ASSERT_EQ (data.active_difficulty, system.nodes.front ()->default_difficulty (nano::work_version::work_1)); } @@ -1724,7 +1720,6 @@ TEST (node, mass_block_new) } }; - nano::genesis genesis; nano::keypair key; std::vector keys (num_blocks); nano::state_block_builder builder; @@ -1736,7 +1731,7 @@ TEST (node, mass_block_new) auto send = builder.make_block () .account (nano::dev::genesis_key.pub) .previous (latest_genesis) - .balance (nano::dev::genesis_amount - i - 1) + .balance (nano::dev::constants.genesis_amount - i - 1) .representative (nano::dev::genesis_key.pub) .link (keys[i].pub) .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) @@ -1834,7 +1829,7 @@ TEST (node, wallet_create_block_confirm_conflicts) auto transaction = node->store.tx_begin_write (); for (auto i = num_blocks - 1; i > 0; --i) { - nano::send_block send (latest, key1.pub, nano::dev::genesis_amount - nano::Gxrb_ratio + i + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); + nano::send_block send (latest, key1.pub, nano::dev::constants.genesis_amount - nano::Gxrb_ratio + i + 1, nano::dev::genesis_key.prv, nano::dev::genesis_key.pub, *system.work.generate (latest)); ASSERT_EQ (nano::process_result::progress, node->ledger.process (transaction, send).code); latest = send.hash (); } diff --git a/nano/test_common/system.cpp b/nano/test_common/system.cpp index 56d996cf0a..2f3c2dbf7b 100644 --- a/nano/test_common/system.cpp +++ b/nano/test_common/system.cpp @@ -152,8 +152,8 @@ nano::system::~system () void nano::system::ledger_initialization_set (std::vector const & reps, nano::amount const & reserve) { nano::block_hash previous = nano::dev::genesis->hash (); - auto amount = (nano::dev::genesis_amount - reserve.number ()) / reps.size (); - auto balance = nano::dev::genesis_amount; + auto amount = (nano::dev::constants.genesis_amount - reserve.number ()) / reps.size (); + auto balance = nano::dev::constants.genesis_amount; for (auto const & i : reps) { balance -= amount; @@ -365,8 +365,7 @@ void nano::system::generate_rollback (nano::node & node_a, std::vectorhash ()) { accounts_a[index] = accounts_a[accounts_a.size () - 1]; accounts_a.pop_back (); @@ -398,7 +397,7 @@ void nano::system::generate_receive (nano::node & node_a) } if (send_block != nullptr) { - auto receive_error (wallet (0)->receive_sync (send_block, nano::ledger_constants (nano::networks::nano_dev_network).genesis_account (), std::numeric_limits::max ())); + auto receive_error (wallet (0)->receive_sync (send_block, nano::dev::genesis->account (), std::numeric_limits::max ())); (void)receive_error; } } diff --git a/nano/test_common/telemetry.cpp b/nano/test_common/telemetry.cpp index fc2d2dd0a4..2ecc2897a1 100644 --- a/nano/test_common/telemetry.cpp +++ b/nano/test_common/telemetry.cpp @@ -13,7 +13,7 @@ void nano::compare_default_telemetry_response_data_excluding_signature (nano::te ASSERT_EQ (telemetry_data_a.unchecked_count, 0); ASSERT_EQ (telemetry_data_a.account_count, 1); ASSERT_LT (telemetry_data_a.uptime, 100); - ASSERT_EQ (telemetry_data_a.genesis_block, network_params_a.ledger.genesis_hash ()); + ASSERT_EQ (telemetry_data_a.genesis_block, network_params_a.ledger.genesis->hash ()); ASSERT_EQ (telemetry_data_a.major_version, nano::get_major_node_version ()); ASSERT_EQ (telemetry_data_a.minor_version, nano::get_minor_node_version ()); ASSERT_EQ (telemetry_data_a.patch_version, nano::get_patch_node_version ());