Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move and rename several classes to organise them by function. #4323

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <nano/lib/utility.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/common.hpp>
#include <nano/node/make_store.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/utility.hpp>
#include <nano/store/account.hpp>
#include <nano/store/block.hpp>
#include <nano/store/lmdb/lmdb.hpp>
#include <nano/store/rocksdb/rocksdb.hpp>
#include <nano/store/lmdb/component.hpp>
#include <nano/store/make_store.hpp>
#include <nano/store/rocksdb/component.hpp>
#include <nano/store/versioning.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/bootstrap_ascending.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/lib/stats.hpp>
#include <nano/node/bootstrap_ascending/service.hpp>
#include <nano/node/make_store.hpp>
#include <nano/store/make_store.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down
36 changes: 18 additions & 18 deletions nano/core_test/confirmation_height.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/store/make_store.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down Expand Up @@ -1166,7 +1166,7 @@ TEST (confirmation_heightDeathTest, rollback_added_block)
ASSERT_TRUE (!store->init_error ());
nano::stats stats;
nano::ledger ledger (*store, stats, nano::dev::constants);
nano::write_database_queue write_database_queue (false);
nano::store::write_database_queue write_database_queue (false);
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::keypair key1;
nano::block_builder builder;
Expand Down Expand Up @@ -1258,7 +1258,7 @@ TEST (confirmation_heightDeathTest, modified_chain)
ASSERT_TRUE (!store->init_error ());
nano::stats stats;
nano::ledger ledger (*store, stats, nano::dev::constants);
nano::write_database_queue write_database_queue (false);
nano::store::write_database_queue write_database_queue (false);
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::keypair key1;
nano::block_builder builder;
Expand All @@ -1283,14 +1283,14 @@ TEST (confirmation_heightDeathTest, modified_chain)

{
// This reads the blocks in the account, but prevents any writes from occuring yet
auto scoped_write_guard = write_database_queue.wait (nano::writer::testing);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::testing);
bounded_processor.process (send);
}

// Rollback the block and now try to write, the block no longer exists so should bail
ledger.rollback (store->tx_begin_write (), send->hash ());
{
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::confirmation_height);
ASSERT_DEATH_IF_SUPPORTED (bounded_processor.cement_blocks (scoped_write_guard), "");
}

Expand All @@ -1302,14 +1302,14 @@ TEST (confirmation_heightDeathTest, modified_chain)

{
// This reads the blocks in the account, but prevents any writes from occuring yet
auto scoped_write_guard = write_database_queue.wait (nano::writer::testing);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::testing);
unbounded_processor.process (send);
}

// Rollback the block and now try to write, the block no longer exists so should bail
ledger.rollback (store->tx_begin_write (), send->hash ());
{
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::confirmation_height);
ASSERT_DEATH_IF_SUPPORTED (unbounded_processor.cement_blocks (scoped_write_guard), "");
}
}
Expand All @@ -1336,7 +1336,7 @@ TEST (confirmation_heightDeathTest, modified_chain_account_removed)
ASSERT_TRUE (!store->init_error ());
nano::stats stats;
nano::ledger ledger (*store, stats, nano::dev::constants);
nano::write_database_queue write_database_queue (false);
nano::store::write_database_queue write_database_queue (false);
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::keypair key1;
nano::block_builder builder;
Expand Down Expand Up @@ -1372,14 +1372,14 @@ TEST (confirmation_heightDeathTest, modified_chain_account_removed)

{
// This reads the blocks in the account, but prevents any writes from occuring yet
auto scoped_write_guard = write_database_queue.wait (nano::writer::testing);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::testing);
unbounded_processor.process (open);
}

// Rollback the block and now try to write, the send should be cemented but the account which the open block belongs no longer exists so should bail
ledger.rollback (store->tx_begin_write (), open->hash ());
{
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::confirmation_height);
ASSERT_DEATH_IF_SUPPORTED (unbounded_processor.cement_blocks (scoped_write_guard), "");
}

Expand All @@ -1392,13 +1392,13 @@ TEST (confirmation_heightDeathTest, modified_chain_account_removed)

{
// This reads the blocks in the account, but prevents any writes from occuring yet
auto scoped_write_guard = write_database_queue.wait (nano::writer::testing);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::testing);
bounded_processor.process (open);
}

// Rollback the block and now try to write, the send should be cemented but the account which the open block belongs no longer exists so should bail
ledger.rollback (store->tx_begin_write (), open->hash ());
auto scoped_write_guard = write_database_queue.wait (nano::writer::confirmation_height);
auto scoped_write_guard = write_database_queue.wait (nano::store::writer::confirmation_height);
ASSERT_DEATH_IF_SUPPORTED (bounded_processor.cement_blocks (scoped_write_guard), "");
}
}
Expand Down Expand Up @@ -1508,7 +1508,7 @@ TEST (confirmation_height, callback_confirmed_history)
node->block_processor.flush ();

// The write guard prevents the confirmation height processor doing any writes
auto write_guard = node->write_database_queue.wait (nano::writer::testing);
auto write_guard = node->write_database_queue.wait (nano::store::writer::testing);

// Confirm send1
auto election = node->active.election (send1->qualified_root ());
Expand All @@ -1521,13 +1521,13 @@ TEST (confirmation_height, callback_confirmed_history)
auto transaction = node->store.tx_begin_read ();
ASSERT_FALSE (node->ledger.block_confirmed (transaction, send->hash ()));

ASSERT_TIMELY (10s, node->write_database_queue.contains (nano::writer::confirmation_height));
ASSERT_TIMELY (10s, node->write_database_queue.contains (nano::store::writer::confirmation_height));

// Confirm that no inactive callbacks have been called when the confirmation height processor has already iterated over it, waiting to write
ASSERT_EQ (0, node->stats.count (nano::stat::type::confirmation_observer, nano::stat::detail::inactive_conf_height, nano::stat::dir::out));
}

ASSERT_TIMELY (10s, !node->write_database_queue.contains (nano::writer::confirmation_height));
ASSERT_TIMELY (10s, !node->write_database_queue.contains (nano::store::writer::confirmation_height));

auto transaction = node->store.tx_begin_read ();
ASSERT_TRUE (node->ledger.block_confirmed (transaction, send->hash ()));
Expand Down Expand Up @@ -2047,7 +2047,7 @@ TEST (confirmation_height, unbounded_block_cache_iteration)
ASSERT_TRUE (!store->init_error ());
nano::stats stats;
nano::ledger ledger (*store, stats, nano::dev::constants);
nano::write_database_queue write_database_queue (false);
nano::store::write_database_queue write_database_queue (false);
boost::latch initialized_latch{ 0 };
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::logging logging;
Expand Down Expand Up @@ -2081,7 +2081,7 @@ TEST (confirmation_height, unbounded_block_cache_iteration)
timer.start ();
{
// Prevent conf height processor doing any writes, so that we can query is_processing_block correctly
auto write_guard = write_database_queue.wait (nano::writer::testing);
auto write_guard = write_database_queue.wait (nano::store::writer::testing);
// Add the frontier block
confirmation_height_processor.add (send1);

Expand Down Expand Up @@ -2113,7 +2113,7 @@ TEST (confirmation_height, pruned_source)
nano::stats stats;
nano::ledger ledger (*store, stats, nano::dev::constants);
ledger.pruning = true;
nano::write_database_queue write_database_queue (false);
nano::store::write_database_queue write_database_queue (false);
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::keypair key1, key2;
nano::block_builder builder;
Expand Down
4 changes: 2 additions & 2 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <nano/lib/stats.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/store/rocksdb/rocksdb.hpp>
#include <nano/store/make_store.hpp>
#include <nano/store/rocksdb/component.hpp>
#include <nano/test_common/ledger.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down
6 changes: 3 additions & 3 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <nano/lib/config.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/store/make_store.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down Expand Up @@ -3102,7 +3102,7 @@ TEST (node, block_processor_half_full)
.work (*node.work_generate_blocking (send2->hash ()))
.build_shared ();
// The write guard prevents block processor doing any writes
auto write_guard = node.write_database_queue.wait (nano::writer::testing);
auto write_guard = node.write_database_queue.wait (nano::store::writer::testing);
node.block_processor.add (send1);
ASSERT_FALSE (node.block_processor.half_full ());
node.block_processor.add (send2);
Expand Down Expand Up @@ -3499,7 +3499,7 @@ TEST (node, rollback_vote_self)

{
// The write guard prevents the block processor from performing the rollback
auto write_guard = node.write_database_queue.wait (nano::writer::testing);
auto write_guard = node.write_database_queue.wait (nano::store::writer::testing);

ASSERT_EQ (0, election->votes_with_weight ().size ());
// Vote with key to switch the winner
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/processor_service.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <nano/lib/stats.hpp>
#include <nano/lib/work.hpp>
#include <nano/node/make_store.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/utility.hpp>
#include <nano/store/component.hpp>
#include <nano/store/make_store.hpp>
#include <nano/test_common/testutil.hpp>

#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/request_aggregator.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/request_aggregator.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/node/voting/aggregator.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down
44 changes: 22 additions & 22 deletions nano/core_test/vote_cache.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nano/node/election.hpp>
#include <nano/node/vote_cache.hpp>
#include <nano/node/voting/cache.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>

Expand Down Expand Up @@ -36,8 +36,8 @@ nano::keypair create_rep (nano::uint128_t weight)

TEST (vote_cache, construction)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
ASSERT_EQ (0, vote_cache.size ());
ASSERT_TRUE (vote_cache.empty ());
auto hash1 = nano::test::random_hash ();
Expand All @@ -49,8 +49,8 @@ TEST (vote_cache, construction)
*/
TEST (vote_cache, insert_one_hash)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto rep1 = create_rep (7);
auto hash1 = nano::test::random_hash ();
Expand Down Expand Up @@ -79,8 +79,8 @@ TEST (vote_cache, insert_one_hash)
*/
TEST (vote_cache, insert_one_hash_many_votes)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto hash1 = nano::test::random_hash ();
auto rep1 = create_rep (7);
Expand Down Expand Up @@ -114,8 +114,8 @@ TEST (vote_cache, insert_one_hash_many_votes)
*/
TEST (vote_cache, insert_many_hashes_many_votes)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
// There will be 3 random hashes to vote for
auto hash1 = nano::test::random_hash ();
Expand Down Expand Up @@ -194,8 +194,8 @@ TEST (vote_cache, insert_many_hashes_many_votes)
*/
TEST (vote_cache, insert_duplicate)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto hash1 = nano::test::random_hash ();
auto rep1 = create_rep (9);
Expand All @@ -211,8 +211,8 @@ TEST (vote_cache, insert_duplicate)
*/
TEST (vote_cache, insert_newer)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto hash1 = nano::test::random_hash ();
auto rep1 = create_rep (9);
Expand All @@ -236,8 +236,8 @@ TEST (vote_cache, insert_newer)
*/
TEST (vote_cache, insert_older)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto hash1 = nano::test::random_hash ();
auto rep1 = create_rep (9);
Expand All @@ -259,8 +259,8 @@ TEST (vote_cache, insert_older)
*/
TEST (vote_cache, erase)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
auto hash1 = nano::test::random_hash ();
auto hash2 = nano::test::random_hash ();
Expand Down Expand Up @@ -299,9 +299,9 @@ TEST (vote_cache, erase)
TEST (vote_cache, overfill)
{
// Create a vote cache with max size set to 1024
nano::vote_cache_config cfg;
nano::voting::cache_config cfg;
cfg.max_size = 1024;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
const int count = 16 * 1024;
for (int n = 0; n < count; ++n)
Expand All @@ -324,8 +324,8 @@ TEST (vote_cache, overfill)
*/
TEST (vote_cache, overfill_entry)
{
nano::vote_cache_config cfg;
nano::vote_cache vote_cache{ cfg };
nano::voting::cache_config cfg;
nano::voting::cache vote_cache{ cfg };
vote_cache.rep_weight_query = rep_weight_query ();
const int count = 1024;
auto hash1 = nano::test::random_hash ();
Expand All @@ -336,4 +336,4 @@ TEST (vote_cache, overfill_entry)
vote_cache.vote (vote1->hashes.front (), vote1);
}
ASSERT_EQ (1, vote_cache.size ());
}
}
2 changes: 1 addition & 1 deletion nano/core_test/vote_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_processor.hpp>
#include <nano/node/voting/processor.hpp>
#include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down
Loading
Loading