diff options
author | luigi1111 <luigi1111w@gmail.com> | 2021-04-16 13:52:44 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2021-04-16 13:52:44 -0500 |
commit | e45619e61e4831eea70a43fe6985f4d57ea02e9e (patch) | |
tree | 0d4b5301559941855cbce9525148c3a55137e827 /tests/unit_tests/epee_levin_protocol_handler_async.cpp | |
parent | Merge pull request #7653 (diff) | |
download | monero-e45619e61e4831eea70a43fe6985f4d57ea02e9e.tar.xz |
Revert "Merge pull request #7136"
This reverts commit 63c7ca07fba2f063c760f786a986fb3e02fb040e, reversing
changes made to 2218e23e84a89e9a1e4c0be5d50f891ab836754f.
Diffstat (limited to 'tests/unit_tests/epee_levin_protocol_handler_async.cpp')
-rw-r--r-- | tests/unit_tests/epee_levin_protocol_handler_async.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index d9de99b8b..a499fa608 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -59,13 +59,13 @@ namespace { } - virtual int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_stream& buff_out, test_levin_connection_context& context) + virtual int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, test_levin_connection_context& context) { m_invoke_counter.inc(); boost::unique_lock<boost::mutex> lock(m_mutex); m_last_command = command; m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size()); - buff_out.write(epee::to_span(m_invoke_out_buf)); + buff_out = m_invoke_out_buf.clone(); return m_return_code; } @@ -434,11 +434,8 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_process const int expected_command = 4673261; const std::string in_data(256, 'e'); - epee::levin::message_writer message{}; - message.buffer.write(epee::to_span(in_data)); - const epee::byte_slice noise = epee::levin::make_noise_notify(1024); - const epee::byte_slice notify = message.finalize_notify(expected_command); + const epee::byte_slice notify = epee::levin::make_notify(expected_command, epee::strspan<std::uint8_t>(in_data)); test_connection_ptr conn = create_connection(); @@ -471,16 +468,11 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_process const int expected_command = 4673261; const int expected_fragmented_command = 46732; const std::string in_data(256, 'e'); - - epee::levin::message_writer message{}; - message.buffer.write(epee::to_span(in_data)); - - epee::levin::message_writer in_fragmented_data; - in_fragmented_data.buffer.put_n('c', 1024 * 4); + std::string in_fragmented_data(1024 * 4, 'c'); const epee::byte_slice noise = epee::levin::make_noise_notify(1024); - const epee::byte_slice notify = message.finalize_notify(expected_command); - epee::byte_slice fragmented = epee::levin::make_fragmented_notify(noise.size(), expected_fragmented_command, std::move(in_fragmented_data)); + const epee::byte_slice notify = epee::levin::make_notify(expected_command, epee::strspan<std::uint8_t>(in_data)); + epee::byte_slice fragmented = epee::levin::make_fragmented_notify(noise, expected_fragmented_command, epee::strspan<std::uint8_t>(in_fragmented_data)); EXPECT_EQ(5u, fragmented.size() / 1024); EXPECT_EQ(0u, fragmented.size() % 1024); @@ -505,13 +497,11 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_process ASSERT_TRUE(conn->m_protocol_handler.handle_recv(next.data(), next.size())); } - std::string compare_buffer(1024 * 4, 'c'); - compare_buffer.resize(((1024 - sizeof(epee::levin::bucket_head2)) * 5) - sizeof(epee::levin::bucket_head2)); // add padding zeroes - + in_fragmented_data.resize(((1024 - sizeof(epee::levin::bucket_head2)) * 5) - sizeof(epee::levin::bucket_head2)); // add padding zeroes ASSERT_EQ(4u, m_commands_handler.notify_counter()); ASSERT_EQ(0u, m_commands_handler.invoke_counter()); ASSERT_EQ(expected_fragmented_command, m_commands_handler.last_command()); - ASSERT_EQ(compare_buffer, m_commands_handler.last_in_buf()); + ASSERT_EQ(in_fragmented_data, m_commands_handler.last_in_buf()); ASSERT_EQ(0u, conn->send_counter()); ASSERT_TRUE(conn->last_send_data().empty()); |