Cleanup some of the fragmented levin handling

This commit is contained in:
Lee *!* Clagett
2026-03-10 09:23:03 -04:00
parent ee1bbe7663
commit 017c9022d7
2 changed files with 33 additions and 5 deletions
@@ -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()));
}