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).
This commit is contained in:
Matthew Wolter
2026-06-15 16:55:41 -07:00
parent c208839a06
commit 1b1d66053c

View File

@@ -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"
# ---------------------------------------------------------------------------