diff options
| author | tobtoht <tob@featherwallet.org> | 2026-04-04 18:45:15 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2026-04-04 18:45:15 +0000 |
| commit | 1df631970fa610824117c85e05afddcedcdf8196 (patch) | |
| tree | ef7473b3ffb9deb854c790a2ff3124632dca16c9 /tests | |
| parent | 2953f74a84f534d10fe45d2d4c7002f350e0adbd (diff) | |
| parent | 017c9022d7bbc03484191177228657b14fb09f53 (diff) | |
| download | monzero-core-1df631970fa610824117c85e05afddcedcdf8196.tar.gz monzero-core-1df631970fa610824117c85e05afddcedcdf8196.tar.xz monzero-core-1df631970fa610824117c85e05afddcedcdf8196.zip | |
Merge pull request #10395
017c902 Cleanup some of the fragmented levin handling (Lee *!* Clagett)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit_tests/epee_levin_protocol_handler_async.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index 9dbb2c19b..4ea6fde90 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -506,7 +506,6 @@ TEST_F(positive_test_connection_to_levin_protocol_handler_calls, handler_process } 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 ASSERT_EQ(4u, m_commands_handler.notify_counter()); ASSERT_EQ(0u, m_commands_handler.invoke_counter()); @@ -652,3 +651,24 @@ TEST_F(test_levin_protocol_handler__hanle_recv_with_invalid_data, handles_short_ ASSERT_FALSE(m_conn->m_protocol_handler.handle_recv(m_buf.data(), m_buf.size())); } + +TEST_F(test_levin_protocol_handler__hanle_recv_with_invalid_data, handles_bad_cb) +{ + m_req_head.m_cb = sizeof(epee::levin::bucket_head2); + m_req_head.m_flags = LEVIN_PACKET_BEGIN; + m_req_head.m_command = 0; + + epee::levin::bucket_head2 inner{}; + inner.m_cb = 2; + m_in_data.resize(sizeof(epee::levin::bucket_head2)); + prepare_buf(); + + ASSERT_TRUE(m_conn->m_protocol_handler.handle_recv(m_buf.data(), m_buf.size())); + + m_req_head.m_cb = 1; + m_req_head.m_flags = LEVIN_PACKET_END; + m_in_data.resize(1); + prepare_buf(); + + ASSERT_FALSE(m_conn->m_protocol_handler.handle_recv(m_buf.data(), m_buf.size())); +} |
