aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLee *!* Clagett <code@leeclagett.com>2026-03-10 09:23:03 -0400
committerLee *!* Clagett <code@leeclagett.com>2026-03-31 14:50:35 -0400
commit017c9022d7bbc03484191177228657b14fb09f53 (patch)
treebe2e2fdd1d5a7972ac44a3130936d61234b9a018 /tests
parentee1bbe766317b2197510d038753be62f09c13c00 (diff)
downloadmonzero-core-017c9022d7bbc03484191177228657b14fb09f53.tar.gz
monzero-core-017c9022d7bbc03484191177228657b14fb09f53.tar.xz
monzero-core-017c9022d7bbc03484191177228657b14fb09f53.zip
Cleanup some of the fragmented levin handling
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/epee_levin_protocol_handler_async.cpp22
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()));
+}