diff --git a/nano/core_test/socket.cpp b/nano/core_test/socket.cpp index 5c72b48571..bd9bafb2b6 100644 --- a/nano/core_test/socket.cpp +++ b/nano/core_test/socket.cpp @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -417,12 +418,12 @@ TEST (socket_timeout, write) }); // check that the callback was called and we got an error - ASSERT_TIMELY_EQ (10s, done, true); + ASSERT_TIMELY (10s, done); ASSERT_TRUE (ec.load ()); - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_write_error, nano::stat::dir::in)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_write_error, nano::stat::dir::in)); // check that the socket was closed due to tcp_io_timeout timeout - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); } TEST (socket_timeout, read_overlapped) @@ -446,8 +447,8 @@ TEST (socket_timeout, read_overlapped) auto buffer = std::make_shared> (1); nano::async_write (newsock, nano::shared_const_buffer (buffer), [] (boost::system::error_code const & ec_a, size_t size_a) { - debug_assert (!ec_a); - debug_assert (size_a == 1); + EXPECT_TRUE (!ec_a); + EXPECT_TRUE (size_a == 1); }); }); @@ -461,11 +462,12 @@ TEST (socket_timeout, read_overlapped) auto buffer = std::make_shared> (1); socket->async_read (buffer, 1, [] (boost::system::error_code const & ec_a, size_t size_a) { - debug_assert (size_a == 1); + EXPECT_FALSE (ec_a); + EXPECT_TRUE (size_a == 1); }); socket->async_read (buffer, 1, [&ec, &done] (boost::system::error_code const & ec_a, size_t size_a) { - debug_assert (size_a == 0); + EXPECT_EQ (size_a, 0); if (ec_a) { ec = ec_a; @@ -477,10 +479,10 @@ TEST (socket_timeout, read_overlapped) // check that the callback was called and we got an error ASSERT_TIMELY_EQ (10s, done, true); ASSERT_TRUE (ec); - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_read_error, nano::stat::dir::in)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_read_error, nano::stat::dir::in)); // check that the socket was closed due to tcp_io_timeout timeout - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); } TEST (socket_timeout, write_overlapped) @@ -507,7 +509,8 @@ TEST (socket_timeout, write_overlapped) EXPECT_FALSE (ec_a); boost::asio::async_read (newsock, boost::asio::buffer (buffer->data (), buffer->size ()), [] (boost::system::error_code const & ec_a, size_t size_a) { - debug_assert (size_a == 1); + EXPECT_FALSE (ec_a); + EXPECT_EQ (size_a, 1); }); }); @@ -521,7 +524,8 @@ TEST (socket_timeout, write_overlapped) auto buffer1 = std::make_shared> (1); auto buffer2 = std::make_shared> (128 * 1024); socket->async_write (nano::shared_const_buffer{ buffer1 }, [] (boost::system::error_code const & ec_a, size_t size_a) { - debug_assert (size_a == 1); + EXPECT_FALSE (ec_a); + EXPECT_EQ (size_a, 1); }); for (auto i = 0; i < 1024; ++i) { @@ -538,8 +542,8 @@ TEST (socket_timeout, write_overlapped) // check that the callback was called and we got an error ASSERT_TIMELY_EQ (10s, done, true); ASSERT_TRUE (ec.load ()); - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_write_error, nano::stat::dir::in)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_write_error, nano::stat::dir::in)); // check that the socket was closed due to tcp_io_timeout timeout - ASSERT_EQ (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); + ASSERT_LE (1, node->stats.count (nano::stat::type::tcp, nano::stat::detail::tcp_io_timeout_drop, nano::stat::dir::out)); } diff --git a/nano/node/transport/tcp_socket.cpp b/nano/node/transport/tcp_socket.cpp index 4560d35a7d..1e96e4e306 100644 --- a/nano/node/transport/tcp_socket.cpp +++ b/nano/node/transport/tcp_socket.cpp @@ -5,8 +5,6 @@ #include #include -#include - #include #include #include