diff --git a/nano/test_common/system.cpp b/nano/test_common/system.cpp index 1e0f938f7..6d14598a5 100644 --- a/nano/test_common/system.cpp +++ b/nano/test_common/system.cpp @@ -32,7 +32,8 @@ std::string nano::error_system_messages::message (int ev) const */ nano::test::system::system () : - io_ctx{ std::make_shared () } + io_ctx{ std::make_shared () }, + io_guard{ boost::asio::make_work_guard (*io_ctx) } { auto scale_str = std::getenv ("DEADLINE_SCALE_FACTOR"); if (scale_str) @@ -70,6 +71,16 @@ nano::test::system::~system () #endif } +void nano::test::system::stop () +{ + io_guard.reset (); + for (auto & node : nodes) + { + node->stop (); + } + work.stop (); +} + nano::node & nano::test::system::node (std::size_t index) const { debug_assert (index < nodes.size ()); @@ -574,15 +585,6 @@ void nano::test::system::generate_mass_activity (uint32_t count_a, nano::node & } } -void nano::test::system::stop () -{ - for (auto i : nodes) - { - i->stop (); - } - work.stop (); -} - nano::node_config nano::test::system::default_config () { nano::node_config config{ get_available_port () }; diff --git a/nano/test_common/system.hpp b/nano/test_common/system.hpp index 00808006a..dffa0a47d 100644 --- a/nano/test_common/system.hpp +++ b/nano/test_common/system.hpp @@ -75,6 +75,7 @@ namespace test public: std::shared_ptr io_ctx; + boost::asio::executor_work_guard io_guard; std::vector> nodes; nano::stats stats; nano::logger logger{ "tests" };