From 1b1d66053cfa10c1d4961f005e712cb48dfeca8a Mon Sep 17 00:00:00 2001 From: Matthew Wolter Date: Mon, 15 Jun 2026 16:55:41 -0700 Subject: [PATCH] test: fix send_raw_data wrapper for 4-byte guard and path_len framing Why: PR #86 (44b21be) reworked send_raw_data to frame as 0x19 | path_len(1) | path | payload and to reject payloads under 4 bytes, but left test_send_raw_data_wrapper unchanged. The test sent a 2-byte payload (now raising ValueError before any assertion) and asserted captured_data[1:] == payload, which no longer holds because of the inserted path_len byte. The firmware drops payloads under 4 bytes, so the guard is correct; this fixes the test, not the guard. Bumps the payload to 4 bytes and asserts the zero path_len byte plus the payload at offset 2, validating the wire format #86 introduced. Tests: tests/unit/test_protocol_surface_gaps.py -- full suite 156 passed (test_send_raw_data_wrapper was the lone failure on current main). --- tests/unit/test_protocol_surface_gaps.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_protocol_surface_gaps.py b/tests/unit/test_protocol_surface_gaps.py index 7688517..4048e4a 100644 --- a/tests/unit/test_protocol_surface_gaps.py +++ b/tests/unit/test_protocol_surface_gaps.py @@ -186,7 +186,7 @@ async def test_send_trace_with_path_no_padding(): @pytest.mark.asyncio async def test_send_raw_data_wrapper(): - """send_raw_data sends CMD 0x19 + payload.""" + """send_raw_data sends CMD 0x19 + path_len + payload.""" from meshcore.commands.messaging import MessagingCommands cmd = MessagingCommands.__new__(MessagingCommands) @@ -200,11 +200,12 @@ async def test_send_raw_data_wrapper(): cmd.send = mock_send - await cmd.send_raw_data(b"\xDE\xAD") + await cmd.send_raw_data(b"\xDE\xAD\xBE\xEF") assert captured_data is not None assert captured_data[0] == 0x19 # CMD_SEND_RAW_DATA - assert captured_data[1:] == b"\xDE\xAD" + assert captured_data[1] == 0x00 # path_len: zero-hop direct (empty path) + assert captured_data[2:] == b"\xDE\xAD\xBE\xEF" # ---------------------------------------------------------------------------