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 <noreply@anthropic.com>
This commit is contained in:
Ben MeadorsandClaude Fable 5 committed 2026-08-18 18:13:57 -05:00
1 parent 32563e0d65
commit 2efff1889b
1 file changed
+20 -8
+20 -8
View File
@@ -39,6 +39,22 @@ constexpr NodeNum kPkiPeer = 0x33333333;
constexpr ChannelIndex kEventChannel = 0;
constexpr ChannelIndex kPrivateChannel = 1;
constexpr std::array<meshtastic_PortNum, 3> 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<meshtastic_PortNum, 3> 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)