diff options
| author | Lee *!* Clagett <code@leeclagett.com> | 2024-12-17 16:40:15 -0500 |
|---|---|---|
| committer | Lee *!* Clagett <code@leeclagett.com> | 2025-02-14 13:29:57 -0500 |
| commit | 01bcd52924244ec8d2a24c10fcef8959289d09ff (patch) | |
| tree | 7aa82581901a978c3c7ba3b0f50ac8c84f753945 /tests/unit_tests/levin.cpp | |
| parent | 23a11d851adef30aea1888da0a7dd23936c81ec1 (diff) | |
| download | monzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.tar.gz monzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.tar.xz monzero-core-01bcd52924244ec8d2a24c10fcef8959289d09ff.zip | |
Fix build with boost ASIO 0.87. Support boost 1.66+
Diffstat (limited to 'tests/unit_tests/levin.cpp')
| -rw-r--r-- | tests/unit_tests/levin.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/tests/unit_tests/levin.cpp b/tests/unit_tests/levin.cpp index 6eac92de7..25b67907f 100644 --- a/tests/unit_tests/levin.cpp +++ b/tests/unit_tests/levin.cpp @@ -54,7 +54,7 @@ namespace { class test_endpoint final : public epee::net_utils::i_service_endpoint { - boost::asio::io_service& io_service_; + boost::asio::io_context& io_service_; std::size_t ref_count_; virtual bool do_send(epee::byte_slice message) override final @@ -83,7 +83,7 @@ namespace throw std::logic_error{"request_callback not implemented"}; } - virtual boost::asio::io_service& get_io_service() override final + virtual boost::asio::io_context& get_io_context() override final { return io_service_; } @@ -101,7 +101,7 @@ namespace } public: - test_endpoint(boost::asio::io_service& io_service) + test_endpoint(boost::asio::io_context& io_service) : epee::net_utils::i_service_endpoint(), io_service_(io_service), ref_count_(0), @@ -171,7 +171,7 @@ namespace epee::levin::async_protocol_handler<cryptonote::levin::detail::p2p_context> handler_; public: - test_connection(boost::asio::io_service& io_service, cryptonote::levin::connections& connections, boost::uuids::random_generator& random_generator, const bool is_incoming) + test_connection(boost::asio::io_context& io_service, cryptonote::levin::connections& connections, boost::uuids::random_generator& random_generator, const bool is_incoming) : endpoint_(io_service), context_(), handler_(std::addressof(endpoint_), connections, context_) @@ -364,7 +364,7 @@ namespace } boost::uuids::random_generator random_generator_; - boost::asio::io_service io_service_; + boost::asio::io_context io_service_; test_receiver receiver_; std::deque<test_connection> contexts_; test_core_events events_; @@ -626,7 +626,7 @@ TEST_F(levin_notify, fluff_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); ASSERT_LT(0u, io_service_.poll()); @@ -680,7 +680,7 @@ TEST_F(levin_notify, stem_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -751,7 +751,7 @@ TEST_F(levin_notify, stem_no_outs_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); if (events_.has_stem_txes()) @@ -820,7 +820,7 @@ TEST_F(levin_notify, local_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(their_txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(their_txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -860,7 +860,7 @@ TEST_F(levin_notify, local_without_padding) context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(my_txs, context->get_id(), cryptonote::relay_method::local)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_TRUE(events_.has_stem_txes()); EXPECT_EQ(my_txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -922,7 +922,7 @@ TEST_F(levin_notify, forward_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -990,7 +990,7 @@ TEST_F(levin_notify, block_without_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1021,7 +1021,7 @@ TEST_F(levin_notify, none_without_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1052,7 +1052,7 @@ TEST_F(levin_notify, fluff_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); ASSERT_LT(0u, io_service_.poll()); @@ -1103,7 +1103,7 @@ TEST_F(levin_notify, stem_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -1172,7 +1172,7 @@ TEST_F(levin_notify, stem_no_outs_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); if (events_.has_stem_txes()) @@ -1235,7 +1235,7 @@ TEST_F(levin_notify, local_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(their_txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(their_txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -1273,7 +1273,7 @@ TEST_F(levin_notify, local_with_padding) context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(my_txs, context->get_id(), cryptonote::relay_method::local)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_TRUE(events_.has_stem_txes()); EXPECT_EQ(my_txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -1332,7 +1332,7 @@ TEST_F(levin_notify, forward_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); const bool is_stem = events_.has_stem_txes(); EXPECT_EQ(txs, events_.take_relayed(is_stem ? cryptonote::relay_method::stem : cryptonote::relay_method::fluff)); @@ -1398,7 +1398,7 @@ TEST_F(levin_notify, block_with_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1429,7 +1429,7 @@ TEST_F(levin_notify, none_with_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1460,10 +1460,10 @@ TEST_F(levin_notify, private_fluff_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); @@ -1513,10 +1513,10 @@ TEST_F(levin_notify, private_stem_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -1566,10 +1566,10 @@ TEST_F(levin_notify, private_local_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::local)); @@ -1619,10 +1619,10 @@ TEST_F(levin_notify, private_forward_without_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::forward)); @@ -1672,7 +1672,7 @@ TEST_F(levin_notify, private_block_without_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1704,7 +1704,7 @@ TEST_F(levin_notify, private_none_without_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1735,10 +1735,10 @@ TEST_F(levin_notify, private_fluff_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); @@ -1787,10 +1787,10 @@ TEST_F(levin_notify, private_stem_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -1839,10 +1839,10 @@ TEST_F(levin_notify, private_local_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::local)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::local)); @@ -1891,10 +1891,10 @@ TEST_F(levin_notify, private_forward_with_padding) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::forward)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::forward)); @@ -1943,7 +1943,7 @@ TEST_F(levin_notify, private_block_with_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::block)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -1974,7 +1974,7 @@ TEST_F(levin_notify, private_none_with_padding) auto context = contexts_.begin(); EXPECT_FALSE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::none)); - io_service_.reset(); + io_service_.restart(); ASSERT_EQ(0u, io_service_.poll()); } } @@ -2008,14 +2008,14 @@ TEST_F(levin_notify, stem_mappings) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); if (events_.has_stem_txes()) break; EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(0u, context->process_send_queue()); @@ -2032,7 +2032,7 @@ TEST_F(levin_notify, stem_mappings) } notifier.run_epoch(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); } EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -2070,7 +2070,7 @@ TEST_F(levin_notify, stem_mappings) auto& incoming = contexts_[i % contexts_.size()]; EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::stem)); @@ -2133,7 +2133,7 @@ TEST_F(levin_notify, fluff_multiple) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); if (!events_.has_stem_txes()) break; @@ -2164,12 +2164,12 @@ TEST_F(levin_notify, fluff_multiple) } notifier.run_epoch(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); } EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); { auto context = contexts_.begin(); @@ -2192,10 +2192,10 @@ TEST_F(levin_notify, fluff_multiple) auto& incoming = contexts_[i % contexts_.size()]; EXPECT_TRUE(notifier.send_txs(txs, incoming.get_id(), cryptonote::relay_method::stem)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); @@ -2252,7 +2252,7 @@ TEST_F(levin_notify, fluff_with_duplicate) auto context = contexts_.begin(); EXPECT_TRUE(notifier.send_txs(txs, context->get_id(), cryptonote::relay_method::fluff)); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); notifier.run_fluff(); ASSERT_LT(0u, io_service_.poll()); @@ -2303,7 +2303,7 @@ TEST_F(levin_notify, noise) } notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); { std::size_t sent = 0; @@ -2316,7 +2316,7 @@ TEST_F(levin_notify, noise) EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::local)); notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::local)); @@ -2338,7 +2338,7 @@ TEST_F(levin_notify, noise) txs[0].resize(3000, 'r'); EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::fluff)); notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); EXPECT_EQ(txs, events_.take_relayed(cryptonote::relay_method::fluff)); @@ -2352,7 +2352,7 @@ TEST_F(levin_notify, noise) } notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); { std::size_t sent = 0; @@ -2397,7 +2397,7 @@ TEST_F(levin_notify, noise_stem) } notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); { std::size_t sent = 0; @@ -2410,7 +2410,7 @@ TEST_F(levin_notify, noise_stem) EXPECT_TRUE(notifier.send_txs(txs, incoming_id, cryptonote::relay_method::stem)); notifier.run_stems(); - io_service_.reset(); + io_service_.restart(); ASSERT_LT(0u, io_service_.poll()); // downgraded to local when being notified |
