mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-11-01 10:12:03 +00:00
Merge pull request #109 from kylemanna/fix-test-issues
Fix send_cmd destination handling and ADVERT_PATH test fixture
This commit is contained in:
@@ -73,10 +73,11 @@ class MessagingCommands(CommandHandlerBase):
|
|||||||
timestamp = int(time.time())
|
timestamp = int(time.time())
|
||||||
|
|
||||||
if dst_type is None:
|
if dst_type is None:
|
||||||
dst_type = dst["type"]
|
if isinstance(dst, dict) and "type" in dst:
|
||||||
else: # assume destination is a repeater
|
dst_type = dst["type"]
|
||||||
logger.warning("Can't determine destination type, please ensure contacts first or specify dst_type when calling `send_cmd`. Assuming it's a repeater.")
|
else: # assume destination is a repeater
|
||||||
dst_type = AdvType.REPEATER.value
|
logger.warning("Can't determine destination type, please ensure contacts first or specify dst_type when calling `send_cmd`. Assuming it's a repeater.")
|
||||||
|
dst_type = AdvType.REPEATER.value
|
||||||
|
|
||||||
cmd_data = bytearray([CommandType.SEND_TXT_MSG.value])
|
cmd_data = bytearray([CommandType.SEND_TXT_MSG.value])
|
||||||
if dst_type == AdvType.CHAT.value :
|
if dst_type == AdvType.CHAT.value :
|
||||||
|
|||||||
@@ -286,10 +286,10 @@ async def test_advert_path_preserves_embedded_zero_bytes():
|
|||||||
dispatcher = _CapturingDispatcher()
|
dispatcher = _CapturingDispatcher()
|
||||||
reader = MessageReader(dispatcher)
|
reader = MessageReader(dispatcher)
|
||||||
|
|
||||||
# ADVERT_PATH (0x0e), 2 hops, 3-byte hashes.
|
# ADVERT_PATH (0x16), timestamp 1, 2 hops, 3-byte hashes.
|
||||||
# path_len byte: hash mode 2 (3 bytes) + 2 hops = 0x82.
|
# path_len byte: hash mode 2 (3 bytes) + 2 hops = 0x82.
|
||||||
# The first hash deliberately contains an embedded 0x00 byte.
|
# The first hash deliberately contains an embedded 0x00 byte.
|
||||||
packet = bytearray.fromhex("0e8212003456789a")
|
packet = bytearray.fromhex("16010000008212003456789a")
|
||||||
|
|
||||||
await reader.handle_rx(packet)
|
await reader.handle_rx(packet)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user