mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-07 01:13:11 +02:00
Refactor packet handling in PacketRouter and RepeaterHandler
- Removed redundant original_path assignment in `RepeaterHandler` to streamline packet processing. - Introduced `_is_direct_final_hop` helper method in `PacketRouter` to determine if a packet is the final destination for direct routes with an empty path. - Updated comments in `PacketRouter` to clarify the handling of packets during routing, especially for direct forwarding scenarios. - Adjusted logic to ensure packets are correctly processed or delivered based on their routing status, enhancing overall packet management.
This commit is contained in:
@@ -287,9 +287,10 @@ class TestDirectForward:
|
||||
assert result.path_len == 2
|
||||
|
||||
def test_single_hop_path_consumed(self, handler):
|
||||
"""After consuming our hash the path becomes empty — packet delivered."""
|
||||
"""Single hop to us: we strip and return packet with empty path (forward so it can reach destination)."""
|
||||
pkt = _make_direct_packet(path=bytes([LOCAL_HASH]))
|
||||
result = handler.direct_forward(pkt)
|
||||
assert result is not None
|
||||
assert list(result.path) == []
|
||||
assert result.path_len == 0
|
||||
|
||||
@@ -1044,7 +1045,7 @@ GOOD_PACKETS = [
|
||||
lambda: _make_flood_packet(payload=b"\xAB\x01\x02\x03", payload_type=4)),
|
||||
|
||||
("good_direct_minimal",
|
||||
"Direct, 1-byte payload, single hop to us",
|
||||
"Direct, 1-byte payload, single hop to us (forward with empty path)",
|
||||
lambda: _make_direct_packet(payload=b"\x01", path=bytes([LOCAL_HASH]))),
|
||||
|
||||
("good_direct_multihop",
|
||||
|
||||
Reference in New Issue
Block a user