add tests and more validation to packets, remove crc setting from config as hardcoded.

This commit is contained in:
Lloyd
2026-03-02 11:35:50 +00:00
parent 0967f899a1
commit c2f57c3d0f
4 changed files with 1280 additions and 8 deletions

View File

@@ -133,9 +133,6 @@ radio:
# Sync word (LoRa network ID)
sync_word: 13380
# Enable CRC checking
crc_enabled: true
# Use implicit header mode
implicit_header: false

View File

@@ -513,6 +513,8 @@ class RepeaterHandler(BaseHandler):
if self.is_duplicate(packet):
packet.drop_reason = "Duplicate"
return None
self.mark_seen(packet)
if packet.path is None:
packet.path = bytearray()
@@ -522,12 +524,22 @@ class RepeaterHandler(BaseHandler):
packet.path.append(self.local_hash)
packet.path_len = len(packet.path)
self.mark_seen(packet)
return packet
def direct_forward(self, packet: Packet) -> Optional[Packet]:
# Validate packet (empty payload, oversized path, etc.)
valid, reason = self.validate_packet(packet)
if not valid:
packet.drop_reason = reason
return None
# Check if packet is marked do-not-retransmit
if packet.is_marked_do_not_retransmit():
if not packet.drop_reason:
packet.drop_reason = "Marked do not retransmit"
return None
# Check if we're the next hop
if not packet.path or len(packet.path) == 0:
packet.drop_reason = "Direct: no path"
@@ -543,12 +555,11 @@ class RepeaterHandler(BaseHandler):
packet.drop_reason = "Duplicate"
return None
original_path = list(packet.path)
self.mark_seen(packet)
packet.path = bytearray(packet.path[1:])
packet.path_len = len(packet.path)
self.mark_seen(packet)
return packet
@staticmethod

0
tests/__init__.py Normal file
View File

1264
tests/test_engine.py Normal file

File diff suppressed because it is too large Load Diff