Refactor shared testing code from core_test (#2775)
* Refactor shared testing code from core_test * Add telemetry testing files
This commit is contained in:
parent
7c9614ecf4
commit
125a8248ff
56 changed files with 223 additions and 211 deletions
|
@ -442,6 +442,7 @@ if (NANO_TEST OR RAIBLOCKS_TEST)
|
|||
set_target_properties(gtest PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/gtest/googletest/include")
|
||||
|
||||
add_subdirectory(nano/test_common)
|
||||
add_subdirectory(nano/core_test)
|
||||
add_subdirectory(nano/rpc_test)
|
||||
add_subdirectory(nano/slow_test)
|
||||
|
@ -526,7 +527,7 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
|
|||
nano/qt_test/entry.cpp
|
||||
nano/qt_test/qt.cpp)
|
||||
|
||||
target_link_libraries(qt_test gtest gtest_main qt Qt5::Test)
|
||||
target_link_libraries(qt_test test_common gtest gtest_main qt Qt5::Test)
|
||||
|
||||
set_target_properties (qt_test PROPERTIES COMPILE_FLAGS "-DQT_NO_KEYWORDS -DBOOST_ASIO_HAS_STD_ARRAY=1")
|
||||
endif ()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
add_executable (core_test
|
||||
core_test_main.cc
|
||||
testutil.hpp
|
||||
fakes/websocket_client.hpp
|
||||
fakes/work_peer.hpp
|
||||
active_transactions.cpp
|
||||
|
@ -8,14 +7,12 @@ add_executable (core_test
|
|||
block_store.cpp
|
||||
bootstrap.cpp
|
||||
cli.cpp
|
||||
common.hpp
|
||||
confirmation_height.cpp
|
||||
confirmation_solicitor.cpp
|
||||
conflicts.cpp
|
||||
difficulty.cpp
|
||||
distributed_work.cpp
|
||||
election.cpp
|
||||
entry.cpp
|
||||
epochs.cpp
|
||||
gap_cache.cpp
|
||||
ipc.cpp
|
||||
|
@ -51,4 +48,4 @@ target_compile_definitions(core_test
|
|||
-DBOOST_PROCESS_SUPPORTED=${BOOST_PROCESS_SUPPORTED}
|
||||
-DCI=${CI_TEST})
|
||||
|
||||
target_link_libraries (core_test node secure gtest libminiupnpc-static Boost::log_setup Boost::log Boost::boost)
|
||||
target_link_libraries (core_test node secure test_common gtest libminiupnpc-static Boost::log_setup Boost::log Boost::boost)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/secure/buffer.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/lib/lmdbconfig.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
|
@ -8,6 +7,7 @@
|
|||
#include <nano/secure/ledger.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/secure/versioning.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/bootstrap/bootstrap_frontier.hpp>
|
||||
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/cli.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace nano
|
||||
{
|
||||
inline void wait_peer_connections (nano::system & system_a)
|
||||
{
|
||||
auto wait_peer_count = [&system_a](bool in_memory) {
|
||||
auto num_nodes = system_a.nodes.size ();
|
||||
system_a.deadline_set (20s);
|
||||
size_t peer_count = 0;
|
||||
while (peer_count != num_nodes * (num_nodes - 1))
|
||||
{
|
||||
ASSERT_NO_ERROR (system_a.poll ());
|
||||
peer_count = std::accumulate (system_a.nodes.cbegin (), system_a.nodes.cend (), std::size_t{ 0 }, [in_memory](auto total, auto const & node) {
|
||||
if (in_memory)
|
||||
{
|
||||
return total += node->network.size ();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
return total += node->store.peer_count (transaction);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Do a pre-pass with in-memory containers to reduce IO if still in the process of connecting to peers
|
||||
wait_peer_count (true);
|
||||
wait_peer_count (false);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/confirmation_solicitor.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/work.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/fakes/work_peer.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/ipc_client.hpp>
|
||||
#include <nano/lib/tomlconfig.hpp>
|
||||
#include <nano/node/ipc/ipc_access_config.hpp>
|
||||
#include <nano/node/ipc/ipc_server.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/locks.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/lib/logger_mt.hpp>
|
||||
#include <nano/node/logging.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/transport/udp.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/secure/buffer.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/network_filter.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/transport/udp.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -3681,7 +3681,7 @@ TEST (node, dont_write_lock_node)
|
|||
write_lock_held_promise.get_future ().wait ();
|
||||
|
||||
// Check inactive node can finish executing while a write lock is open
|
||||
nano::inactive_node node (path);
|
||||
nano::inactive_node node (path, nano::inactive_node_flag_defaults ());
|
||||
finished_promise.set_value ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <nano/boost/asio/io_context.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/alarm.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/lib/work.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/ledger.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/request_aggregator.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/node/socket.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/common.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/telemetry.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/telemetry.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/timer.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/lib/rpcconfig.hpp>
|
||||
#include <nano/lib/tomlconfig.hpp>
|
||||
#include <nano/node/daemonconfig.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/vote_processor.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/node/lmdb/wallet_value.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/secure/versioning.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -108,7 +107,7 @@ TEST (wallets, reload)
|
|||
ASSERT_EQ (1, node1.wallets.items.size ());
|
||||
{
|
||||
nano::lock_guard<std::mutex> lock_wallet (node1.wallets.mutex);
|
||||
nano::inactive_node node (node1.application_path);
|
||||
nano::inactive_node node (node1.application_path, nano::inactive_node_flag_defaults ());
|
||||
auto wallet (node.node->wallets.create (one));
|
||||
ASSERT_NE (wallet, nullptr);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/core_test/common.hpp>
|
||||
#include <nano/core_test/fakes/websocket_client.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/websocket.hpp>
|
||||
#include <nano/test_common/telemetry.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -209,4 +209,7 @@ void force_nano_test_network ();
|
|||
|
||||
/** Checks if we are running inside a valgrind instance */
|
||||
bool running_within_valgrind ();
|
||||
|
||||
/** Set the active network to the test network */
|
||||
void force_nano_test_network ();
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
add_executable (load_test
|
||||
entry.cpp)
|
||||
|
||||
target_link_libraries (load_test node secure Boost::boost)
|
||||
target_link_libraries (load_test node secure test_common gtest Boost::boost)
|
||||
|
||||
target_compile_definitions(load_test
|
||||
PRIVATE
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include <nano/boost/asio/bind_executor.hpp>
|
||||
#include <nano/boost/asio/connect.hpp>
|
||||
#include <nano/boost/asio/ip/tcp.hpp>
|
||||
#include <nano/boost/asio/strand.hpp>
|
||||
#include <nano/boost/beast/core/flat_buffer.hpp>
|
||||
#include <nano/boost/beast/http.hpp>
|
||||
#include <nano/boost/process/child.hpp>
|
||||
#define IGNORE_GTEST_INCL
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/lib/tomlconfig.hpp>
|
||||
#include <nano/node/daemonconfig.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <nano/node/ipc/ipc_server.hpp>
|
||||
#include <nano/node/json_handler.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
@ -78,7 +77,6 @@ int main (int argc, char * const * argv)
|
|||
("debug_dump_online_weight", "Dump online_weights table")
|
||||
("debug_dump_representatives", "List representatives and weights")
|
||||
("debug_account_count", "Display the number of accounts")
|
||||
("debug_mass_activity", "(Deprecated) Generates fake debug activity. Can use slow_test's generate_mass_activity test for the same behavior.")
|
||||
("debug_profile_generate", "Profile work generation")
|
||||
("debug_profile_validate", "Profile work validation")
|
||||
("debug_opencl", "OpenCL work generation")
|
||||
|
@ -439,12 +437,6 @@ int main (int argc, char * const * argv)
|
|||
nano::inactive_node inactive_node (data_path, node_flags);
|
||||
std::cout << boost::str (boost::format ("Frontier count: %1%\n") % inactive_node.node->ledger.cache.account_count);
|
||||
}
|
||||
else if (vm.count ("debug_mass_activity"))
|
||||
{
|
||||
nano::system system (1);
|
||||
uint32_t count (1000000);
|
||||
system.generate_mass_activity (count, *system.nodes[0]);
|
||||
}
|
||||
else if (vm.count ("debug_profile_kdf"))
|
||||
{
|
||||
nano::network_params network_params;
|
||||
|
@ -910,14 +902,15 @@ int main (int argc, char * const * argv)
|
|||
size_t num_iterations (5); // 100,000 * 5 * 2 = 1,000,000 blocks
|
||||
size_t max_blocks (2 * num_accounts * num_iterations + num_accounts * 2); // 1,000,000 + 2 * 100,000 = 1,200,000 blocks
|
||||
std::cout << boost::str (boost::format ("Starting pregenerating %1% blocks\n") % max_blocks);
|
||||
nano::system system;
|
||||
boost::asio::io_context io_ctx;
|
||||
nano::alarm alarm (io_ctx);
|
||||
nano::work_pool work (std::numeric_limits<unsigned>::max ());
|
||||
nano::logging logging;
|
||||
auto path (nano::unique_path ());
|
||||
logging.init (path);
|
||||
nano::node_flags node_flags;
|
||||
nano::update_flags (node_flags, vm);
|
||||
auto node (std::make_shared<nano::node> (system.io_ctx, 24001, path, system.alarm, logging, work, node_flags));
|
||||
auto node (std::make_shared<nano::node> (io_ctx, 24001, path, alarm, logging, work, node_flags));
|
||||
nano::block_hash genesis_latest (node->latest (test_params.ledger.test_genesis_key.pub));
|
||||
nano::uint128_t genesis_balance (std::numeric_limits<nano::uint128_t>::max ());
|
||||
// Generating keys
|
||||
|
@ -1035,12 +1028,13 @@ int main (int argc, char * const * argv)
|
|||
size_t num_representatives (25);
|
||||
size_t max_votes (num_elections * num_representatives); // 40,000 * 25 = 1,000,000 votes
|
||||
std::cerr << boost::str (boost::format ("Starting pregenerating %1% votes\n") % max_votes);
|
||||
nano::system system (1);
|
||||
boost::asio::io_context io_ctx;
|
||||
nano::alarm alarm (io_ctx);
|
||||
nano::work_pool work (std::numeric_limits<unsigned>::max ());
|
||||
nano::logging logging;
|
||||
auto path (nano::unique_path ());
|
||||
logging.init (path);
|
||||
auto node (std::make_shared<nano::node> (system.io_ctx, 24001, path, system.alarm, logging, work));
|
||||
auto node (std::make_shared<nano::node> (io_ctx, 24001, path, alarm, logging, work));
|
||||
nano::block_hash genesis_latest (node->latest (test_params.ledger.test_genesis_key.pub));
|
||||
nano::uint128_t genesis_balance (std::numeric_limits<nano::uint128_t>::max ());
|
||||
// Generating keys
|
||||
|
@ -1741,7 +1735,7 @@ int main (int argc, char * const * argv)
|
|||
auto node_flags = nano::inactive_node_flag_defaults ();
|
||||
node_flags.read_only = false;
|
||||
nano::update_flags (node_flags, vm);
|
||||
nano::inactive_node node2 (nano::unique_path (), node_flags);
|
||||
nano::inactive_node node (nano::unique_path (), node_flags);
|
||||
nano::genesis genesis;
|
||||
auto begin (std::chrono::high_resolution_clock::now ());
|
||||
uint64_t block_count (0);
|
||||
|
@ -1769,7 +1763,7 @@ int main (int argc, char * const * argv)
|
|||
std::cout << boost::str (boost::format ("%1% blocks retrieved") % count) << std::endl;
|
||||
}
|
||||
nano::unchecked_info unchecked_info (block, account, 0, nano::signature_verification::unknown);
|
||||
node2.node->block_processor.add (unchecked_info);
|
||||
node->block_processor.add (unchecked_info);
|
||||
// Retrieving previous block hash
|
||||
hash = block->previous ();
|
||||
}
|
||||
|
@ -1777,14 +1771,14 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
}
|
||||
nano::timer<std::chrono::seconds> timer_l (nano::timer_state::started);
|
||||
while (node2.node->ledger.cache.block_count != block_count)
|
||||
while (node.node->ledger.cache.block_count != block_count)
|
||||
{
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds (50));
|
||||
// Message each 60 seconds
|
||||
if (timer_l.after_deadline (std::chrono::seconds (60)))
|
||||
{
|
||||
timer_l.restart ();
|
||||
std::cout << boost::str (boost::format ("%1% (%2%) blocks processed (unchecked)") % node2.node->ledger.cache.block_count % node2.node->ledger.cache.unchecked_count) << std::endl;
|
||||
std::cout << boost::str (boost::format ("%1% (%2%) blocks processed (unchecked)") % node.node->ledger.cache.block_count % node.node->ledger.cache.unchecked_count) << std::endl;
|
||||
}
|
||||
}
|
||||
// Waiting for final transaction commit
|
||||
|
@ -1792,8 +1786,8 @@ int main (int argc, char * const * argv)
|
|||
while (block_count_2 != block_count)
|
||||
{
|
||||
std::this_thread::sleep_for (std::chrono::milliseconds (50));
|
||||
auto transaction_2 (node2.node->store.tx_begin_read ());
|
||||
block_count_2 = node2.node->store.block_count (transaction_2).sum ();
|
||||
auto transaction_2 (node.node->store.tx_begin_read ());
|
||||
block_count_2 = node.node->store.block_count (transaction_2).sum ();
|
||||
}
|
||||
auto end (std::chrono::high_resolution_clock::now ());
|
||||
auto time (std::chrono::duration_cast<std::chrono::microseconds> (end - begin).count ());
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#define IGNORE_GTEST_INCL
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/lib/tomlconfig.hpp>
|
||||
#include <nano/lib/utility.hpp>
|
||||
|
@ -7,6 +5,7 @@
|
|||
#include <nano/node/daemonconfig.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/telemetry.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/websocket.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/secure/buffer.hpp>
|
||||
|
|
|
@ -219,7 +219,7 @@ nano::node_flags const & inactive_node_flag_defaults ();
|
|||
class inactive_node final
|
||||
{
|
||||
public:
|
||||
inactive_node (boost::filesystem::path const & path_a, nano::node_flags const & node_flags_a = nano::inactive_node_flag_defaults ());
|
||||
inactive_node (boost::filesystem::path const & path_a, nano::node_flags const & node_flags_a);
|
||||
~inactive_node ();
|
||||
std::shared_ptr<boost::asio::io_context> io_context;
|
||||
nano::alarm alarm;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#define IGNORE_GTEST_INCL
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
|
@ -9,6 +7,8 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
std::string nano::error_system_messages::message (int ev) const
|
||||
{
|
||||
switch (static_cast<nano::error_system> (ev))
|
||||
|
@ -176,19 +176,20 @@ uint64_t nano::system::work_generate_limited (nano::block_hash const & root_a, u
|
|||
std::unique_ptr<nano::state_block> nano::upgrade_epoch (nano::work_pool & pool_a, nano::ledger & ledger_a, nano::epoch epoch_a)
|
||||
{
|
||||
auto transaction (ledger_a.store.tx_begin_write ());
|
||||
auto account = nano::test_genesis_key.pub;
|
||||
auto test_genesis_key = nano::ledger_constants (nano::nano_networks::nano_test_network).test_genesis_key;
|
||||
auto account = test_genesis_key.pub;
|
||||
auto latest = ledger_a.latest (transaction, account);
|
||||
auto balance = ledger_a.account_balance (transaction, account);
|
||||
|
||||
nano::state_block_builder builder;
|
||||
std::error_code ec;
|
||||
auto epoch = builder
|
||||
.account (nano::test_genesis_key.pub)
|
||||
.account (test_genesis_key.pub)
|
||||
.previous (latest)
|
||||
.balance (balance)
|
||||
.link (ledger_a.epoch_link (epoch_a))
|
||||
.representative (nano::test_genesis_key.pub)
|
||||
.sign (nano::test_genesis_key.prv, nano::test_genesis_key.pub)
|
||||
.representative (test_genesis_key.pub)
|
||||
.sign (test_genesis_key.prv, test_genesis_key.pub)
|
||||
.work (*pool_a.generate (latest, nano::work_threshold (nano::work_version::work_1, nano::block_details (epoch_a, false, false, true))))
|
||||
.build (ec);
|
||||
|
||||
|
@ -339,7 +340,7 @@ void nano::system::generate_receive (nano::node & node_a)
|
|||
}
|
||||
if (send_block != nullptr)
|
||||
{
|
||||
auto receive_error (wallet (0)->receive_sync (send_block, nano::genesis_account, std::numeric_limits<nano::uint128_t>::max ()));
|
||||
auto receive_error (wallet (0)->receive_sync (send_block, nano::ledger_constants (nano::nano_networks::nano_test_network).genesis_account, std::numeric_limits<nano::uint128_t>::max ()));
|
||||
(void)receive_error;
|
||||
}
|
||||
}
|
||||
|
@ -464,8 +465,9 @@ void nano::system::generate_send_new (nano::node & node_a, std::vector<nano::acc
|
|||
void nano::system::generate_mass_activity (uint32_t count_a, nano::node & node_a)
|
||||
{
|
||||
std::vector<nano::account> accounts;
|
||||
wallet (0)->insert_adhoc (nano::test_genesis_key.prv);
|
||||
accounts.push_back (nano::test_genesis_key.pub);
|
||||
auto test_genesis_key = nano::ledger_constants (nano::nano_networks::nano_test_network).test_genesis_key;
|
||||
wallet (0)->insert_adhoc (test_genesis_key.prv);
|
||||
accounts.push_back (test_genesis_key.pub);
|
||||
auto previous (std::chrono::steady_clock::now ());
|
||||
for (uint32_t i (0); i < count_a; ++i)
|
||||
{
|
||||
|
@ -497,9 +499,31 @@ void nano::system::stop ()
|
|||
work.stop ();
|
||||
}
|
||||
|
||||
namespace nano
|
||||
uint16_t nano::get_available_port ()
|
||||
{
|
||||
void cleanup_test_directories_on_exit ()
|
||||
// Maximum possible sockets which may feasibly be used in 1 test
|
||||
constexpr auto max = 200;
|
||||
static uint16_t current = 0;
|
||||
// Read the TEST_BASE_PORT environment and override the default base port if it exists
|
||||
auto base_str = std::getenv ("TEST_BASE_PORT");
|
||||
uint16_t base_port = 24000;
|
||||
if (base_str)
|
||||
{
|
||||
base_port = boost::lexical_cast<uint16_t> (base_str);
|
||||
}
|
||||
|
||||
uint16_t const available_port = base_port + current;
|
||||
++current;
|
||||
// Reset port number once we have reached the maximum
|
||||
if (current == max)
|
||||
{
|
||||
current = 0;
|
||||
}
|
||||
|
||||
return available_port;
|
||||
}
|
||||
|
||||
void nano::cleanup_test_directories_on_exit ()
|
||||
{
|
||||
// Makes sure everything is cleaned up
|
||||
nano::logging::release_file_sink ();
|
||||
|
@ -511,4 +535,3 @@ void cleanup_test_directories_on_exit ()
|
|||
nano::remove_temporary_directories ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,5 +57,7 @@ public:
|
|||
};
|
||||
std::unique_ptr<nano::state_block> upgrade_epoch (nano::work_pool &, nano::ledger &, nano::epoch);
|
||||
void blocks_confirm (nano::node &, std::vector<std::shared_ptr<nano::block>> const &);
|
||||
uint16_t get_available_port ();
|
||||
void cleanup_test_directories_on_exit ();
|
||||
}
|
||||
REGISTER_ERROR_CODES (nano, error_system);
|
||||
|
|
|
@ -22,6 +22,7 @@ class logger_mt;
|
|||
class online_reps;
|
||||
class ledger;
|
||||
class network_params;
|
||||
class node_flags;
|
||||
|
||||
class transaction;
|
||||
namespace transport
|
||||
|
|
|
@ -8,10 +8,9 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
nano::network_constants::set_active_network (nano::nano_networks::nano_test_network);
|
||||
nano::force_nano_test_network ();
|
||||
nano::node_singleton_memory_pool_purge_guard memory_pool_cleanup_guard;
|
||||
QApplication application (argc, argv);
|
||||
QCoreApplication::setOrganizationName ("Nano");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/qt/qt.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ add_executable (rpc_test
|
|||
entry.cpp
|
||||
rpc.cpp)
|
||||
|
||||
target_link_libraries(rpc_test gtest rpc node)
|
||||
target_link_libraries(rpc_test node rpc test_common gtest)
|
||||
|
||||
target_compile_definitions(rpc_test
|
||||
PUBLIC
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <nano/boost/beast/core/flat_buffer.hpp>
|
||||
#include <nano/boost/beast/http.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/lib/rpcconfig.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/node/ipc/ipc_server.hpp>
|
||||
|
@ -9,6 +8,8 @@
|
|||
#include <nano/node/testing.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/rpc/rpc_request_processor.hpp>
|
||||
#include <nano/test_common/telemetry.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#define IGNORE_GTEST_INCL
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/lib/config.hpp>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
|
@ -165,21 +163,6 @@ nano::bootstrap_constants::bootstrap_constants (nano::network_constants & networ
|
|||
gap_cache_bootstrap_start_interval = network_constants.is_test_network () ? std::chrono::milliseconds (5) : std::chrono::milliseconds (30 * 1000);
|
||||
}
|
||||
|
||||
/* Convenience constants for core_test which is always on the test network */
|
||||
namespace
|
||||
{
|
||||
nano::ledger_constants test_constants (nano::nano_networks::nano_test_network);
|
||||
}
|
||||
|
||||
nano::keypair const & nano::zero_key (test_constants.zero_key);
|
||||
nano::keypair const & nano::test_genesis_key (test_constants.test_genesis_key);
|
||||
nano::account const & nano::nano_test_account (test_constants.nano_test_account);
|
||||
std::string const & nano::nano_test_genesis (test_constants.nano_test_genesis);
|
||||
nano::account const & nano::genesis_account (test_constants.genesis_account);
|
||||
nano::block_hash const & nano::genesis_hash (test_constants.genesis_hash);
|
||||
nano::uint128_t const & nano::genesis_amount (test_constants.genesis_amount);
|
||||
nano::account const & nano::burn_account (test_constants.burn_account);
|
||||
|
||||
// Create a new random keypair
|
||||
nano::keypair::keypair ()
|
||||
{
|
||||
|
|
|
@ -2,4 +2,4 @@ add_executable (slow_test
|
|||
entry.cpp
|
||||
node.cpp)
|
||||
|
||||
target_link_libraries (slow_test node secure gtest libminiupnpc-static Boost::boost)
|
||||
target_link_libraries (slow_test secure node test_common gtest libminiupnpc-static Boost::boost)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#include <nano/core_test/common.hpp>
|
||||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/lib/threading.hpp>
|
||||
#include <nano/node/election.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/transport/udp.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
7
nano/test_common/CMakeLists.txt
Normal file
7
nano/test_common/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
add_library (test_common
|
||||
telemetry.hpp
|
||||
telemetry.cpp
|
||||
testutil.hpp
|
||||
testutil.cpp)
|
||||
|
||||
target_link_libraries (test_common node gtest Boost::log_setup Boost::log Boost::boost)
|
36
nano/test_common/telemetry.cpp
Normal file
36
nano/test_common/telemetry.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <nano/node/common.hpp>
|
||||
#include <nano/test_common/telemetry.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
void nano::compare_default_telemetry_response_data_excluding_signature (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a)
|
||||
{
|
||||
ASSERT_EQ (telemetry_data_a.block_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.cemented_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.bandwidth_cap, bandwidth_limit_a);
|
||||
ASSERT_EQ (telemetry_data_a.peer_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.protocol_version, network_params_a.protocol.telemetry_protocol_version_min);
|
||||
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.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 ());
|
||||
ASSERT_EQ (telemetry_data_a.pre_release_version, nano::get_pre_release_node_version ());
|
||||
ASSERT_EQ (telemetry_data_a.maker, 0);
|
||||
ASSERT_GT (telemetry_data_a.timestamp, std::chrono::system_clock::now () - std::chrono::seconds (100));
|
||||
ASSERT_EQ (telemetry_data_a.active_difficulty, active_difficulty_a);
|
||||
}
|
||||
|
||||
void nano::compare_default_telemetry_response_data (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a, nano::keypair const & node_id_a)
|
||||
{
|
||||
ASSERT_FALSE (telemetry_data_a.validate_signature (nano::telemetry_data::size));
|
||||
nano::telemetry_data telemetry_data_l = telemetry_data_a;
|
||||
telemetry_data_l.signature.clear ();
|
||||
telemetry_data_l.sign (node_id_a);
|
||||
// Signature should be different because uptime/timestamp will have changed.
|
||||
ASSERT_NE (telemetry_data_a.signature, telemetry_data_l.signature);
|
||||
compare_default_telemetry_response_data_excluding_signature (telemetry_data_a, network_params_a, bandwidth_limit_a, active_difficulty_a);
|
||||
ASSERT_EQ (telemetry_data_a.node_id, node_id_a.pub);
|
||||
}
|
13
nano/test_common/telemetry.hpp
Normal file
13
nano/test_common/telemetry.hpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace nano
|
||||
{
|
||||
class keypair;
|
||||
class network_params;
|
||||
class telemetry_data;
|
||||
|
||||
void compare_default_telemetry_response_data_excluding_signature (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a);
|
||||
void compare_default_telemetry_response_data (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a, nano::keypair const & node_id_a);
|
||||
}
|
53
nano/test_common/testutil.cpp
Normal file
53
nano/test_common/testutil.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/test_common/testutil.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <numeric>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/* Convenience constants for tests which are always on the test network */
|
||||
namespace
|
||||
{
|
||||
nano::ledger_constants test_constants (nano::nano_networks::nano_test_network);
|
||||
}
|
||||
|
||||
nano::keypair const & nano::zero_key (test_constants.zero_key);
|
||||
nano::keypair const & nano::test_genesis_key (test_constants.test_genesis_key);
|
||||
nano::account const & nano::nano_test_account (test_constants.nano_test_account);
|
||||
std::string const & nano::nano_test_genesis (test_constants.nano_test_genesis);
|
||||
nano::account const & nano::genesis_account (test_constants.genesis_account);
|
||||
nano::block_hash const & nano::genesis_hash (test_constants.genesis_hash);
|
||||
nano::uint128_t const & nano::genesis_amount (test_constants.genesis_amount);
|
||||
nano::account const & nano::burn_account (test_constants.burn_account);
|
||||
|
||||
void nano::wait_peer_connections (nano::system & system_a)
|
||||
{
|
||||
auto wait_peer_count = [&system_a](bool in_memory) {
|
||||
auto num_nodes = system_a.nodes.size ();
|
||||
system_a.deadline_set (20s);
|
||||
size_t peer_count = 0;
|
||||
while (peer_count != num_nodes * (num_nodes - 1))
|
||||
{
|
||||
ASSERT_NO_ERROR (system_a.poll ());
|
||||
peer_count = std::accumulate (system_a.nodes.cbegin (), system_a.nodes.cend (), std::size_t{ 0 }, [in_memory](auto total, auto const & node) {
|
||||
if (in_memory)
|
||||
{
|
||||
return total += node->network.size ();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
return total += node->store.peer_count (transaction);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Do a pre-pass with in-memory containers to reduce IO if still in the process of connecting to peers
|
||||
wait_peer_count (true);
|
||||
wait_peer_count (false);
|
||||
}
|
|
@ -1,22 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/errors.hpp>
|
||||
#include <nano/lib/locks.hpp>
|
||||
#include <nano/lib/timer.hpp>
|
||||
|
||||
// This test header is unfortunately included in many different files.
|
||||
// Requires guarding in some cases.
|
||||
#ifndef IGNORE_GTEST_INCL
|
||||
#include <nano/node/common.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/concepts.hpp>
|
||||
#include <boost/log/sinks/text_ostream_backend.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
@ -48,13 +42,17 @@
|
|||
ASSERT_NO_ERROR (system.poll ()); \
|
||||
}
|
||||
|
||||
/* Convenience globals for core_test */
|
||||
/* Convenience globals for gtest projects */
|
||||
namespace nano
|
||||
{
|
||||
using uint128_t = boost::multiprecision::uint128_t;
|
||||
class keypair;
|
||||
class public_key;
|
||||
class block_hash;
|
||||
class telemetry_data;
|
||||
class network_params;
|
||||
class system;
|
||||
|
||||
extern nano::keypair const & zero_key;
|
||||
extern nano::keypair const & test_genesis_key;
|
||||
extern std::string const & nano_test_genesis;
|
||||
|
@ -214,61 +212,5 @@ namespace util
|
|||
};
|
||||
}
|
||||
|
||||
inline uint16_t get_available_port ()
|
||||
{
|
||||
// Maximum possible sockets which may feasibly be used in 1 test
|
||||
constexpr auto max = 200;
|
||||
static uint16_t current = 0;
|
||||
// Read the TEST_BASE_PORT environment and override the default base port if it exists
|
||||
auto base_str = std::getenv ("TEST_BASE_PORT");
|
||||
uint16_t base_port = 24000;
|
||||
if (base_str)
|
||||
{
|
||||
base_port = boost::lexical_cast<uint16_t> (base_str);
|
||||
}
|
||||
|
||||
uint16_t const available_port = base_port + current;
|
||||
++current;
|
||||
// Reset port number once we have reached the maximum
|
||||
if (current == max)
|
||||
{
|
||||
current = 0;
|
||||
}
|
||||
|
||||
return available_port;
|
||||
}
|
||||
|
||||
#ifndef IGNORE_GTEST_INCL
|
||||
inline void compare_default_telemetry_response_data_excluding_signature (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a)
|
||||
{
|
||||
ASSERT_EQ (telemetry_data_a.block_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.cemented_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.bandwidth_cap, bandwidth_limit_a);
|
||||
ASSERT_EQ (telemetry_data_a.peer_count, 1);
|
||||
ASSERT_EQ (telemetry_data_a.protocol_version, network_params_a.protocol.telemetry_protocol_version_min);
|
||||
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.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 ());
|
||||
ASSERT_EQ (telemetry_data_a.pre_release_version, nano::get_pre_release_node_version ());
|
||||
ASSERT_EQ (telemetry_data_a.maker, 0);
|
||||
ASSERT_GT (telemetry_data_a.timestamp, std::chrono::system_clock::now () - std::chrono::seconds (100));
|
||||
ASSERT_EQ (telemetry_data_a.active_difficulty, active_difficulty_a);
|
||||
}
|
||||
|
||||
inline void compare_default_telemetry_response_data (nano::telemetry_data const & telemetry_data_a, nano::network_params const & network_params_a, uint64_t bandwidth_limit_a, uint64_t active_difficulty_a, nano::keypair const & node_id_a)
|
||||
{
|
||||
ASSERT_FALSE (telemetry_data_a.validate_signature (nano::telemetry_data::size));
|
||||
nano::telemetry_data telemetry_data_l = telemetry_data_a;
|
||||
telemetry_data_l.signature.clear ();
|
||||
telemetry_data_l.sign (node_id_a);
|
||||
// Signature should be different because uptime/timestamp will have changed.
|
||||
ASSERT_NE (telemetry_data_a.signature, telemetry_data_l.signature);
|
||||
compare_default_telemetry_response_data_excluding_signature (telemetry_data_a, network_params_a, bandwidth_limit_a, active_difficulty_a);
|
||||
ASSERT_EQ (telemetry_data_a.node_id, node_id_a.pub);
|
||||
}
|
||||
#endif
|
||||
void wait_peer_connections (nano::system &);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue