From 1c59386b16256bc2b3e2777ab5ba36d6e4850e07 Mon Sep 17 00:00:00 2001 From: battlmonstr Date: Sat, 1 Jul 2023 13:02:09 +0200 Subject: [PATCH] infra_test_util library with TaskRunner (#1300) --- cmd/test/CMakeLists.txt | 8 --- silkworm/infra/CMakeLists.txt | 28 ++++++-- silkworm/infra/common/log_test.cpp | 21 ++---- .../awaitable_condition_variable_test.cpp | 58 ++++++---------- .../infra/concurrency/context_pool_test.cpp | 8 +-- silkworm/infra/concurrency/timeout_test.cpp | 20 ++---- .../grpc/client/client_context_pool_test.cpp | 14 ++-- silkworm/infra/grpc/common/util_test.cpp | 4 +- silkworm/infra/grpc/common/version_test.cpp | 4 +- silkworm/infra/grpc/server/call_test.cpp | 4 +- .../grpc/server/server_context_pool_test.cpp | 8 +-- .../grpc/server/server_settings_test.cpp | 4 +- silkworm/infra/grpc/server/server_test.cpp | 12 ++-- silkworm/infra/test_util/CMakeLists.txt | 25 +++++++ silkworm/infra/{test => test_util}/log.hpp | 4 +- silkworm/infra/test_util/task_runner.hpp | 67 +++++++++++++++++++ .../backend/remote/backend_kv_server_test.cpp | 6 +- silkworm/node/bittorrent/client_test.cpp | 8 +-- silkworm/node/db/access_layer_test.cpp | 30 ++++----- silkworm/node/db/buffer_test.cpp | 6 +- .../node/db/memory_mutation_cursor_test.cpp | 4 +- silkworm/node/etl/collector_test.cpp | 8 +-- silkworm/node/huffman/decompressor_test.cpp | 22 +++--- .../recsplit/encoding/elias_fano_test.cpp | 6 +- .../recsplit/encoding/golomb_rice_test.cpp | 4 +- .../node/recsplit/encoding/sequence_test.cpp | 4 +- silkworm/node/recsplit/rec_split_test.cpp | 16 ++--- silkworm/node/snapshot/index_test.cpp | 12 ++-- silkworm/node/snapshot/repository_test.cpp | 10 +-- silkworm/node/snapshot/snapshot_test.cpp | 12 ++-- silkworm/node/snapshot/sync_test.cpp | 6 +- .../node/stagedsync/execution_engine_test.cpp | 4 +- silkworm/node/stagedsync/forks/fork_test.cpp | 4 +- .../node/stagedsync/forks/main_chain_test.cpp | 4 +- .../node/stagedsync/local_client_test.cpp | 4 +- .../node/stagedsync/remote_client_test.cpp | 4 +- silkworm/node/stagedsync/stages/_test.cpp | 4 +- .../stages/stage_history_index_test.cpp | 6 +- .../sentry/discovery/node_db/CMakeLists.txt | 6 +- .../discovery/node_db/node_db_sqlite_test.cpp | 57 +++++----------- silkworm/silkrpc/commands/debug_api_test.cpp | 4 +- silkworm/silkrpc/commands/engine_api_test.cpp | 38 +++++------ silkworm/silkrpc/commands/trace_api_test.cpp | 4 +- silkworm/silkrpc/common/util_test.cpp | 22 +++--- silkworm/silkrpc/core/account_dumper_test.cpp | 4 +- silkworm/silkrpc/core/blocks_test.cpp | 4 +- silkworm/silkrpc/core/cached_chain_test.cpp | 12 ++-- .../silkrpc/core/estimate_gas_oracle_test.cpp | 6 +- silkworm/silkrpc/core/evm_executor_test.cpp | 4 +- silkworm/silkrpc/core/evm_trace_test.cpp | 38 +++++------ .../silkrpc/core/fee_history_oracle_test.cpp | 4 +- silkworm/silkrpc/core/filter_storage_test.cpp | 6 +- silkworm/silkrpc/core/rawdb/chain_test.cpp | 50 +++++++------- silkworm/silkrpc/core/remote_state_test.cpp | 4 +- silkworm/silkrpc/ethdb/cbor_test.cpp | 28 ++++---- .../silkrpc/ethdb/kv/state_cache_test.cpp | 14 ++-- .../ethdb/kv/state_changes_stream_test.cpp | 4 +- silkworm/silkrpc/grpc/util_test.cpp | 6 +- silkworm/silkrpc/http/connection_test.cpp | 4 +- silkworm/silkrpc/http/jwt_test.cpp | 6 +- silkworm/silkrpc/http/server_test.cpp | 4 +- silkworm/silkrpc/json/stream_test.cpp | 6 +- silkworm/silkrpc/test/context_test_base.hpp | 4 +- silkworm/silkrpc/types/block_test.cpp | 4 +- silkworm/silkrpc/types/chain_config_test.cpp | 4 +- silkworm/silkrpc/types/dump_account_test.cpp | 8 +-- silkworm/silkrpc/types/error_test.cpp | 6 +- .../silkrpc/types/execution_payload_test.cpp | 24 +++---- silkworm/silkrpc/types/issuance_test.cpp | 4 +- silkworm/silkrpc/types/log_test.cpp | 4 +- silkworm/silkrpc/types/receipt_test.cpp | 6 +- silkworm/silkrpc/types/transaction_test.cpp | 12 ++-- silkworm/silkrpc/types/writer_test.cpp | 6 +- .../internals/header_chain_plus_exec_test.cpp | 4 +- silkworm/sync/internals/header_chain_test.cpp | 28 ++++---- 75 files changed, 486 insertions(+), 436 deletions(-) create mode 100644 silkworm/infra/test_util/CMakeLists.txt rename silkworm/infra/{test => test_util}/log.hpp (96%) create mode 100644 silkworm/infra/test_util/task_runner.hpp diff --git a/cmd/test/CMakeLists.txt b/cmd/test/CMakeLists.txt index 62a98f80cd..77c59ccd85 100644 --- a/cmd/test/CMakeLists.txt +++ b/cmd/test/CMakeLists.txt @@ -32,14 +32,6 @@ endif() if(NOT SILKWORM_CORE_ONLY) find_package(GTest REQUIRED) - # Silkworm Infra Tests - file(GLOB_RECURSE SILKWORM_INFRA_TESTS CONFIGURE_DEPENDS "${SILKWORM_MAIN_SRC_DIR}/infra/*_test.cpp") - add_executable(infra_test "unit_test.cpp;${SILKWORM_INFRA_TESTS}") - if(SILKWORM_SANITIZE) - target_compile_definitions(infra_test PRIVATE GRPC_ASAN_SUPPRESSED GRPC_TSAN_SUPPRESSED) - endif() - target_link_libraries(infra_test silkworm_infra Catch2::Catch2 GTest::gmock) - # Silkworm Node Tests file(GLOB_RECURSE SILKWORM_NODE_TESTS CONFIGURE_DEPENDS "${SILKWORM_MAIN_SRC_DIR}/node/*_test.cpp") add_executable(node_test unit_test.cpp ${SILKWORM_NODE_TESTS}) diff --git a/silkworm/infra/CMakeLists.txt b/silkworm/infra/CMakeLists.txt index d0c85f25b4..2dc5075b86 100644 --- a/silkworm/infra/CMakeLists.txt +++ b/silkworm/infra/CMakeLists.txt @@ -17,22 +17,29 @@ find_package(absl REQUIRED) find_package(asio-grpc REQUIRED) find_package(Boost REQUIRED container thread) +find_package(Catch2 REQUIRED) find_package(gRPC REQUIRED) +find_package(GTest REQUIRED) find_package(magic_enum REQUIRED) +add_subdirectory(test_util) + +set(TARGET silkworm_infra) + file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "*.cpp" "*.hpp") list(FILTER SRC EXCLUDE REGEX "_test\\.cpp$") list(FILTER SRC EXCLUDE REGEX "_benchmark\\.cpp$") +list(FILTER SRC EXCLUDE REGEX "test_util/") -add_library(silkworm_infra "${SRC}") +add_library(${TARGET} "${SRC}") # Suppress ASAN/TSAN in gRPC to avoid ODR violation when building Silkworm with sanitizers See # https://github.com/grpc/grpc/issues/19224 if(SILKWORM_SANITIZE) - target_compile_definitions(silkworm_infra PRIVATE GRPC_ASAN_SUPPRESSED GRPC_TSAN_SUPPRESSED) + target_compile_definitions(${TARGET} PRIVATE GRPC_ASAN_SUPPRESSED GRPC_TSAN_SUPPRESSED) endif() -target_include_directories(silkworm_infra PUBLIC "${SILKWORM_MAIN_DIR}") +target_include_directories(${TARGET} PUBLIC "${SILKWORM_MAIN_DIR}") set(LIBS_PUBLIC silkworm_core @@ -56,7 +63,20 @@ if(MSVC) endif(MSVC) target_link_libraries( - silkworm_infra + ${TARGET} PUBLIC "${LIBS_PUBLIC}" PRIVATE "${LIBS_PRIVATE}" ) + +# unit tests +set(TEST_TARGET ${TARGET}_test) +file(GLOB_RECURSE TEST_SRC CONFIGURE_DEPENDS "*_test.cpp") +add_executable(${TEST_TARGET} "${SILKWORM_MAIN_DIR}/cmd/test/unit_test.cpp" ${TEST_SRC}) +if(SILKWORM_SANITIZE) + target_compile_definitions(${TEST_TARGET} PRIVATE GRPC_ASAN_SUPPRESSED GRPC_TSAN_SUPPRESSED) +endif() +target_link_libraries( + ${TEST_TARGET} + PRIVATE ${TARGET} Catch2::Catch2 GTest::gmock + INTERFACE silkworm_infra_test_util +) diff --git a/silkworm/infra/common/log_test.cpp b/silkworm/infra/common/log_test.cpp index a5a5de6387..c22b6c0c93 100644 --- a/silkworm/infra/common/log_test.cpp +++ b/silkworm/infra/common/log_test.cpp @@ -22,7 +22,7 @@ #include -#include +#include namespace silkworm::log { @@ -52,17 +52,6 @@ void check_log_not_empty() { CHECK(log_buffer.content().find("test") != std::string::npos); } -//! Utility class using RAII to swap the underlying buffers of the provided streams -class StreamSwap { - public: - StreamSwap(std::ostream& o1, std::ostream& o2) : buffer_(o1.rdbuf()), stream_(o1) { o1.rdbuf(o2.rdbuf()); } - ~StreamSwap() { stream_.rdbuf(buffer_); } - - private: - std::streambuf* buffer_; - std::ostream& stream_; -}; - //! Build the prettified key-value pair using color scheme static std::string prettified_key_value(const std::string& key, const std::string& value) { std::string kv_pair{kColorGreen}; @@ -77,8 +66,8 @@ static std::string prettified_key_value(const std::string& key, const std::strin TEST_CASE("LogBuffer", "[silkworm][common][log]") { // Temporarily override std::cout and std::cerr with null stream to avoid terminal output - StreamSwap cout_swap{std::cout, test::null_stream()}; - StreamSwap cerr_swap{std::cerr, test::null_stream()}; + test_util::StreamSwap cout_swap{std::cout, test_util::null_stream()}; + test_util::StreamSwap cerr_swap{std::cerr, test_util::null_stream()}; SECTION("LogBuffer stores nothing for verbosity higher than default") { check_log_empty(); @@ -94,14 +83,14 @@ TEST_CASE("LogBuffer", "[silkworm][common][log]") { } SECTION("LogBuffer stores nothing for verbosity higher than configured one") { - test::SetLogVerbosityGuard guard{Level::kWarning}; + test_util::SetLogVerbosityGuard guard{Level::kWarning}; check_log_empty(); check_log_empty(); check_log_empty(); } SECTION("LogBuffer stores content for verbosity lower than or equal to configured one") { - test::SetLogVerbosityGuard guard{Level::kWarning}; + test_util::SetLogVerbosityGuard guard{Level::kWarning}; check_log_not_empty(); check_log_not_empty(); check_log_not_empty(); diff --git a/silkworm/infra/concurrency/awaitable_condition_variable_test.cpp b/silkworm/infra/concurrency/awaitable_condition_variable_test.cpp index da5a76b28c..995ea1f9f0 100644 --- a/silkworm/infra/concurrency/awaitable_condition_variable_test.cpp +++ b/silkworm/infra/concurrency/awaitable_condition_variable_test.cpp @@ -19,87 +19,73 @@ #include #include -#include -#include -#include #include +#include + namespace silkworm::concurrency { using namespace boost::asio; -using namespace std::chrono_literals; - -template -static void poll_context_until_future_is_ready(io_context& context, std::future& future) { - while (future.wait_for(0s) != std::future_status::ready) { - context.poll_one(); - } -} - -template -static TResult run(io_context& context, awaitable awaitable1) { - auto task = co_spawn(context, std::move(awaitable1), use_future); - poll_context_until_future_is_ready(context, task); - return task.get(); -} TEST_CASE("AwaitableConditionVariable.not_blocking_when_notified_before_waiting") { - io_context context; + test_util::TaskRunner runner; AwaitableConditionVariable cond_var; auto waiter = cond_var.waiter(); cond_var.notify_all(); - run(context, waiter()); + runner.run(waiter()); } TEST_CASE("AwaitableConditionVariable.blocks_during_waiting") { - io_context context; + using namespace std::chrono_literals; + + test_util::TaskRunner runner; AwaitableConditionVariable cond_var; auto waiter = cond_var.waiter(); // schedule waiting - auto task = co_spawn(context, waiter(), use_future); + auto future = runner.spawn_future(waiter()); // run until it blocks - while (context.poll_one() > 0) { + while (runner.context().poll_one() > 0) { } - CHECK(task.wait_for(0s) == std::future_status::timeout); + CHECK(future.wait_for(0s) == std::future_status::timeout); } TEST_CASE("AwaitableConditionVariable.notify_all_awakes_waiter") { - io_context context; + test_util::TaskRunner runner; AwaitableConditionVariable cond_var; auto waiter = cond_var.waiter(); // schedule waiting - auto task = co_spawn(context, waiter(), use_future); + auto future = runner.spawn_future(waiter()); // run until it blocks - while (context.poll_one() > 0) { + while (runner.context().poll_one() > 0) { } cond_var.notify_all(); - poll_context_until_future_is_ready(context, task); + runner.poll_context_until_future_is_ready(future); } TEST_CASE("AwaitableConditionVariable.notify_all_awakes_multiple_waiters") { - io_context context; + test_util::TaskRunner runner; AwaitableConditionVariable cond_var; auto waiter1 = cond_var.waiter(); auto waiter2 = cond_var.waiter(); auto waiter3 = cond_var.waiter(); // schedule waiting - auto task1 = co_spawn(context, waiter1(), use_future); - auto task2 = co_spawn(context, waiter2(), use_future); - auto task3 = co_spawn(context, waiter3(), use_future); + auto future1 = runner.spawn_future(waiter1()); + auto future2 = runner.spawn_future(waiter2()); + auto future3 = runner.spawn_future(waiter3()); // run until it blocks - while (context.poll_one() > 0) { + while (runner.context().poll_one() > 0) { } cond_var.notify_all(); - poll_context_until_future_is_ready(context, task1); - poll_context_until_future_is_ready(context, task2); - poll_context_until_future_is_ready(context, task3); + runner.poll_context_until_future_is_ready(future1); + runner.poll_context_until_future_is_ready(future2); + runner.poll_context_until_future_is_ready(future3); } } // namespace silkworm::concurrency diff --git a/silkworm/infra/concurrency/context_pool_test.cpp b/silkworm/infra/concurrency/context_pool_test.cpp index 77771fe4ec..2ea5597240 100644 --- a/silkworm/infra/concurrency/context_pool_test.cpp +++ b/silkworm/infra/concurrency/context_pool_test.cpp @@ -24,14 +24,14 @@ #include #include -#include +#include namespace silkworm::concurrency { // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE("Context", "[silkworm][concurrency][server_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; Context ctx{0}; SECTION("ServerContext") { @@ -65,12 +65,12 @@ TEST_CASE("Context", "[silkworm][concurrency][server_context]") { } SECTION("print") { - CHECK_NOTHROW(test::null_stream() << ctx); + CHECK_NOTHROW(test_util::null_stream() << ctx); } } TEST_CASE("ContextPool", "[silkworm][concurrency][Context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("ContextPool OK") { ContextPool context_pool{2}; diff --git a/silkworm/infra/concurrency/timeout_test.cpp b/silkworm/infra/concurrency/timeout_test.cpp index 840bfac1c7..db69753650 100644 --- a/silkworm/infra/concurrency/timeout_test.cpp +++ b/silkworm/infra/concurrency/timeout_test.cpp @@ -19,22 +19,19 @@ #include #include -#include +#include -#include -#include #include #include -#include #include #include -#include #include #include #include #include #include +#include namespace silkworm::concurrency { @@ -94,17 +91,8 @@ awaitable wait_until_cancelled_bad() { template TResult run(awaitable awaitable1) { - io_context context; - auto task = co_spawn( - context, - std::move(awaitable1), - boost::asio::use_future); - - while (task.wait_for(0s) != std::future_status::ready) { - context.poll_one(); - } - - return task.get(); + test_util::TaskRunner runner; + return runner.run(std::move(awaitable1)); } TEST_CASE("Timeout.value") { diff --git a/silkworm/infra/grpc/client/client_context_pool_test.cpp b/silkworm/infra/grpc/client/client_context_pool_test.cpp index 1abb982e31..3f97fe18e3 100644 --- a/silkworm/infra/grpc/client/client_context_pool_test.cpp +++ b/silkworm/infra/grpc/client/client_context_pool_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -72,13 +72,13 @@ TEST_CASE("ClientContext", "[silkworm][infra][grpc][client][client_context]") { } SECTION("print") { - CHECK_NOTHROW(test::null_stream() << context); + CHECK_NOTHROW(test_util::null_stream() << context); } } } TEST_CASE("ClientContextPool: create context pool", "[silkworm][infra][grpc][client][client_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("reject size 0") { CHECK_THROWS_MATCHES((ClientContextPool{0}), std::logic_error, @@ -121,7 +121,7 @@ TEST_CASE("ClientContextPool: create context pool", "[silkworm][infra][grpc][cli } TEST_CASE("ClientContextPool: start context pool", "[silkworm][infra][grpc][client][client_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("running 1 thread") { ClientContextPool cp{1}; @@ -139,7 +139,7 @@ TEST_CASE("ClientContextPool: start context pool", "[silkworm][infra][grpc][clie } TEST_CASE("ClientContextPool: run context pool", "[silkworm][infra][grpc][client][client_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("running 1 thread") { ClientContextPool cp{1}; @@ -168,7 +168,7 @@ TEST_CASE("ClientContextPool: run context pool", "[silkworm][infra][grpc][client } TEST_CASE("ClientContextPool: stop context pool", "[silkworm][infra][grpc][client][client_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("not yet running") { ClientContextPool cp{3}; @@ -194,7 +194,7 @@ TEST_CASE("ClientContextPool: stop context pool", "[silkworm][infra][grpc][clien } TEST_CASE("ClientContextPool: cannot restart context pool", "[silkworm][infra][grpc][client][client_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("running 1 thread") { ClientContextPool cp{1}; diff --git a/silkworm/infra/grpc/common/util_test.cpp b/silkworm/infra/grpc/common/util_test.cpp index a7d1623897..e2cdac9427 100644 --- a/silkworm/infra/grpc/common/util_test.cpp +++ b/silkworm/infra/grpc/common/util_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -72,7 +72,7 @@ TEST_CASE("GrpcLogGuard", "[silkworm][rpc][util]") { } TEST_CASE("gpr_silkworm_log", "[silkworm][rpc][util]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; const char* FILE_NAME{"file.cpp"}; const int LINE_NUMBER{10}; Grpc2SilkwormLogGuard log_guard; diff --git a/silkworm/infra/grpc/common/version_test.cpp b/silkworm/infra/grpc/common/version_test.cpp index e8bb445b01..e0411c42a7 100644 --- a/silkworm/infra/grpc/common/version_test.cpp +++ b/silkworm/infra/grpc/common/version_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ using testing::SetArgPointee; #ifndef SILKWORM_SANITIZE TEST_CASE("write protocol version to ostream", "[silkrpc][protocol][version]") { const ProtocolVersion v{1, 0, 0}; - CHECK_NOTHROW(silkworm::test::null_stream() << v); + CHECK_NOTHROW(silkworm::test_util::null_stream() << v); } TEST_CASE("ETHBACKEND protocol version error", "[silkrpc][protocol][wait_for_ethbackend_protocol_check]") { diff --git a/silkworm/infra/grpc/server/call_test.cpp b/silkworm/infra/grpc/server/call_test.cpp index 845be2360b..566eb53915 100644 --- a/silkworm/infra/grpc/server/call_test.cpp +++ b/silkworm/infra/grpc/server/call_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include namespace silkworm::rpc { @@ -28,7 +28,7 @@ TEST_CASE("BaseRpc", "[silkworm][rpc][call][.]") { explicit FakeRpc(grpc::ServerContext& server_context) : server::Call(server_context) {} }; - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; grpc::ServerContext server_context; SECTION("count live instances") { diff --git a/silkworm/infra/grpc/server/server_context_pool_test.cpp b/silkworm/infra/grpc/server/server_context_pool_test.cpp index 7747fe559f..4357c576b7 100644 --- a/silkworm/infra/grpc/server/server_context_pool_test.cpp +++ b/silkworm/infra/grpc/server/server_context_pool_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -33,7 +33,7 @@ using namespace concurrency; // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE("ServerContext", "[silkworm][infra][grpc][server][server_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; grpc::ServerBuilder builder; std::unique_ptr scq = builder.AddCompletionQueue(); grpc::ServerCompletionQueue* scq_ptr = scq.get(); @@ -74,12 +74,12 @@ TEST_CASE("ServerContext", "[silkworm][infra][grpc][server][server_context]") { } SECTION("print") { - CHECK_NOTHROW(test::null_stream() << server_context); + CHECK_NOTHROW(test_util::null_stream() << server_context); } } TEST_CASE("ServerContextPool", "[silkworm][infra][grpc][server][server_context]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; grpc::ServerBuilder builder; SECTION("ServerContextPool OK") { diff --git a/silkworm/infra/grpc/server/server_settings_test.cpp b/silkworm/infra/grpc/server/server_settings_test.cpp index 49334cf65e..ca25a5922f 100644 --- a/silkworm/infra/grpc/server/server_settings_test.cpp +++ b/silkworm/infra/grpc/server/server_settings_test.cpp @@ -19,14 +19,14 @@ #include #include -#include +#include namespace silkworm::rpc { // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE("ServerConfig::ServerConfig", "[silkworm][rpc][server_settings]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ServerSettings config; CHECK(config.address_uri == kDefaultAddressUri); CHECK(config.context_pool_settings.num_contexts > 0); diff --git a/silkworm/infra/grpc/server/server_test.cpp b/silkworm/infra/grpc/server/server_test.cpp index 3691d1304b..92baebe088 100644 --- a/silkworm/infra/grpc/server/server_test.cpp +++ b/silkworm/infra/grpc/server/server_test.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -54,7 +54,7 @@ static const std::string kTestAddressUri{"localhost:12345"}; // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE("Barebone gRPC Server", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; grpc::ServerBuilder builder; // Add *at least one non-empty* ServerCompletionQueue (otherwise: ASAN SIGSEGV error in Shutdown) std::unique_ptr cq = builder.AddCompletionQueue(); @@ -75,7 +75,7 @@ TEST_CASE("Barebone gRPC Server", "[silkworm][node][rpc]") { } TEST_CASE("Server::Server", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("OK: create an empty Server", "[silkworm][node][rpc]") { ServerSettings settings; @@ -85,7 +85,7 @@ TEST_CASE("Server::Server", "[silkworm][node][rpc]") { } TEST_CASE("Server::build_and_start", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard set_log_verbosity_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard set_log_verbosity_guard{log::Level::kNone}; // TODO(canepat): use GMock class TestServer : public EmptyServer { @@ -140,7 +140,7 @@ TEST_CASE("Server::build_and_start", "[silkworm][node][rpc]") { } TEST_CASE("Server::shutdown", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; ServerSettings settings; settings.address_uri = kTestAddressUri; EmptyServer server{settings}; @@ -158,7 +158,7 @@ TEST_CASE("Server::shutdown", "[silkworm][node][rpc]") { } TEST_CASE("Server::join", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; ServerSettings settings; settings.address_uri = kTestAddressUri; EmptyServer server{settings}; diff --git a/silkworm/infra/test_util/CMakeLists.txt b/silkworm/infra/test_util/CMakeLists.txt new file mode 100644 index 0000000000..f52a23aeff --- /dev/null +++ b/silkworm/infra/test_util/CMakeLists.txt @@ -0,0 +1,25 @@ +#[[ + Copyright 2023 The Silkworm Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +]] + +find_package(Boost REQUIRED thread) + +set(TARGET silkworm_infra_test_util) + +file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "*.cpp" "*.hpp") + +add_library(${TARGET} ${SRC}) + +target_link_libraries(${TARGET} PUBLIC silkworm_infra Boost::thread) diff --git a/silkworm/infra/test/log.hpp b/silkworm/infra/test_util/log.hpp similarity index 96% rename from silkworm/infra/test/log.hpp rename to silkworm/infra/test_util/log.hpp index 5245797578..311eb5826e 100644 --- a/silkworm/infra/test/log.hpp +++ b/silkworm/infra/test_util/log.hpp @@ -20,7 +20,7 @@ #include -namespace silkworm::test { +namespace silkworm::test_util { //! Utility class using RAII to change the log verbosity level (necessary to make tests work in shuffled order) class SetLogVerbosityGuard { @@ -56,4 +56,4 @@ class StreamSwap { std::ostream& stream_; }; -} // namespace silkworm::test +} // namespace silkworm::test_util diff --git a/silkworm/infra/test_util/task_runner.hpp b/silkworm/infra/test_util/task_runner.hpp new file mode 100644 index 0000000000..5673d4d0a4 --- /dev/null +++ b/silkworm/infra/test_util/task_runner.hpp @@ -0,0 +1,67 @@ +/* + Copyright 2023 The Silkworm Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include + +#include + +#include +#include +#include + +namespace silkworm::test_util { + +/** + * A helper to run Task-s on io_context in tests + */ +class TaskRunner { + public: + TaskRunner() = default; + + //! Run task to completion + template + TResult run(Task task) { + auto future = spawn_future(std::move(task)); + poll_context_until_future_is_ready(future); + return future.get(); + } + + //! co_spawn with use_future + template + std::future spawn_future(Task task) { + return co_spawn(context_, std::move(task), boost::asio::use_future); + } + + //! Poll until the spawned future completes + template + void poll_context_until_future_is_ready(std::future& future) { + using namespace std::chrono_literals; + context_.restart(); + while (future.wait_for(0s) != std::future_status::ready) { + context_.poll_one(); + } + } + + [[nodiscard]] boost::asio::io_context& context() { return context_; } + + private: + boost::asio::io_context context_; +}; + +} // namespace silkworm::test_util diff --git a/silkworm/node/backend/remote/backend_kv_server_test.cpp b/silkworm/node/backend/remote/backend_kv_server_test.cpp index a5bdf4b4dc..3fd1ff3c33 100644 --- a/silkworm/node/backend/remote/backend_kv_server_test.cpp +++ b/silkworm/node/backend/remote/backend_kv_server_test.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -376,7 +376,7 @@ struct BackEndKvE2eTest { server->join(); } - test::SetLogVerbosityGuard set_verbosity_log_guard; + test_util::SetLogVerbosityGuard set_verbosity_log_guard; rpc::Grpc2SilkwormLogGuard grpc2silkworm_log_guard; std::unique_ptr ethbackend_stub; std::unique_ptr backend_client; @@ -397,7 +397,7 @@ namespace silkworm::rpc { // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE("BackEndKvServer", "[silkworm][node][rpc]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; Grpc2SilkwormLogGuard log_guard; ServerSettings srv_config; srv_config.address_uri = kTestAddressUri; diff --git a/silkworm/node/bittorrent/client_test.cpp b/silkworm/node/bittorrent/client_test.cpp index 34e08143e1..cd6efaab64 100644 --- a/silkworm/node/bittorrent/client_test.cpp +++ b/silkworm/node/bittorrent/client_test.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include namespace silkworm { @@ -154,7 +154,7 @@ TEST_CASE("BitTorrentClient::BitTorrentClient", "[silkworm][snapshot][bittorrent } TEST_CASE("BitTorrentClient::add_info_hash", "[silkworm][snapshot][bittorrent]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; TestRepository repo; BitTorrentSettings settings{}; @@ -183,7 +183,7 @@ TEST_CASE("BitTorrentClient::add_info_hash", "[silkworm][snapshot][bittorrent]") } TEST_CASE("BitTorrentClient::execute_loop", "[silkworm][snapshot][bittorrent]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; TestRepository repo; BitTorrentSettings settings{}; @@ -286,7 +286,7 @@ TEST_CASE("BitTorrentClient::process_alerts", "[silkworm][snapshot][bittorrent]" } TEST_CASE("BitTorrentClient::handle_alert", "[silkworm][snapshot][bittorrent]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; TestRepository repo; BitTorrentSettings settings{}; diff --git a/silkworm/node/db/access_layer_test.cpp b/silkworm/node/db/access_layer_test.cpp index 1f114bb8fe..3016aa0224 100644 --- a/silkworm/node/db/access_layer_test.cpp +++ b/silkworm/node/db/access_layer_test.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -89,7 +89,7 @@ static BlockBody sample_block_body() { namespace silkworm::db { TEST_CASE("Db Opening") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; // Empty dir std::string empty{}; db::EnvConfig db_config{empty}; @@ -134,7 +134,7 @@ TEST_CASE("Db Opening") { } TEST_CASE("Methods cursor_for_each/cursor_for_count") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -171,7 +171,7 @@ TEST_CASE("VersionBase primitives") { } TEST_CASE("Sequences") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -218,7 +218,7 @@ TEST_CASE("Sequences") { } TEST_CASE("Schema Version") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context(/*with_create_tables=*/false); SECTION("Read/Write") { @@ -256,7 +256,7 @@ TEST_CASE("Schema Version") { } TEST_CASE("Storage and Prune Modes") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.txn()}; @@ -383,7 +383,7 @@ TEST_CASE("Storage and Prune Modes") { } TEST_CASE("Stages") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -448,7 +448,7 @@ TEST_CASE("Difficulty") { } TEST_CASE("Headers and bodies") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -569,7 +569,7 @@ TEST_CASE("Headers and bodies") { } TEST_CASE("Account") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; db::RWTxn& txn{context.rw_txn()}; @@ -613,7 +613,7 @@ TEST_CASE("Account") { } TEST_CASE("Storage") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -701,7 +701,7 @@ TEST_CASE("Account_changes") { } TEST_CASE("Storage changes") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -781,7 +781,7 @@ TEST_CASE("Storage changes") { } TEST_CASE("Chain config") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -804,7 +804,7 @@ TEST_CASE("Chain config") { } TEST_CASE("Head header") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -814,7 +814,7 @@ TEST_CASE("Head header") { } TEST_CASE("Last Fork Choice") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -832,7 +832,7 @@ TEST_CASE("Last Fork Choice") { } TEST_CASE("read rlp encoded transactions") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; diff --git a/silkworm/node/db/buffer_test.cpp b/silkworm/node/db/buffer_test.cpp index 525d2877d6..5afd9434d6 100644 --- a/silkworm/node/db/buffer_test.cpp +++ b/silkworm/node/db/buffer_test.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ namespace silkworm::db { TEST_CASE("Storage update") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; @@ -69,7 +69,7 @@ TEST_CASE("Storage update") { } TEST_CASE("Account update") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::Context context; auto& txn{context.rw_txn()}; diff --git a/silkworm/node/db/memory_mutation_cursor_test.cpp b/silkworm/node/db/memory_mutation_cursor_test.cpp index d8af927cc3..764458fb6e 100644 --- a/silkworm/node/db/memory_mutation_cursor_test.cpp +++ b/silkworm/node/db/memory_mutation_cursor_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include namespace silkworm::db { @@ -88,7 +88,7 @@ struct MemoryMutationCursorTest { RWTxn main_txn{main_env}; MemoryOverlay overlay{tmp_dir.path(), &main_txn}; MemoryMutation mutation{overlay}; - test::SetLogVerbosityGuard log_guard_{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard_{log::Level::kNone}; }; // Skip in TSAN build due to false positive lock-order-inversion: https://github.com/google/sanitizers/issues/814 diff --git a/silkworm/node/etl/collector_test.cpp b/silkworm/node/etl/collector_test.cpp index fa486fb63b..b38de7df1d 100644 --- a/silkworm/node/etl/collector_test.cpp +++ b/silkworm/node/etl/collector_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -100,17 +100,17 @@ void run_collector_test(const LoadFunc& load_func, bool do_copy = true) { } TEST_CASE("collect_and_default_load") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; run_collector_test(nullptr); } TEST_CASE("collect_and_default_load_move") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; run_collector_test(nullptr, false); } TEST_CASE("collect_and_load") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; run_collector_test([](const Entry& entry, auto& table, MDBX_put_flags_t) { Bytes key{entry.key}; key.at(0) = 1; diff --git a/silkworm/node/huffman/decompressor_test.cpp b/silkworm/node/huffman/decompressor_test.cpp index 2b9b69f8f1..3a8fcf9915 100644 --- a/silkworm/node/huffman/decompressor_test.cpp +++ b/silkworm/node/huffman/decompressor_test.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include using Catch::Matchers::Message; @@ -172,10 +172,10 @@ TEST_CASE("PatternTable::search_condensed", "[silkworm][snapshot][decompressor]" TEST_CASE("PatternTable::operator<<", "[silkworm][snapshot][decompressor]") { PatternTable table1{0}; - CHECK_NOTHROW(test::null_stream() << table1); + CHECK_NOTHROW(test_util::null_stream() << table1); SetCondensedTableBitLengthThresholdGuard bit_length_threshold_guard{1}; PatternTable table2{0}; - CHECK_NOTHROW(test::null_stream() << table2); + CHECK_NOTHROW(test_util::null_stream() << table2); } TEST_CASE("PositionTable::PositionTable", "[silkworm][snapshot][decompressor]") { @@ -191,7 +191,7 @@ TEST_CASE("PositionTable::PositionTable", "[silkworm][snapshot][decompressor]") TEST_CASE("PositionTable::operator<<", "[silkworm][snapshot][decompressor]") { PositionTable table{0}; - CHECK_NOTHROW(test::null_stream() << table); + CHECK_NOTHROW(test_util::null_stream() << table); } TEST_CASE("Decompressor::Decompressor", "[silkworm][snapshot][decompressor]") { @@ -204,7 +204,7 @@ TEST_CASE("Decompressor::Decompressor", "[silkworm][snapshot][decompressor]") { } TEST_CASE("Decompressor::open invalid files", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SECTION("empty file") { test::TemporaryFile tmp_file; @@ -232,7 +232,7 @@ TEST_CASE("Decompressor::open invalid files", "[silkworm][snapshot][decompressor } TEST_CASE("Decompressor::open valid files", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::map header_tests{ {"zero patterns and zero positions", @@ -273,7 +273,7 @@ TEST_CASE("Decompressor::open valid files", "[silkworm][snapshot][decompressor]" } TEST_CASE("Decompressor::read_ahead", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SnapshotHeader header{ .words_count = 0, .empty_words_count = 0, @@ -296,7 +296,7 @@ TEST_CASE("Decompressor::read_ahead", "[silkworm][snapshot][decompressor]") { } TEST_CASE("Decompressor::close", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SnapshotHeader header{ .words_count = 0, .empty_words_count = 0, @@ -319,7 +319,7 @@ TEST_CASE("Decompressor::close", "[silkworm][snapshot][decompressor]") { } TEST_CASE("Iterator::Iterator empty data", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SnapshotHeader header{ .words_count = 0, .empty_words_count = 0, @@ -408,7 +408,7 @@ const Bytes kLoremIpsumDict{*from_hex( "73742036340d6c61626f72756d203635")}; TEST_CASE("Decompressor: lorem ipsum next_uncompressed", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile tmp_file{}; tmp_file.write(kLoremIpsumDict); Decompressor decoder{tmp_file.path()}; @@ -441,7 +441,7 @@ TEST_CASE("Decompressor: lorem ipsum next_uncompressed", "[silkworm][snapshot][d } TEST_CASE("Decompressor: lorem ipsum next", "[silkworm][snapshot][decompressor]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile tmp_file{}; tmp_file.write(kLoremIpsumDict); Decompressor decoder{tmp_file.path()}; diff --git a/silkworm/node/recsplit/encoding/elias_fano_test.cpp b/silkworm/node/recsplit/encoding/elias_fano_test.cpp index dcbb90dfb0..d186e786ed 100644 --- a/silkworm/node/recsplit/encoding/elias_fano_test.cpp +++ b/silkworm/node/recsplit/encoding/elias_fano_test.cpp @@ -23,12 +23,12 @@ #include #include -#include +#include namespace silkworm::succinct { TEST_CASE("EliasFanoList32", "[silkworm][recsplit][elias_fano]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector offsets{1, 4, 6, 8, 10, 14, 16, 19, 22, 34, 37, 39, 41, 43, 48, 51, 54, 58, 62}; @@ -72,7 +72,7 @@ TEST_CASE("EliasFanoList32", "[silkworm][recsplit][elias_fano]") { } TEST_CASE("DoubleEliasFanoList16", "[silkworm][recsplit][elias_fano]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; DoubleEliasFanoList16 double_ef_list; std::vector cum_keys{1, 1, 2, 6, 7, 11, 13, 20}; std::vector position{1, 2, 5, 5, 6, 7, 9, 9}; diff --git a/silkworm/node/recsplit/encoding/golomb_rice_test.cpp b/silkworm/node/recsplit/encoding/golomb_rice_test.cpp index 6983670407..17e24c0db6 100644 --- a/silkworm/node/recsplit/encoding/golomb_rice_test.cpp +++ b/silkworm/node/recsplit/encoding/golomb_rice_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace silkworm::succinct { @@ -68,7 +68,7 @@ static void test_trees(GolombRiceVector& v, const Uint64Sequence& keys, uint64_t } TEST_CASE("GolombRiceVector", "[silkworm][recsplit][golomb_rice]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; const std::vector golomb_params{0, 1, 2, 3, 4, 5, 6}; for (std::size_t i{0}; i < golomb_params.size(); ++i) { diff --git a/silkworm/node/recsplit/encoding/sequence_test.cpp b/silkworm/node/recsplit/encoding/sequence_test.cpp index 2bc6638cbf..46ce031084 100644 --- a/silkworm/node/recsplit/encoding/sequence_test.cpp +++ b/silkworm/node/recsplit/encoding/sequence_test.cpp @@ -20,12 +20,12 @@ #include -#include +#include namespace silkworm::succinct { TEST_CASE("Uint64Sequence", "[silkworm][recsplit][sequence]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; Uint64Sequence output_sequence{0, 11, 21, 31, 41, 51, 61}; std::stringstream ss; diff --git a/silkworm/node/recsplit/rec_split_test.cpp b/silkworm/node/recsplit/rec_split_test.cpp index 728332ef37..1d00bd7ee1 100644 --- a/silkworm/node/recsplit/rec_split_test.cpp +++ b/silkworm/node/recsplit/rec_split_test.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include @@ -33,7 +33,7 @@ namespace silkworm::succinct { constexpr int kTestSalt{1}; TEST_CASE("RecSplit8: key_count=0", "[silkworm][node][recsplit]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; RecSplitSettings settings{ .keys_count = 0, @@ -46,7 +46,7 @@ TEST_CASE("RecSplit8: key_count=0", "[silkworm][node][recsplit]") { } TEST_CASE("RecSplit8: key_count=1", "[silkworm][node][recsplit]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; RecSplitSettings settings{ .keys_count = 1, @@ -60,7 +60,7 @@ TEST_CASE("RecSplit8: key_count=1", "[silkworm][node][recsplit]") { } TEST_CASE("RecSplit8: key_count=2", "[silkworm][node][recsplit]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; RecSplitSettings settings{ .keys_count = 2, @@ -119,7 +119,7 @@ template <> const std::array RecSplit4::memo = RecSplit4::fill_golomb_rice(); TEST_CASE("RecSplit4: keys=1000 buckets=128", "[silkworm][node][recsplit]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; constexpr int kTestNumKeys{1'000}; @@ -157,7 +157,7 @@ TEST_CASE("RecSplit4: keys=1000 buckets=128", "[silkworm][node][recsplit]") { } TEST_CASE("RecSplit4: multiple keys-buckets", "[silkworm][node][recsplit]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; struct RecSplitParams { @@ -204,7 +204,7 @@ TEST_CASE("RecSplit4: multiple keys-buckets", "[silkworm][node][recsplit]") { } TEST_CASE("RecSplit8: index lookup", "[silkworm][node][recsplit][.]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; RecSplitSettings settings{ .keys_count = 100, @@ -227,7 +227,7 @@ TEST_CASE("RecSplit8: index lookup", "[silkworm][node][recsplit][.]") { } TEST_CASE("RecSplit8: double index lookup", "[silkworm][node][recsplit][.]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporaryFile index_file; RecSplitSettings settings{ .keys_count = 100, diff --git a/silkworm/node/snapshot/index_test.cpp b/silkworm/node/snapshot/index_test.cpp index 3ccec52b48..d19c0f6b77 100644 --- a/silkworm/node/snapshot/index_test.cpp +++ b/silkworm/node/snapshot/index_test.cpp @@ -19,20 +19,20 @@ #include #include -#include +#include #include namespace silkworm::snapshot { TEST_CASE("Index::Index", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporarySnapshotFile tmp_snapshot_file{"v1-014500-015000-headers.seg"}; HeaderIndex header_index{*SnapshotPath::parse(tmp_snapshot_file.path().string())}; CHECK_THROWS_AS(header_index.build(), std::logic_error); } TEST_CASE("BodyIndex::build OK", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SampleBodySnapshotFile valid_body_snapshot{}; test::SampleBodySnapshotPath body_snapshot_path{valid_body_snapshot.path()}; // necessary to tweak the block numbers BodyIndex body_index{body_snapshot_path}; @@ -40,7 +40,7 @@ TEST_CASE("BodyIndex::build OK", "[silkworm][snapshot][index]") { } TEST_CASE("TransactionIndex::build KO: empty snapshot", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; constexpr const char* kBodiesSnapshotFileName{"v1-014500-015000-bodies.seg"}; constexpr const char* kTransactionsSnapshotFileName{"v1-014500-015000-transactions.seg"}; @@ -53,7 +53,7 @@ TEST_CASE("TransactionIndex::build KO: empty snapshot", "[silkworm][snapshot][in } TEST_CASE("TransactionIndex::build KO: invalid snapshot", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; constexpr const char* kTransactionsSnapshotFileName{"v1-015000-015500-transactions.seg"}; SECTION("KO: invalid zero word length") { @@ -125,7 +125,7 @@ TEST_CASE("TransactionIndex::build KO: invalid snapshot", "[silkworm][snapshot][ } TEST_CASE("TransactionIndex::build OK", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SampleBodySnapshotFile valid_bodies_snapshot{}; test::SampleTransactionSnapshotFile valid_txs_snapshot{}; test::SampleTransactionSnapshotPath txs_snapshot_path{valid_txs_snapshot.path()}; // necessary to tweak the block numbers diff --git a/silkworm/node/snapshot/repository_test.cpp b/silkworm/node/snapshot/repository_test.cpp index 778bcfdd91..d6d5009602 100644 --- a/silkworm/node/snapshot/repository_test.cpp +++ b/silkworm/node/snapshot/repository_test.cpp @@ -20,18 +20,18 @@ #include #include -#include +#include #include namespace silkworm::snapshot { TEST_CASE("SnapshotRepository::SnapshotRepository", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; CHECK_NOTHROW(SnapshotRepository{SnapshotSettings{}}); } TEST_CASE("SnapshotRepository::reopen_folder", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; const auto tmp_dir = TemporaryDirectory::get_unique_temporary_path(); std::filesystem::create_directories(tmp_dir); @@ -48,7 +48,7 @@ TEST_CASE("SnapshotRepository::reopen_folder", "[silkworm][snapshot][snapshot]") } TEST_CASE("SnapshotRepository::view", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; const auto tmp_dir = TemporaryDirectory::get_unique_temporary_path(); std::filesystem::create_directories(tmp_dir); SnapshotSettings settings{tmp_dir}; @@ -119,7 +119,7 @@ TEST_CASE("SnapshotRepository::view", "[silkworm][snapshot][snapshot]") { } TEST_CASE("SnapshotRepository::missing_block_ranges", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; const auto tmp_dir = TemporaryDirectory::get_unique_temporary_path(); std::filesystem::create_directories(tmp_dir); SnapshotSettings settings{tmp_dir}; diff --git a/silkworm/node/snapshot/snapshot_test.cpp b/silkworm/node/snapshot/snapshot_test.cpp index 704d641062..15a2fbad74 100644 --- a/silkworm/node/snapshot/snapshot_test.cpp +++ b/silkworm/node/snapshot/snapshot_test.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include namespace silkworm::snapshot { @@ -62,14 +62,14 @@ TEST_CASE("Snapshot::Snapshot", "[silkworm][snapshot][snapshot]") { } TEST_CASE("Snapshot::reopen_segment", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::TemporarySnapshotFile tmp_snapshot_file{test::SnapshotHeader{}}; auto snapshot{std::make_unique(tmp_snapshot_file.path(), 0, 0)}; snapshot->reopen_segment(); } TEST_CASE("Snapshot::for_each_item", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::HelloWorldSnapshotFile hello_world_snapshot_file{}; huffman::Decompressor decoder{hello_world_snapshot_file.path()}; Snapshot_ForTest tmp_snapshot{hello_world_snapshot_file.path(), 1'000, 2'000}; @@ -85,7 +85,7 @@ TEST_CASE("Snapshot::for_each_item", "[silkworm][snapshot][snapshot]") { } TEST_CASE("Snapshot::close", "[silkworm][snapshot][snapshot]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::HelloWorldSnapshotFile hello_world_snapshot_file{}; huffman::Decompressor decoder{hello_world_snapshot_file.path()}; Snapshot_ForTest tmp_snapshot{hello_world_snapshot_file.path(), 1'000, 2'000}; @@ -95,7 +95,7 @@ TEST_CASE("Snapshot::close", "[silkworm][snapshot][snapshot]") { // https://etherscan.io/block/1500013 TEST_CASE("HeaderSnapshot::header_by_number OK", "[silkworm][snapshot][index][.]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SampleHeaderSnapshotFile valid_header_snapshot{}; test::SampleHeaderSnapshotPath header_snapshot_path{valid_header_snapshot.path()}; // necessary to tweak the block numbers HeaderIndex header_index{header_snapshot_path}; @@ -129,7 +129,7 @@ TEST_CASE("HeaderSnapshot::header_by_number OK", "[silkworm][snapshot][index][.] // https://etherscan.io/block/1500013 TEST_CASE("BodySnapshot::body_by_number OK", "[silkworm][snapshot][index]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::SampleBodySnapshotFile valid_body_snapshot{}; test::SampleBodySnapshotPath body_snapshot_path{valid_body_snapshot.path()}; // necessary to tweak the block numbers BodyIndex body_index{body_snapshot_path}; diff --git a/silkworm/node/snapshot/sync_test.cpp b/silkworm/node/snapshot/sync_test.cpp index bac8f0a87e..bc3062945b 100644 --- a/silkworm/node/snapshot/sync_test.cpp +++ b/silkworm/node/snapshot/sync_test.cpp @@ -20,20 +20,20 @@ #include #include -#include +#include #include #include namespace silkworm::snapshot { TEST_CASE("SnapshotSync::SnapshotSync", "[silkworm][snapshot][sync]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; SnapshotRepository repository{SnapshotSettings{}}; CHECK_NOTHROW(SnapshotSync{&repository, kMainnetConfig}); } TEST_CASE("SnapshotSync::download_and_index_snapshots", "[silkworm][snapshot][sync]") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; test::Context context; const auto tmp_dir{TemporaryDirectory::get_unique_temporary_path()}; BitTorrentSettings bittorrent_settings{ diff --git a/silkworm/node/stagedsync/execution_engine_test.cpp b/silkworm/node/stagedsync/execution_engine_test.cpp index d38acb586c..61b216e8fb 100644 --- a/silkworm/node/stagedsync/execution_engine_test.cpp +++ b/silkworm/node/stagedsync/execution_engine_test.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -104,7 +104,7 @@ class ExecutionEngine_ForTest : public stagedsync::ExecutionEngine { }; TEST_CASE("ExecutionEngine") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); asio::io_context io; asio::executor_work_guard work{io.get_executor()}; diff --git a/silkworm/node/stagedsync/forks/fork_test.cpp b/silkworm/node/stagedsync/forks/fork_test.cpp index c4dfac316b..b27cfb82c4 100644 --- a/silkworm/node/stagedsync/forks/fork_test.cpp +++ b/silkworm/node/stagedsync/forks/fork_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -69,7 +69,7 @@ static Block generateSampleChildrenBlock(const BlockHeader& parent) { } TEST_CASE("Fork") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); test::Context context; context.add_genesis_data(); diff --git a/silkworm/node/stagedsync/forks/main_chain_test.cpp b/silkworm/node/stagedsync/forks/main_chain_test.cpp index db99f19256..61751b2ca7 100644 --- a/silkworm/node/stagedsync/forks/main_chain_test.cpp +++ b/silkworm/node/stagedsync/forks/main_chain_test.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ static Block generateSampleChildrenBlock(const BlockHeader& parent) { } TEST_CASE("MainChain") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); asio::io_context io; asio::executor_work_guard work{io.get_executor()}; diff --git a/silkworm/node/stagedsync/local_client_test.cpp b/silkworm/node/stagedsync/local_client_test.cpp index 0178817f65..08ab1c7eee 100644 --- a/silkworm/node/stagedsync/local_client_test.cpp +++ b/silkworm/node/stagedsync/local_client_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -27,7 +27,7 @@ namespace silkworm::execution { namespace asio = boost::asio; TEST_CASE("execution::LocalClient") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); test::Context context; context.add_genesis_data(); context.commit_txn(); diff --git a/silkworm/node/stagedsync/remote_client_test.cpp b/silkworm/node/stagedsync/remote_client_test.cpp index d592eb9780..33b83e4bff 100644 --- a/silkworm/node/stagedsync/remote_client_test.cpp +++ b/silkworm/node/stagedsync/remote_client_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace silkworm::execution { @@ -27,7 +27,7 @@ namespace silkworm::execution { namespace asio = boost::asio; TEST_CASE("execution::RemoteClient") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); test::Context context; context.add_genesis_data(); context.commit_txn(); diff --git a/silkworm/node/stagedsync/stages/_test.cpp b/silkworm/node/stagedsync/stages/_test.cpp index 7dc5455c7f..6fea13082b 100644 --- a/silkworm/node/stagedsync/stages/_test.cpp +++ b/silkworm/node/stagedsync/stages/_test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ TEST_CASE("Sync Stages") { std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt); - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto chaindata_env{db::open_env(node_settings.chaindata_env_config)}; db::RWTxn txn(chaindata_env); diff --git a/silkworm/node/stagedsync/stages/stage_history_index_test.cpp b/silkworm/node/stagedsync/stages/stage_history_index_test.cpp index 809f7aaba7..b513f1c676 100644 --- a/silkworm/node/stagedsync/stages/stage_history_index_test.cpp +++ b/silkworm/node/stagedsync/stages/stage_history_index_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,8 +34,8 @@ namespace silkworm { TEST_CASE("Stage History Index") { // Temporarily override std::cout and std::cerr with null stream to avoid terminal output - test::StreamSwap cout_swap{std::cout, test::null_stream()}; - test::StreamSwap cerr_swap{std::cerr, test::null_stream()}; + test_util::StreamSwap cout_swap{std::cout, test_util::null_stream()}; + test_util::StreamSwap cerr_swap{std::cerr, test_util::null_stream()}; test::Context context; db::RWTxn& txn{context.rw_txn()}; diff --git a/silkworm/sentry/discovery/node_db/CMakeLists.txt b/silkworm/sentry/discovery/node_db/CMakeLists.txt index 604079946a..e67644dcc5 100644 --- a/silkworm/sentry/discovery/node_db/CMakeLists.txt +++ b/silkworm/sentry/discovery/node_db/CMakeLists.txt @@ -37,4 +37,8 @@ target_link_libraries( set(TEST_TARGET ${TARGET}_test) file(GLOB_RECURSE TEST_SRC CONFIGURE_DEPENDS "*_test.cpp") add_executable(${TEST_TARGET} "${SILKWORM_MAIN_DIR}/cmd/test/unit_test.cpp" ${TEST_SRC}) -target_link_libraries(${TEST_TARGET} ${TARGET} Catch2::Catch2) +target_link_libraries( + ${TEST_TARGET} + PRIVATE ${TARGET} Catch2::Catch2 + INTERFACE silkworm_infra_test_util +) diff --git a/silkworm/sentry/discovery/node_db/node_db_sqlite_test.cpp b/silkworm/sentry/discovery/node_db/node_db_sqlite_test.cpp index 814fa27359..7f3cf5ef8b 100644 --- a/silkworm/sentry/discovery/node_db/node_db_sqlite_test.cpp +++ b/silkworm/sentry/discovery/node_db/node_db_sqlite_test.cpp @@ -16,36 +16,15 @@ #include "node_db_sqlite.hpp" -#include -#include - -#include -#include -#include #include #include +#include namespace silkworm::sentry::discovery::node_db { using namespace boost::asio; -template -static void poll_context_until_future_is_ready(io_context& context, std::future& future) { - using namespace std::chrono_literals; - context.restart(); - while (future.wait_for(0s) != std::future_status::ready) { - context.poll_one(); - } -} - -template -static TResult run(io_context& context, Task task) { - auto future = co_spawn(context, std::move(task), use_future); - poll_context_until_future_is_ready(context, future); - return future.get(); -} - bool operator==(const NodeAddress& lhs, const NodeAddress& rhs) { return (lhs.ip == rhs.ip) && (lhs.port_disc == rhs.port_disc) && @@ -53,7 +32,7 @@ bool operator==(const NodeAddress& lhs, const NodeAddress& rhs) { } TEST_CASE("NodeDbSqlite") { - io_context context; + test_util::TaskRunner runner; NodeDbSqlite db_sqlite; db_sqlite.setup_in_memory(); @@ -67,33 +46,33 @@ TEST_CASE("NodeDbSqlite") { }; SECTION("insert_and_find_address.v4") { - run(context, db.upsert_node_address(test_id, test_address)); - auto address = run(context, db.find_node_address_v4(test_id)); + runner.run(db.upsert_node_address(test_id, test_address)); + auto address = runner.run(db.find_node_address_v4(test_id)); REQUIRE(address.has_value()); CHECK(*address == test_address); - auto address_v6 = run(context, db.find_node_address_v6(test_id)); + auto address_v6 = runner.run(db.find_node_address_v6(test_id)); CHECK_FALSE(address_v6.has_value()); } SECTION("insert_and_find_address.v6") { test_address.ip = ip::make_address("::ffff:a00:110"); - run(context, db.upsert_node_address(test_id, test_address)); - auto address = run(context, db.find_node_address_v6(test_id)); + runner.run(db.upsert_node_address(test_id, test_address)); + auto address = runner.run(db.find_node_address_v6(test_id)); REQUIRE(address.has_value()); CHECK(*address == test_address); - auto address_v4 = run(context, db.find_node_address_v4(test_id)); + auto address_v4 = runner.run(db.find_node_address_v4(test_id)); CHECK_FALSE(address_v4.has_value()); } SECTION("update_address") { - run(context, db.upsert_node_address(test_id, test_address)); + runner.run(db.upsert_node_address(test_id, test_address)); NodeAddress test_address2{ ip::make_address("10.0.1.17"), 30306, 30305, }; - run(context, db.upsert_node_address(test_id, test_address2)); - auto address = run(context, db.find_node_address_v4(test_id)); + runner.run(db.upsert_node_address(test_id, test_address2)); + auto address = runner.run(db.find_node_address_v4(test_id)); REQUIRE(address.has_value()); CHECK(*address == test_address2); } @@ -101,22 +80,22 @@ TEST_CASE("NodeDbSqlite") { SECTION("insert_address_with_zero_ports") { test_address.port_disc = 0; test_address.port_rlpx = 0; - run(context, db.upsert_node_address(test_id, test_address)); - auto address = run(context, db.find_node_address_v4(test_id)); + runner.run(db.upsert_node_address(test_id, test_address)); + auto address = runner.run(db.find_node_address_v4(test_id)); REQUIRE(address.has_value()); CHECK(*address == test_address); } SECTION("insert_and_delete_node") { - run(context, db.upsert_node_address(test_id, test_address)); - run(context, db.delete_node(test_id)); - auto address = run(context, db.find_node_address_v4(test_id)); + runner.run(db.upsert_node_address(test_id, test_address)); + runner.run(db.delete_node(test_id)); + auto address = runner.run(db.find_node_address_v4(test_id)); CHECK_FALSE(address.has_value()); } SECTION("update_last_pong_time") { - run(context, db.upsert_node_address(test_id, test_address)); - run(context, db.update_last_pong_time(test_id, std::chrono::system_clock::system_clock::now())); + runner.run(db.upsert_node_address(test_id, test_address)); + runner.run(db.update_last_pong_time(test_id, std::chrono::system_clock::system_clock::now())); } } diff --git a/silkworm/silkrpc/commands/debug_api_test.cpp b/silkworm/silkrpc/commands/debug_api_test.cpp index 3bb67cec68..fcf2446f55 100644 --- a/silkworm/silkrpc/commands/debug_api_test.cpp +++ b/silkworm/silkrpc/commands/debug_api_test.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include #include @@ -208,7 +208,7 @@ class DummyDatabase : public ethdb::Database { #ifndef SILKWORM_SANITIZE TEST_CASE("DebugRpcApi") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::io_context ioc; add_shared_service(ioc, std::make_shared()); diff --git a/silkworm/silkrpc/commands/engine_api_test.cpp b/silkworm/silkrpc/commands/engine_api_test.cpp index 20a9c72203..d0e1cf01df 100644 --- a/silkworm/silkrpc/commands/engine_api_test.cpp +++ b/silkworm/silkrpc/commands/engine_api_test.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -223,7 +223,7 @@ TEST_CASE_METHOD(EngineRpcApiTest, "EngineRpcApi::handle_engine_exchange_capabil } TEST_CASE("handle_engine_get_payload_v1 succeeds if request is expected payload", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock; EXPECT_CALL(*backend, engine_get_payload(1)).WillOnce(InvokeWithoutArgs([]() -> awaitable { @@ -282,7 +282,7 @@ TEST_CASE("handle_engine_get_payload_v1 succeeds if request is expected payload" } TEST_CASE("handle_engine_get_payload_v1 fails with invalid amount of params", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; nlohmann::json reply; nlohmann::json request = R"({ @@ -323,7 +323,7 @@ TEST_CASE("handle_engine_get_payload_v1 fails with invalid amount of params", "[ } TEST_CASE("handle_engine_new_payload_v1 succeeds if request is expected payload status", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock; EXPECT_CALL(*backend, engine_new_payload(testing::_)).WillOnce(InvokeWithoutArgs([]() -> awaitable { @@ -389,7 +389,7 @@ TEST_CASE("handle_engine_new_payload_v1 succeeds if request is expected payload } TEST_CASE("handle_engine_new_payload_v1 fails with invalid amount of params", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; nlohmann::json reply; nlohmann::json request = R"({ @@ -430,7 +430,7 @@ TEST_CASE("handle_engine_new_payload_v1 fails with invalid amount of params", "[ } TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds only with forkchoiceState", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock; EXPECT_CALL(*backend, engine_forkchoice_updated(testing::_)).WillOnce(InvokeWithoutArgs([]() -> awaitable { @@ -488,7 +488,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds only with forkchoiceStat } TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds with both params", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock; EXPECT_CALL(*backend, engine_forkchoice_updated(testing::_)).WillOnce(InvokeWithoutArgs([]() -> awaitable { @@ -551,7 +551,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds with both params", "[sil } TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds with both params and second set to null", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock; EXPECT_CALL(*backend, engine_forkchoice_updated(testing::_)).WillOnce(InvokeWithoutArgs([]() -> awaitable { @@ -610,7 +610,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 succeeds with both params and sec } TEST_CASE("handle_engine_forkchoice_updated_v1 fails with invalid amount of params", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; nlohmann::json reply; nlohmann::json request = R"({ @@ -651,7 +651,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 fails with invalid amount of para } TEST_CASE("handle_engine_forkchoice_updated_v1 fails with empty finalized block hash", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock(); nlohmann::json reply; @@ -697,7 +697,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 fails with empty finalized block } TEST_CASE("handle_engine_forkchoice_updated_v1 fails with empty safe block hash", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; auto* backend = new BackEndMock(); nlohmann::json reply; @@ -743,7 +743,7 @@ TEST_CASE("handle_engine_forkchoice_updated_v1 fails with empty safe block hash" } TEST_CASE("handle_engine_transition_configuration_v1 succeeds if EL configurations has the same request configuration", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -802,7 +802,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 succeeds if EL configuratio } TEST_CASE("handle_engine_transition_configuration_v1 succeeds and default terminal block number to zero if chain config doesn't specify it", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -861,7 +861,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 succeeds and default termin } TEST_CASE("handle_engine_transition_configuration_v1 fails if incorrect terminal total difficulty", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -918,7 +918,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 fails if incorrect terminal } TEST_CASE("handle_engine_transition_configuration_v1 fails if execution layer does not have terminal total difficulty", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -975,7 +975,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 fails if execution layer do } TEST_CASE("handle_engine_transition_configuration_v1 fails if consensus layer sends wrong terminal total difficulty", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -1032,7 +1032,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 fails if consensus layer se } TEST_CASE("handle_engine_transition_configuration_v1 fails if consensus layer sends wrong terminal block hash", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -1089,7 +1089,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 fails if consensus layer se } TEST_CASE("handle_engine_transition_configuration_v1 succeeds w/o matching terminal block number", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); @@ -1147,7 +1147,7 @@ TEST_CASE("handle_engine_transition_configuration_v1 succeeds w/o matching termi } TEST_CASE("handle_engine_transition_configuration_v1 fails if incorrect params", "[silkworm][rpc][commands][engine_api]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; ClientContextPool context_pool{1}; context_pool.start(); diff --git a/silkworm/silkrpc/commands/trace_api_test.cpp b/silkworm/silkrpc/commands/trace_api_test.cpp index 4c322a7ed2..e9eb95fcd7 100644 --- a/silkworm/silkrpc/commands/trace_api_test.cpp +++ b/silkworm/silkrpc/commands/trace_api_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace silkworm::rpc::commands { @@ -27,7 +27,7 @@ using Catch::Matchers::Message; #ifndef SILKWORM_SANITIZE TEST_CASE("TraceRpcApi") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::io_context ioc; boost::asio::thread_pool workers{1}; diff --git a/silkworm/silkrpc/common/util_test.cpp b/silkworm/silkrpc/common/util_test.cpp index 5dd3611b8a..6ab52860b4 100644 --- a/silkworm/silkrpc/common/util_test.cpp +++ b/silkworm/silkrpc/common/util_test.cpp @@ -20,13 +20,13 @@ #include #include -#include +#include namespace silkworm { TEST_CASE("print Bytes", "[silkrpc][common][util]") { silkworm::Bytes b{}; - CHECK_NOTHROW(test::null_stream() << b); + CHECK_NOTHROW(test_util::null_stream() << b); } } // namespace silkworm @@ -58,28 +58,28 @@ TEST_CASE("calculate hash of transaction", "[silkrpc][common][util]") { TEST_CASE("print ByteView", "[silkrpc][common][util]") { silkworm::Bytes b1; - CHECK_NOTHROW(test::null_stream() << b1); + CHECK_NOTHROW(test_util::null_stream() << b1); silkworm::Bytes b2{*silkworm::from_hex("0x0608")}; - CHECK_NOTHROW(test::null_stream() << b2); + CHECK_NOTHROW(test_util::null_stream() << b2); } TEST_CASE("print empty address", "[silkrpc][common][util]") { evmc::address addr1{}; - CHECK_NOTHROW(test::null_stream() << addr1); + CHECK_NOTHROW(test_util::null_stream() << addr1); evmc::address addr2{0xa872626373628737383927236382161739290870_address}; - CHECK_NOTHROW(test::null_stream() << addr2); + CHECK_NOTHROW(test_util::null_stream() << addr2); } TEST_CASE("print bytes32", "[silkrpc][common][util]") { evmc::bytes32 b32_1{}; - CHECK_NOTHROW(test::null_stream() << b32_1); + CHECK_NOTHROW(test_util::null_stream() << b32_1); evmc::bytes32 b32_2{0x3763e4f6e4198413383534c763f3f5dac5c5e939f0a81724e3beb96d6e2ad0d5_bytes32}; - CHECK_NOTHROW(test::null_stream() << b32_2); + CHECK_NOTHROW(test_util::null_stream() << b32_2); } TEST_CASE("print empty const_buffer", "[silkrpc][common][util]") { boost::asio::const_buffer cb{}; - CHECK_NOTHROW(test::null_stream() << cb); + CHECK_NOTHROW(test_util::null_stream() << cb); } TEST_CASE("print empty vector of const_buffer", "[silkrpc][common][util]") { @@ -88,12 +88,12 @@ TEST_CASE("print empty vector of const_buffer", "[silkrpc][common][util]") { boost::asio::const_buffer cb2{}; v.push_back(cb1); v.push_back(cb2); - CHECK_NOTHROW(test::null_stream() << v); + CHECK_NOTHROW(test_util::null_stream() << v); } TEST_CASE("print Account", "[silkrpc][common][util]") { silkworm::Account account{}; - CHECK_NOTHROW(test::null_stream() << account); + CHECK_NOTHROW(test_util::null_stream() << account); } TEST_CASE("base64 encode", "[silkrpc][common][util]") { diff --git a/silkworm/silkrpc/core/account_dumper_test.cpp b/silkworm/silkrpc/core/account_dumper_test.cpp index 0e2917d463..9cc985e9ef 100644 --- a/silkworm/silkrpc/core/account_dumper_test.cpp +++ b/silkworm/silkrpc/core/account_dumper_test.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -199,7 +199,7 @@ class DummyDatabase : public ethdb::Database { // const evmc::address start_address{0x79a4d418f7887dd4d5123a41b6c8c186686ae8cb_address}; TEST_CASE("account dumper") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; nlohmann::json json; BlockCache block_cache(100, true); diff --git a/silkworm/silkrpc/core/blocks_test.cpp b/silkworm/silkrpc/core/blocks_test.cpp index c10d496d0c..4261a3c9ec 100644 --- a/silkworm/silkrpc/core/blocks_test.cpp +++ b/silkworm/silkrpc/core/blocks_test.cpp @@ -27,7 +27,7 @@ #include #include #include -// #include +// #include #include #include @@ -55,7 +55,7 @@ static silkworm::Bytes kHeader{*silkworm::from_hex( "00000000000000000000000000000000000000000000880000000000000000")}; TEST_CASE("get_block_number latest_required", "[silkrpc][core][blocks]") { - // SILK_LOG_STREAMS(test::null_stream(), test::null_stream()); + // SILK_LOG_STREAMS(test_util::null_stream(), test_util::null_stream()); const silkworm::ByteView kExecutionStage{stages::kExecution}; test::MockDatabaseReader db_reader; boost::asio::thread_pool pool{1}; diff --git a/silkworm/silkrpc/core/cached_chain_test.cpp b/silkworm/silkrpc/core/cached_chain_test.cpp index e2f77b609d..6357d8aeb4 100644 --- a/silkworm/silkrpc/core/cached_chain_test.cpp +++ b/silkworm/silkrpc/core/cached_chain_test.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -108,7 +108,7 @@ static void check_expected_transaction(const Transaction& transaction) { } TEST_CASE("read_block_by_number_or_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; BlockCache cache(10, true); @@ -148,7 +148,7 @@ TEST_CASE("read_block_by_number_or_hash") { } TEST_CASE("silkworm::core::read_block_by_number") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; uint64_t bn = 5'000'001; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -209,7 +209,7 @@ TEST_CASE("silkworm::core::read_block_by_number") { } TEST_CASE("silkworm::core::read_block_by_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const evmc::bytes32 bh = 0x439816753229fc0736bf86a5048de4bc9fcdede8c91dadf88c828c76b2281dff_bytes32; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -280,7 +280,7 @@ TEST_CASE("silkworm::core::read_block_by_hash") { } TEST_CASE("read_block_by_transaction_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; BlockCache cache(10, true); @@ -356,7 +356,7 @@ TEST_CASE("read_block_by_transaction_hash") { } TEST_CASE("read_transaction_by_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; BlockCache cache(10, true); diff --git a/silkworm/silkrpc/core/estimate_gas_oracle_test.cpp b/silkworm/silkrpc/core/estimate_gas_oracle_test.cpp index 76d11a9278..adfa7c9303 100644 --- a/silkworm/silkrpc/core/estimate_gas_oracle_test.cpp +++ b/silkworm/silkrpc/core/estimate_gas_oracle_test.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ using testing::InvokeWithoutArgs; using testing::Return; TEST_CASE("EstimateGasException") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("EstimateGasException(int64_t, std::string const&)") { const char* kErrorMessage{"insufficient funds for transfer"}; @@ -73,7 +73,7 @@ TEST_CASE("EstimateGasException") { } TEST_CASE("estimate gas") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; boost::asio::thread_pool workers{1}; diff --git a/silkworm/silkrpc/core/evm_executor_test.cpp b/silkworm/silkrpc/core/evm_executor_test.cpp index daaaeaa00c..681b766b4f 100644 --- a/silkworm/silkrpc/core/evm_executor_test.cpp +++ b/silkworm/silkrpc/core/evm_executor_test.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ using evmc::literals::operator""_address, evmc::literals::operator""_bytes32; #ifndef SILKWORM_SANITIZE TEST_CASE("EVMExecutor") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; class StubDatabase : public core::rawdb::DatabaseReader { [[nodiscard]] awaitable get(const std::string& /*table*/, silkworm::ByteView /*key*/) const override { diff --git a/silkworm/silkrpc/core/evm_trace_test.cpp b/silkworm/silkrpc/core/evm_trace_test.cpp index c18cfa0dbe..49ef0ca4d9 100644 --- a/silkworm/silkrpc/core/evm_trace_test.cpp +++ b/silkworm/silkrpc/core/evm_trace_test.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -5682,7 +5682,7 @@ TEST_CASE_METHOD(TraceCallExecutorTest, "TraceCallExecutor::trace_filter") { } TEST_CASE("VmTrace json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceEx trace_ex; trace_ex.used = 5000; @@ -5779,7 +5779,7 @@ TEST_CASE("VmTrace json serialization") { } TEST_CASE("TraceAction json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceAction trace_action; trace_action.from = 0xe0a2Bd4258D2768837BAa26A28fE71Dc079f84c7_address; @@ -5823,7 +5823,7 @@ TEST_CASE("TraceAction json serialization") { } TEST_CASE("TraceResult json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceResult trace_result; trace_result.address = 0xe0a2Bd4258D2768837BAa26A28fE71Dc079f84c7_address; @@ -5838,7 +5838,7 @@ TEST_CASE("TraceResult json serialization") { } TEST_CASE("Trace json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceAction trace_action; trace_action.from = 0xe0a2Bd4258D2768837BAa26A28fE71Dc079f84c7_address; @@ -5928,7 +5928,7 @@ TEST_CASE("Trace json serialization") { } TEST_CASE("StateDiff json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; StateDiff state_diff; @@ -5953,7 +5953,7 @@ TEST_CASE("StateDiff json serialization") { } TEST_CASE("DiffValue json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("no entries") { DiffValue dv; @@ -5987,7 +5987,7 @@ TEST_CASE("DiffValue json serialization") { } TEST_CASE("copy_stack") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const std::size_t stack_size{32}; evmone::uint256 stack[stack_size] = { @@ -6173,7 +6173,7 @@ TEST_CASE("copy_stack") { } TEST_CASE("copy_memory") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; evmone::Memory memory; for (std::uint8_t idx = 0; idx < 16; idx++) { @@ -6205,7 +6205,7 @@ TEST_CASE("copy_memory") { } TEST_CASE("copy_store") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const std::size_t stack_size{32}; evmone::uint256 stack[stack_size] = { @@ -6231,7 +6231,7 @@ TEST_CASE("copy_store") { } TEST_CASE("copy_memory_offset_len") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const std::size_t stack_size{32}; evmone::uint256 stack[stack_size] = { @@ -6299,7 +6299,7 @@ TEST_CASE("copy_memory_offset_len") { } TEST_CASE("push_memory_offset_len") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const std::size_t stack_size{32}; evmone::uint256 stack[stack_size] = { @@ -6343,7 +6343,7 @@ TEST_CASE("push_memory_offset_len") { } TEST_CASE("get_op_name") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const char* names[256] = { /* 0x00 */ "STOP", /* 0x01 */ "ADD", @@ -6395,7 +6395,7 @@ TEST_CASE("to_string") { } TEST_CASE("TraceConfig") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("dump on stream") { TraceConfig config{true, false, true}; @@ -6426,7 +6426,7 @@ TEST_CASE("TraceConfig") { } TEST_CASE("TraceFilter") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("dump on stream: simple") { TraceFilter config; @@ -6500,7 +6500,7 @@ TEST_CASE("TraceFilter") { } TEST_CASE("TraceCall") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("json deserialization") { nlohmann::json json = R"([ @@ -6532,7 +6532,7 @@ TEST_CASE("TraceCall") { } TEST_CASE("TraceCallTraces: json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceCallTraces tct; tct.output = "0xdeadbeaf"; @@ -6595,7 +6595,7 @@ TEST_CASE("TraceCallTraces: json serialization") { } TEST_CASE("TraceCallResult: json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceCallResult tcr; SECTION("with traces") { @@ -6610,7 +6610,7 @@ TEST_CASE("TraceCallResult: json serialization") { } TEST_CASE("TraceManyCallResult: json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; TraceManyCallResult tmcr; SECTION("with traces") { diff --git a/silkworm/silkrpc/core/fee_history_oracle_test.cpp b/silkworm/silkrpc/core/fee_history_oracle_test.cpp index 2d11b00a22..5e6fd919bd 100644 --- a/silkworm/silkrpc/core/fee_history_oracle_test.cpp +++ b/silkworm/silkrpc/core/fee_history_oracle_test.cpp @@ -19,14 +19,14 @@ #include #include -#include +#include namespace silkworm::rpc::fee_history { using Catch::Matchers::Message; TEST_CASE("FeeHistory: json serialization") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("default value") { FeeHistory fh; diff --git a/silkworm/silkrpc/core/filter_storage_test.cpp b/silkworm/silkrpc/core/filter_storage_test.cpp index 67ec90a1a8..183a81443c 100644 --- a/silkworm/silkrpc/core/filter_storage_test.cpp +++ b/silkworm/silkrpc/core/filter_storage_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace silkworm::rpc { @@ -29,7 +29,7 @@ namespace silkworm::rpc { using Catch::Matchers::Message; TEST_CASE("FilterStorage base") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; FilterStorage filter_storage{3, 0.01}; SECTION("adding 1 entry") { @@ -112,7 +112,7 @@ TEST_CASE("FilterStorage base") { } TEST_CASE("FilterStorage enhanced") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; std::uint64_t count = 0; std::uint64_t max_keys = 3; diff --git a/silkworm/silkrpc/core/rawdb/chain_test.cpp b/silkworm/silkrpc/core/rawdb/chain_test.cpp index ada4f7392a..a2a43c0d47 100644 --- a/silkworm/silkrpc/core/rawdb/chain_test.cpp +++ b/silkworm/silkrpc/core/rawdb/chain_test.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -128,7 +128,7 @@ static void check_expected_block_with_hash(const silkworm::BlockWithHash& bwh) { } TEST_CASE("read_header_number") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -153,7 +153,7 @@ TEST_CASE("read_header_number") { } TEST_CASE("read_chain_config") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -200,7 +200,7 @@ TEST_CASE("read_chain_config") { } TEST_CASE("read_chain_id") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -228,7 +228,7 @@ TEST_CASE("read_chain_id") { } TEST_CASE("read_canonical_block_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -265,7 +265,7 @@ TEST_CASE("read_canonical_block_hash") { } TEST_CASE("read_total_difficulty") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -296,7 +296,7 @@ TEST_CASE("read_total_difficulty") { } TEST_CASE("read_block_by_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -354,7 +354,7 @@ TEST_CASE("read_block_by_hash") { } TEST_CASE("read_block_by_number") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -428,7 +428,7 @@ TEST_CASE("read_block_by_number") { } TEST_CASE("read_block_number_by_transaction_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -460,7 +460,7 @@ TEST_CASE("read_block_number_by_transaction_hash") { } TEST_CASE("read_block") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -534,7 +534,7 @@ TEST_CASE("read_block") { } TEST_CASE("read_header_by_hash") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -584,7 +584,7 @@ TEST_CASE("read_header_by_hash") { } TEST_CASE("read_header_by_number") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -634,7 +634,7 @@ TEST_CASE("read_header_by_number") { } TEST_CASE("read_header") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -673,7 +673,7 @@ TEST_CASE("read_header") { } TEST_CASE("read_body") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -767,7 +767,7 @@ TEST_CASE("read_body") { } TEST_CASE("read_header_rlp") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -789,7 +789,7 @@ TEST_CASE("read_header_rlp") { } TEST_CASE("read_body_rlp") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -811,7 +811,7 @@ TEST_CASE("read_body_rlp") { } TEST_CASE("read_senders") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -853,7 +853,7 @@ TEST_CASE("read_senders") { } TEST_CASE("read_raw_receipts") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -991,7 +991,7 @@ TEST_CASE("read_raw_receipts") { } TEST_CASE("read_receipts") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1149,7 +1149,7 @@ TEST_CASE("read_receipts") { } TEST_CASE("read_canonical_transactions") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1281,7 +1281,7 @@ TEST_CASE("read_canonical_transactions") { } TEST_CASE("read_noncanonical_transactions") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1411,7 +1411,7 @@ TEST_CASE("read_noncanonical_transactions") { } TEST_CASE("read_cumulative_transaction_count") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("block found and matching") { boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1448,7 +1448,7 @@ TEST_CASE("read_cumulative_transaction_count") { } TEST_CASE("read_total_issued") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1459,7 +1459,7 @@ TEST_CASE("read_total_issued") { } TEST_CASE("read_total_burnt") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; @@ -1470,7 +1470,7 @@ TEST_CASE("read_total_burnt") { } TEST_CASE("read_cumulative_gas_used") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("read_cumulative_gas_used") { boost::asio::thread_pool pool{1}; test::MockDatabaseReader db_reader; diff --git a/silkworm/silkrpc/core/remote_state_test.cpp b/silkworm/silkrpc/core/remote_state_test.cpp index 11c3a0824f..73a35be414 100644 --- a/silkworm/silkrpc/core/remote_state_test.cpp +++ b/silkworm/silkrpc/core/remote_state_test.cpp @@ -36,7 +36,7 @@ using evmc::literals::operator""_bytes32; using evmc::literals::operator""_address; TEST_CASE("async remote buffer", "[silkrpc][core][remote_buffer]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; class MockDatabaseReader : public core::rawdb::DatabaseReader { public: @@ -411,7 +411,7 @@ struct RemoteStateTest : public test::ContextTestBase { // Exclude gRPC tests from sanitizer builds due to data race warnings inside gRPC library #ifndef SILKWORM_SANITIZE TEST_CASE_METHOD(RemoteStateTest, "RemoteState") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("overridden write methods do nothing") { CHECK_NOTHROW(remote_state_.insert_block(silkworm::Block{}, evmc::bytes32{})); diff --git a/silkworm/silkrpc/ethdb/cbor_test.cpp b/silkworm/silkrpc/ethdb/cbor_test.cpp index be77a20da2..85689ebd5d 100644 --- a/silkworm/silkrpc/ethdb/cbor_test.cpp +++ b/silkworm/silkrpc/ethdb/cbor_test.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -41,21 +41,21 @@ using evmc::literals::operator""_address, evmc::literals::operator""_bytes32; using std::string_literals::operator""s; TEST_CASE("decode logs from empty bytes", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex(""), logs)); CHECK(logs.empty()); } TEST_CASE("decode logs from empty array", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex("80"), logs)); CHECK(logs.empty()); } TEST_CASE("decode logs from CBOR 1", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex("818354000000000000000000000000000000000000000080f6"), logs)); CHECK(logs.size() == 1); @@ -65,7 +65,7 @@ TEST_CASE("decode logs from CBOR 1", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode logs from CBOR 2", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex( "82" @@ -82,7 +82,7 @@ TEST_CASE("decode logs from CBOR 2", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode logs from CBOR 3", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; auto bytes = *silkworm::from_hex("818354ea674fdde714fd979de3edf0f56aa9716b898ec88043010043"); CHECK_NOTHROW(cbor_decode(bytes, logs)); @@ -93,7 +93,7 @@ TEST_CASE("decode logs from CBOR 3", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode logs from CBOR 4", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; auto bytes = *silkworm::from_hex( "81835456c0369e002852c2570ca0cc3442e26df98e01a2835820ddf252ad1be2c89b69c2b068fc37" @@ -113,7 +113,7 @@ TEST_CASE("decode logs from CBOR 4", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode logs from incorrect bytes", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Logs logs{}; const auto b1 = *silkworm::from_hex("81"); CHECK(!cbor_decode(b1, logs)); @@ -122,21 +122,21 @@ TEST_CASE("decode logs from incorrect bytes", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode receipts from empty bytes", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex(""), receipts)); CHECK(receipts.empty()); } TEST_CASE("decode receipts from empty array", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex("80"), receipts)); CHECK(receipts.empty()); } TEST_CASE("decode receipts from CBOR 1", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex("818400f60101"), receipts)); CHECK(receipts.size() == 1); @@ -146,7 +146,7 @@ TEST_CASE("decode receipts from CBOR 1", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode receipts from CBOR 2", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; CHECK_NOTHROW(cbor_decode(*silkworm::from_hex( "82" @@ -163,7 +163,7 @@ TEST_CASE("decode receipts from CBOR 2", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode receipts from CBOR 3", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; auto bytes = *silkworm::from_hex("838400f601196d398400f6011a00371b0b8400f6011a003947f4"); CHECK_NOTHROW(cbor_decode(bytes, receipts)); @@ -177,7 +177,7 @@ TEST_CASE("decode receipts from CBOR 3", "[silkrpc][ethdb][cbor]") { } TEST_CASE("decode receipts from incorrect bytes", "[silkrpc][ethdb][cbor]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; Receipts receipts{}; const auto b1 = *silkworm::from_hex("81"); CHECK_THROWS(cbor_decode(b1, receipts)); diff --git a/silkworm/silkrpc/ethdb/kv/state_cache_test.cpp b/silkworm/silkrpc/ethdb/kv/state_cache_test.cpp index b67fdbab80..a53c7d68c4 100644 --- a/silkworm/silkrpc/ethdb/kv/state_cache_test.cpp +++ b/silkworm/silkrpc/ethdb/kv/state_cache_test.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -248,7 +248,7 @@ TEST_CASE("CoherentStateCache::CoherentStateCache", "[silkrpc][ethdb][kv][state_ } TEST_CASE("CoherentStateCache::get_view returns no view", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; boost::asio::thread_pool pool{1}; SECTION("no batch") { @@ -279,7 +279,7 @@ TEST_CASE("CoherentStateCache::get_view returns no view", "[silkrpc][ethdb][kv][ } TEST_CASE("CoherentStateCache::get_view one view", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; CoherentStateCache cache; boost::asio::thread_pool pool{1}; @@ -470,7 +470,7 @@ TEST_CASE("CoherentStateCache::get_view one view", "[silkrpc][ethdb][kv][state_c } TEST_CASE("CoherentStateCache::get_view two views", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; CoherentStateCache cache; SECTION("two single-upsert change batches => two search hits in different views") { @@ -532,7 +532,7 @@ TEST_CASE("CoherentStateCache::get_view two views", "[silkrpc][ethdb][kv][state_ } TEST_CASE("CoherentStateCache::on_new_block exceed max views", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const CoherentCacheConfig config; const auto kMaxViews{config.max_views}; CoherentStateCache cache{config}; @@ -560,7 +560,7 @@ TEST_CASE("CoherentStateCache::on_new_block exceed max views", "[silkrpc][ethdb] } TEST_CASE("CoherentStateCache::on_new_block exceed max keys", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; constexpr auto kMaxKeys{2u}; const CoherentCacheConfig config{kDefaultMaxViews, /*with_storage=*/true, kMaxKeys, kMaxKeys}; CoherentStateCache cache{config}; @@ -583,7 +583,7 @@ TEST_CASE("CoherentStateCache::on_new_block exceed max keys", "[silkrpc][ethdb][ } TEST_CASE("CoherentStateCache::on_new_block clear the cache on view ID wrapping", "[silkrpc][ethdb][kv][state_cache]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; const CoherentCacheConfig config; const auto kMaxViews{config.max_views}; CoherentStateCache cache{config}; diff --git a/silkworm/silkrpc/ethdb/kv/state_changes_stream_test.cpp b/silkworm/silkrpc/ethdb/kv/state_changes_stream_test.cpp index 0daa14a713..1fe7ccf264 100644 --- a/silkworm/silkrpc/ethdb/kv/state_changes_stream_test.cpp +++ b/silkworm/silkrpc/ethdb/kv/state_changes_stream_test.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include #include @@ -45,7 +45,7 @@ class RegistrationIntervalGuard { #ifndef SILKWORM_SANITIZE TEST_CASE("StateChangeBatch::operator<<", "[silkrpc][ethdb][kv][state_changes_stream]") { - CHECK(silkworm::test::null_stream() << remote::StateChangeBatch{}); + CHECK(silkworm::test_util::null_stream() << remote::StateChangeBatch{}); } TEST_CASE("StateChangesStream::set_registration_interval", "[silkrpc][ethdb][kv][state_changes_stream]") { diff --git a/silkworm/silkrpc/grpc/util_test.cpp b/silkworm/silkrpc/grpc/util_test.cpp index 140ba175ea..0e044ac1d7 100644 --- a/silkworm/silkrpc/grpc/util_test.cpp +++ b/silkworm/silkrpc/grpc/util_test.cpp @@ -18,13 +18,13 @@ #include -#include +#include namespace silkworm { TEST_CASE("print grpc::Status", "[silkrpc][grpc][util]") { - CHECK_NOTHROW(test::null_stream() << grpc::Status::OK); - CHECK_NOTHROW(test::null_stream() << grpc::Status::CANCELLED); + CHECK_NOTHROW(test_util::null_stream() << grpc::Status::OK); + CHECK_NOTHROW(test_util::null_stream() << grpc::Status::CANCELLED); } } // namespace silkworm diff --git a/silkworm/silkrpc/http/connection_test.cpp b/silkworm/silkrpc/http/connection_test.cpp index 734cafec58..702037aa8f 100644 --- a/silkworm/silkrpc/http/connection_test.cpp +++ b/silkworm/silkrpc/http/connection_test.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include namespace silkworm::rpc::http { @@ -33,7 +33,7 @@ using Catch::Matchers::Message; // - previous write of size 1 by main thread #ifndef SILKWORM_SANITIZE TEST_CASE("connection creation", "[silkrpc][http][connection]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("field initialization") { ClientContextPool context_pool{1}; diff --git a/silkworm/silkrpc/http/jwt_test.cpp b/silkworm/silkrpc/http/jwt_test.cpp index df5bda58d6..a7a78e6a87 100644 --- a/silkworm/silkrpc/http/jwt_test.cpp +++ b/silkworm/silkrpc/http/jwt_test.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include static char hex2ascii(char c) { @@ -52,7 +52,7 @@ static std::string ascii_from_hex(const std::string& hex) { namespace silkworm { TEST_CASE("generate_jwt_token", "[silkworm][rpc][http][jwt]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::TemporaryFile tmp_jwt_file; SECTION("empty file path") { @@ -72,7 +72,7 @@ TEST_CASE("generate_jwt_token", "[silkworm][rpc][http][jwt]") { } TEST_CASE("load_jwt_token", "[silkworm][rpc][http][jwt]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; test::TemporaryFile tmp_jwt_file; std::ofstream tmp_jwt_ofs{tmp_jwt_file.path()}; diff --git a/silkworm/silkrpc/http/server_test.cpp b/silkworm/silkrpc/http/server_test.cpp index 836b483a1e..2c2ad2212f 100644 --- a/silkworm/silkrpc/http/server_test.cpp +++ b/silkworm/silkrpc/http/server_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace silkworm::rpc::http { @@ -29,7 +29,7 @@ using Catch::Matchers::Message; // WARNING: ThreadSanitizer: signal-unsafe call inside a signal #ifndef SILKWORM_SANITIZE TEST_CASE("server creation", "[silkrpc][http][server]") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("localhost successful") { ServerContextPool context_pool{1}; diff --git a/silkworm/silkrpc/json/stream_test.cpp b/silkworm/silkrpc/json/stream_test.cpp index 390fe69014..3780ccc826 100644 --- a/silkworm/silkrpc/json/stream_test.cpp +++ b/silkworm/silkrpc/json/stream_test.cpp @@ -19,12 +19,12 @@ #include #include -#include +#include namespace silkworm::rpc::json { TEST_CASE("JsonStream", "[json]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; StringWriter string_writer; ChunksWriter chunks_writer(string_writer, 16); @@ -69,7 +69,7 @@ TEST_CASE("JsonStream", "[json]") { } TEST_CASE("JsonStream calls") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; StringWriter string_writer; Stream stream(string_writer); diff --git a/silkworm/silkrpc/test/context_test_base.hpp b/silkworm/silkrpc/test/context_test_base.hpp index bcddfd088c..86f131b74b 100644 --- a/silkworm/silkrpc/test/context_test_base.hpp +++ b/silkworm/silkrpc/test/context_test_base.hpp @@ -28,7 +28,7 @@ #include #include -#include +#include namespace silkworm::rpc::test { @@ -52,7 +52,7 @@ class ContextTestBase { ~ContextTestBase(); - silkworm::test::SetLogVerbosityGuard log_guard_; + silkworm::test_util::SetLogVerbosityGuard log_guard_; ClientContext context_; boost::asio::io_context& io_context_; agrpc::GrpcContext& grpc_context_; diff --git a/silkworm/silkrpc/types/block_test.cpp b/silkworm/silkrpc/types/block_test.cpp index 53e3460d78..754846e947 100644 --- a/silkworm/silkrpc/types/block_test.cpp +++ b/silkworm/silkrpc/types/block_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -212,7 +212,7 @@ TEST_CASE("check size of EIP-2718 block from RLP", "[silkrpc][types][block]") { CHECK(view.empty()); CHECK(rpc_block_with_hash.get_block_size() == rlp_bytes.size()); - CHECK_NOTHROW(test::null_stream() << rpc_block_with_hash); + CHECK_NOTHROW(test_util::null_stream() << rpc_block_with_hash); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/chain_config_test.cpp b/silkworm/silkrpc/types/chain_config_test.cpp index 0d451a1a39..9ffadd5be6 100644 --- a/silkworm/silkrpc/types/chain_config_test.cpp +++ b/silkworm/silkrpc/types/chain_config_test.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -35,7 +35,7 @@ TEST_CASE("create empty chain config", "[silkrpc][types][chain_config]") { TEST_CASE("print empty chain config", "[silkrpc][types][chain_config]") { ChainConfig chain_config{}; - CHECK_NOTHROW(silkworm::test::null_stream() << chain_config); + CHECK_NOTHROW(silkworm::test_util::null_stream() << chain_config); } TEST_CASE("cannot create forks from empty chain config", "[silkrpc][types][chain_config]") { diff --git a/silkworm/silkrpc/types/dump_account_test.cpp b/silkworm/silkrpc/types/dump_account_test.cpp index 82223214de..b17f07bf2a 100644 --- a/silkworm/silkrpc/types/dump_account_test.cpp +++ b/silkworm/silkrpc/types/dump_account_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -44,7 +44,7 @@ TEST_CASE("Empty DumpAccounts", "[silkrpc][types][dump_account]") { } SECTION("print") { - CHECK_NOTHROW(silkworm::test::null_stream() << da); + CHECK_NOTHROW(silkworm::test_util::null_stream() << da); } SECTION("json") { @@ -78,7 +78,7 @@ TEST_CASE("Filled DumpAccounts", "[silkrpc][types][dump_account]") { } SECTION("print") { - CHECK_NOTHROW(silkworm::test::null_stream() << das); + CHECK_NOTHROW(silkworm::test_util::null_stream() << das); } SECTION("json") { @@ -111,7 +111,7 @@ TEST_CASE("Filled zero-account DumpAccounts", "[silkrpc][types][dump_account]") } SECTION("print") { - CHECK_NOTHROW(silkworm::test::null_stream() << da); + CHECK_NOTHROW(silkworm::test_util::null_stream() << da); } SECTION("json") { diff --git a/silkworm/silkrpc/types/error_test.cpp b/silkworm/silkrpc/types/error_test.cpp index c1d013b1da..9b7284ce9f 100644 --- a/silkworm/silkrpc/types/error_test.cpp +++ b/silkworm/silkrpc/types/error_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include namespace silkworm::rpc { @@ -39,12 +39,12 @@ TEST_CASE("create empty revert error", "[silkrpc][types][error]") { TEST_CASE("print empty error", "[silkrpc][types][error]") { Error err{}; - CHECK_NOTHROW(silkworm::test::null_stream() << err); + CHECK_NOTHROW(silkworm::test_util::null_stream() << err); } TEST_CASE("print empty revert error", "[silkrpc][types][error]") { RevertError err{}; - CHECK_NOTHROW(silkworm::test::null_stream() << err); + CHECK_NOTHROW(silkworm::test_util::null_stream() << err); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/execution_payload_test.cpp b/silkworm/silkrpc/types/execution_payload_test.cpp index 9037551cd7..5dbb566e3c 100644 --- a/silkworm/silkrpc/types/execution_payload_test.cpp +++ b/silkworm/silkrpc/types/execution_payload_test.cpp @@ -18,53 +18,53 @@ #include -#include +#include namespace silkworm::rpc { TEST_CASE("print empty ExecutionPayloadV1", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ExecutionPayload{.version = ExecutionPayload::V1}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ExecutionPayload{.version = ExecutionPayload::V1}); } TEST_CASE("print empty ExecutionPayloadV2", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ExecutionPayload{.version = ExecutionPayload::V2}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ExecutionPayload{.version = ExecutionPayload::V2}); } TEST_CASE("print empty PayloadStatus", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << PayloadStatus{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << PayloadStatus{}); } TEST_CASE("print empty ForkChoiceState", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ForkChoiceState{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ForkChoiceState{}); } TEST_CASE("print empty PayloadAttributesV1", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << PayloadAttributes{.version = PayloadAttributes::V1}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << PayloadAttributes{.version = PayloadAttributes::V1}); } TEST_CASE("print empty PayloadAttributesV2", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << PayloadAttributes{.version = PayloadAttributes::V2}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << PayloadAttributes{.version = PayloadAttributes::V2}); } TEST_CASE("print empty ForkChoiceUpdatedRequest", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ForkChoiceUpdatedRequest{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ForkChoiceUpdatedRequest{}); } TEST_CASE("print empty ForkChoiceUpdatedReply", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ForkChoiceUpdatedReply{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ForkChoiceUpdatedReply{}); } TEST_CASE("print empty TransitionConfiguration", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << TransitionConfiguration{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << TransitionConfiguration{}); } TEST_CASE("print empty ExecutionPayloadAndValue", "[silkworm][rpc][types]") { ExecutionPayloadAndValue pv{.payload = {.version = ExecutionPayload::V2}, .block_value = 0}; - CHECK_NOTHROW(silkworm::test::null_stream() << pv); + CHECK_NOTHROW(silkworm::test_util::null_stream() << pv); } TEST_CASE("print empty ExecutionPayloadBody", "[silkworm][rpc][types]") { - CHECK_NOTHROW(silkworm::test::null_stream() << ExecutionPayloadBody{}); + CHECK_NOTHROW(silkworm::test_util::null_stream() << ExecutionPayloadBody{}); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/issuance_test.cpp b/silkworm/silkrpc/types/issuance_test.cpp index 22baf7f13d..393b67696d 100644 --- a/silkworm/silkrpc/types/issuance_test.cpp +++ b/silkworm/silkrpc/types/issuance_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include namespace silkworm::rpc { @@ -33,7 +33,7 @@ TEST_CASE("create empty issuance", "[silkrpc][types][issuance]") { TEST_CASE("print empty issuance", "[silkrpc][types][issuance]") { Issuance i{}; - CHECK_NOTHROW(silkworm::test::null_stream() << i); + CHECK_NOTHROW(silkworm::test_util::null_stream() << i); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/log_test.cpp b/silkworm/silkrpc/types/log_test.cpp index 3a36609ba4..96149bc054 100644 --- a/silkworm/silkrpc/types/log_test.cpp +++ b/silkworm/silkrpc/types/log_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -34,7 +34,7 @@ TEST_CASE("create empty log", "[silkrpc][types][log]") { TEST_CASE("print empty log", "[silkrpc][types][log]") { Log l{}; - CHECK_NOTHROW(silkworm::test::null_stream() << l); + CHECK_NOTHROW(silkworm::test_util::null_stream() << l); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/receipt_test.cpp b/silkworm/silkrpc/types/receipt_test.cpp index 679dc5ca2e..ba26fe9bf3 100644 --- a/silkworm/silkrpc/types/receipt_test.cpp +++ b/silkworm/silkrpc/types/receipt_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -38,7 +38,7 @@ TEST_CASE("create empty receipt", "[silkrpc][types][receipt]") { TEST_CASE("print empty receipt", "[silkrpc][types][receipt]") { Receipt r{}; - CHECK_NOTHROW(silkworm::test::null_stream() << r); + CHECK_NOTHROW(silkworm::test_util::null_stream() << r); } TEST_CASE("print receipt", "[silkrpc][types][receipt]") { @@ -51,7 +51,7 @@ TEST_CASE("print receipt", "[silkrpc][types][receipt]") { r.from = 0x0715a7794a1dc8e42615f059dd6e406a6594651a_address; r.to = 0x0715a7794a1dc8e42615f059dd6e406a6594651a_address; r.type = 2; - CHECK_NOTHROW(silkworm::test::null_stream() << r); + CHECK_NOTHROW(silkworm::test_util::null_stream() << r); } TEST_CASE("bloom from empty logs", "[silkrpc][types][receipt]") { diff --git a/silkworm/silkrpc/types/transaction_test.cpp b/silkworm/silkrpc/types/transaction_test.cpp index e4a63ea9ce..24ee5ec7c1 100644 --- a/silkworm/silkrpc/types/transaction_test.cpp +++ b/silkworm/silkrpc/types/transaction_test.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include namespace silkworm::rpc { @@ -40,12 +40,12 @@ TEST_CASE("create empty transaction", "[silkrpc][types][transaction]") { TEST_CASE("create empty silkworm::transaction", "[silkrpc][types][silkworm::transaction]") { silkworm::Transaction txn{}; - CHECK_NOTHROW(silkworm::test::null_stream() << txn); + CHECK_NOTHROW(silkworm::test_util::null_stream() << txn); } TEST_CASE("print empty transaction", "[silkrpc][types][transaction]") { Transaction txn{}; - CHECK_NOTHROW(silkworm::test::null_stream() << txn); + CHECK_NOTHROW(silkworm::test_util::null_stream() << txn); } TEST_CASE("print type-2 transaction", "[silkrpc][types][transaction]") { @@ -71,7 +71,7 @@ TEST_CASE("print type-2 transaction", "[silkrpc][types][transaction]") { 110'045'619'790, // block_base_fee_per_gas 144, // transaction index }; - CHECK_NOTHROW(silkworm::test::null_stream() << txn); + CHECK_NOTHROW(silkworm::test_util::null_stream() << txn); } TEST_CASE("print type-2 silkworm::transaction", "[silkrpc][types][silkworm::transaction]") { @@ -91,7 +91,7 @@ TEST_CASE("print type-2 silkworm::transaction", "[silkrpc][types][silkworm::tran intx::from_string("0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a"), // s 0x7ad75fdb6244111753822140dad3337f5535f718_address, // from }; - CHECK_NOTHROW(silkworm::test::null_stream() << txn); + CHECK_NOTHROW(silkworm::test_util::null_stream() << txn); } TEST_CASE("create legacy transaction", "[silkrpc][types][transaction]") { @@ -135,7 +135,7 @@ TEST_CASE("create legacy silkworm::transaction", "[silkrpc][types][silkworm::tra 0xa1e4380a3b1f749673e270229993ee55f35663b4_address, // from }; - CHECK_NOTHROW(silkworm::test::null_stream() << txn); + CHECK_NOTHROW(silkworm::test_util::null_stream() << txn); } } // namespace silkworm::rpc diff --git a/silkworm/silkrpc/types/writer_test.cpp b/silkworm/silkrpc/types/writer_test.cpp index d7a1500576..8a9359d2ff 100644 --- a/silkworm/silkrpc/types/writer_test.cpp +++ b/silkworm/silkrpc/types/writer_test.cpp @@ -21,12 +21,12 @@ #include #include -#include +#include namespace silkworm::rpc { TEST_CASE("StringWriter", "[silkrpc]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("write") { StringWriter writer; @@ -48,7 +48,7 @@ TEST_CASE("StringWriter", "[silkrpc]") { } TEST_CASE("ChunksWriter", "[silkrpc]") { - silkworm::test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + silkworm::test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; SECTION("write&close under chunk size") { StringWriter s_writer; diff --git a/silkworm/sync/internals/header_chain_plus_exec_test.cpp b/silkworm/sync/internals/header_chain_plus_exec_test.cpp index c537bc5fa2..be0209bdc9 100644 --- a/silkworm/sync/internals/header_chain_plus_exec_test.cpp +++ b/silkworm/sync/internals/header_chain_plus_exec_test.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -66,7 +66,7 @@ class DummyRuleSet : public protocol::IRuleSet { }; TEST_CASE("Headers receiving and saving") { - test::SetLogVerbosityGuard log_guard(log::Level::kNone); + test_util::SetLogVerbosityGuard log_guard(log::Level::kNone); asio::io_context io; asio::executor_work_guard work{io.get_executor()}; diff --git a/silkworm/sync/internals/header_chain_test.cpp b/silkworm/sync/internals/header_chain_test.cpp index e6dc98a592..28ff194294 100644 --- a/silkworm/sync/internals/header_chain_test.cpp +++ b/silkworm/sync/internals/header_chain_test.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include namespace silkworm { // Useful definitions @@ -47,7 +47,7 @@ class HeaderChainForTest : public HeaderChain { // ---------------------------------------------------------------------------- TEST_CASE("HeaderList - split_into_segments - No headers") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; auto headerList = HeaderList::make(headers); @@ -59,7 +59,7 @@ TEST_CASE("HeaderList - split_into_segments - No headers") { } TEST_CASE("HeaderList - split_into_segments - Single header") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header; @@ -75,7 +75,7 @@ TEST_CASE("HeaderList - split_into_segments - Single header") { } TEST_CASE("HeaderList - split_into_segments - Single header repeated twice") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header; @@ -92,7 +92,7 @@ TEST_CASE("HeaderList - split_into_segments - Single header repeated twice") { } TEST_CASE("HeaderList - split_into_segments - Two connected headers") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -118,7 +118,7 @@ TEST_CASE("HeaderList - split_into_segments - Two connected headers") { } TEST_CASE("HeaderList - split_into_segments - Two connected headers with wrong numbers") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -147,7 +147,7 @@ TEST_CASE("HeaderList - split_into_segments - Two connected headers with wrong n * 3 segments: {h3}, {h2}, {h1} (in this order) */ TEST_CASE("HeaderList - split_into_segments - Two headers connected to the third header") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -184,7 +184,7 @@ TEST_CASE("HeaderList - split_into_segments - Two headers connected to the third } TEST_CASE("HeaderList - split_into_segments - Same three headers, but in a reverse order") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -226,7 +226,7 @@ TEST_CASE("HeaderList - split_into_segments - Same three headers, but in a rever * 2 segments: {h3?}, {h2?} */ TEST_CASE("HeaderList - split_into_segments - Two headers not connected to each other") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -265,7 +265,7 @@ TEST_CASE("HeaderList - split_into_segments - Two headers not connected to each * 1 segment: {h3, h2, h1} (with header in this order) */ TEST_CASE("HeaderList - split_into_segments - Three headers connected") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -305,7 +305,7 @@ TEST_CASE("HeaderList - split_into_segments - Three headers connected") { * 3 segments: {h3?}, {h4?}, {h2, h1} */ TEST_CASE("HeaderList - split_into_segments - Four headers connected") { - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; std::vector headers; BlockHeader header1; @@ -351,7 +351,7 @@ TEST_CASE("HeaderList - split_into_segments - Four headers connected") { TEST_CASE("HeaderChain - process_segment - (1) simple chain") { using namespace std; - test::SetLogVerbosityGuard guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard guard{log::Level::kNone}; ChainConfig chain_config{kMainnetConfig}; chain_config.genesis_hash.emplace(kMainnetGenesisHash); @@ -1221,7 +1221,7 @@ TEST_CASE("HeaderChain - process_segment - (6) (malicious) siblings") { } TEST_CASE("HeaderChain - process_segment - (7) invalidating anchor") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; using namespace std; ChainConfig chain_config{kMainnetConfig}; @@ -1319,7 +1319,7 @@ TEST_CASE("HeaderChain - process_segment - (7) invalidating anchor") { } TEST_CASE("HeaderChain - process_segment - (8) sibling with anchor invalidation and links reduction") { - test::SetLogVerbosityGuard log_guard{log::Level::kNone}; + test_util::SetLogVerbosityGuard log_guard{log::Level::kNone}; using namespace std; ChainConfig chain_config{kMainnetConfig};