Skip to content

Commit 453eecf

Browse files
NomDeTomclaude
andcommitted
test/tmm: fix thresholdAbove255_clamps loop count
The unknown counter is a 6-bit field (saturates at 63); the threshold is capped at 60 so saturated readings always exceed it. A config value of 300 clamps to 60, meaning the 61st packet is the first drop — not the 256th. Loop count corrected from 255 to 60 to match the actual implementation cap. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a312da9 commit 453eecf

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/test_traffic_management/test_main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,9 @@ static void test_tm_unknownPackets_resetAfterWindowExpires(void)
10061006
}
10071007

10081008
/**
1009-
* Verify unknown threshold values above 255 clamp to the counter ceiling.
1010-
* Important to align config semantics with saturating counter storage.
1009+
* Verify unknown threshold values above the implementation cap (60) are clamped.
1010+
* The counter is a 6-bit field (saturates at 63); threshold is capped at 60 so a
1011+
* saturated reading always exceeds it. A config value of 300 should behave as 60.
10111012
*/
10121013
static void test_tm_unknownPackets_thresholdAbove255_clamps(void)
10131014
{
@@ -1016,7 +1017,7 @@ static void test_tm_unknownPackets_thresholdAbove255_clamps(void)
10161017
TrafficManagementModuleTestShim module;
10171018
meshtastic_MeshPacket packet = makeUnknownPacket(kRemoteNode);
10181019

1019-
for (int i = 0; i < 255; i++) {
1020+
for (int i = 0; i < 60; i++) {
10201021
ProcessMessage result = module.handleReceived(packet);
10211022
TEST_ASSERT_EQUAL_INT(static_cast<int>(ProcessMessage::CONTINUE), static_cast<int>(result));
10221023
}

0 commit comments

Comments
 (0)