From 2efff1889be91cf77f67b8ecc70f900aa03732eb Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 18 Aug 2026 18:13:57 -0500 Subject: [PATCH] test(event): make the coordinate-port RX expectation event-mode aware test_private_channel_preserves_legacy_tx_and_rx_for_all_coordinate_ports sent all three coordinate ports over a private channel and expected all three back. On an USERPREFS_EVENT_MODE build that is wrong: event mode forces the CORE_PORTNUMS_ONLY filter in Router::dispatchReceived() and MAP_REPORT_APP is not in its allow-list, so a map report is dropped before module dispatch - on any channel, event or private. The suite failed with "Expected 3 Was 2" on every event branch, with or without the event-channel coordinate policy. Add kRxDeliverableCoordinatePorts (one fewer under event mode) and use it for the receive-side assertion; TX is not portnum-filtered so it still expects all three. kExpectedEventDeliveryCount's non-blocking branch derives from it too, so an event-mode build with the position block disabled gets the right expectation. Test-only: no firmware behavior change. The map-report drop is intended event-mode behavior. CI does not see this because coverage-event-policy sets USERPREFS_BLOCK_POSITION_ON_EVENT_CHANNEL and CHANNEL_0_PSK but not EVENT_MODE. Co-Authored-By: Claude Fable 5 --- test/test_event_channel_router/test_main.cpp | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/test/test_event_channel_router/test_main.cpp b/test/test_event_channel_router/test_main.cpp index f7d1af54b..46d6af961 100644 --- a/test/test_event_channel_router/test_main.cpp +++ b/test/test_event_channel_router/test_main.cpp @@ -39,6 +39,22 @@ constexpr NodeNum kPkiPeer = 0x33333333; constexpr ChannelIndex kEventChannel = 0; constexpr ChannelIndex kPrivateChannel = 1; +constexpr std::array kCoordinatePorts = { + meshtastic_PortNum_POSITION_APP, + meshtastic_PortNum_WAYPOINT_APP, + meshtastic_PortNum_MAP_REPORT_APP, +}; + +// How many of kCoordinatePorts survive the receive path to reach the modules, on ANY channel. +// USERPREFS_EVENT_MODE forces the CORE_PORTNUMS_ONLY filter in Router::dispatchReceived(), and +// MAP_REPORT_APP is not in that allow-list, so a map report is dropped before module dispatch on +// event-mode builds. Unrelated to the event-channel coordinate policy, which is keyed on the PSK. +#if USERPREFS_EVENT_MODE +constexpr size_t kRxDeliverableCoordinatePorts = kCoordinatePorts.size() - 1; +#else +constexpr size_t kRxDeliverableCoordinatePorts = kCoordinatePorts.size(); +#endif + #if USERPREFS_BLOCK_POSITION_ON_EVENT_CHANNEL constexpr bool kBlockEventCoordinates = true; constexpr ErrorCode kExpectedEventTxResult = meshtastic_Routing_Error_NOT_AUTHORIZED; @@ -46,15 +62,9 @@ constexpr size_t kExpectedEventDeliveryCount = 0; #else constexpr bool kBlockEventCoordinates = false; constexpr ErrorCode kExpectedEventTxResult = ERRNO_OK; -constexpr size_t kExpectedEventDeliveryCount = 3; +constexpr size_t kExpectedEventDeliveryCount = kRxDeliverableCoordinatePorts; #endif -constexpr std::array kCoordinatePorts = { - meshtastic_PortNum_POSITION_APP, - meshtastic_PortNum_WAYPOINT_APP, - meshtastic_PortNum_MAP_REPORT_APP, -}; - class TestNodeDB : public NodeDB { public: @@ -247,8 +257,10 @@ static void test_private_channel_preserves_legacy_tx_and_rx_for_all_coordinate_p receivePacket(makeDecodedPacket(port, kRemoteNode, NODENUM_BROADCAST, kPrivateChannel)); } + // TX is not portnum-filtered, so every coordinate port still goes out; RX drops map reports on + // event-mode builds (see kRxDeliverableCoordinatePorts). TEST_ASSERT_EQUAL_UINT32(kCoordinatePorts.size(), captureRadio->packets.size()); - TEST_ASSERT_EQUAL_UINT32(kCoordinatePorts.size(), captureModule->packets.size()); + TEST_ASSERT_EQUAL_UINT32(kRxDeliverableCoordinatePorts, captureModule->packets.size()); } #if !(MESHTASTIC_EXCLUDE_PKI)