From c71d3df3322cb2168395ff29f753c08cd43d8045 Mon Sep 17 00:00:00 2001 From: Nox Date: Thu, 4 Jun 2026 12:45:59 +0800 Subject: [PATCH] Add unit test for onResponseTraceRoute ROUTING_APP error handling Co-Authored-By: Claude Sonnet 4.6 --- meshtastic/tests/test_mesh_interface.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/meshtastic/tests/test_mesh_interface.py b/meshtastic/tests/test_mesh_interface.py index 8d53628..d002c18 100644 --- a/meshtastic/tests/test_mesh_interface.py +++ b/meshtastic/tests/test_mesh_interface.py @@ -757,3 +757,23 @@ def test_timeago_fuzz(seconds): """Fuzz _timeago to ensure it works with any integer""" val = _timeago(seconds) assert re.match(r"(now|\d+ (secs?|mins?|hours?|days?|months?|years?))", val) + + +@pytest.mark.unit +@pytest.mark.usefixtures("reset_mt_config") +def test_onResponseTraceRoute_routing_error(capsys): + """Test that onResponseTraceRoute handles ROUTING_APP error packets correctly.""" + iface = MeshInterface(noProto=True) + + packet = { + "decoded": { + "portnum": "ROUTING_APP", + "routing": {"errorReason": "MAX_RETRANSMIT"}, + } + } + + iface.onResponseTraceRoute(packet) + + assert iface._acknowledgment.receivedTraceRoute is True + out, _ = capsys.readouterr() + assert "Traceroute failed: MAX_RETRANSMIT" in out