Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/test_radio/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,27 @@ static void test_regionPresetMap_unsetCarriesUserprefsIntent()

static void test_beginSending_oversizedPayloadAbortsSafely()
{
// Allocate a packet and set required header fields
meshtastic_MeshPacket *p = packetPool.allocZeroed();
TEST_ASSERT_NOT_NULL(p);
p->from = 0x12345678;
p->to = 0x87654321;
p->id = 0x10203040;
p->which_payload_variant = meshtastic_MeshPacket_encrypted_tag;

// Set encrypted size larger than sizeof(radioBuffer.payload) (which is 256 - sizeof(PacketHeader))
// Set encrypted size larger than radioBuffer.payload capacity to trigger rejection
p->encrypted.size = testRadio->getRadioBufferPayloadCapacity() + 10;

// Call beginSending with the oversized packet
size_t result = testRadio->beginSendingPublic(p);

// Verify the send was rejected (returns 0)
TEST_ASSERT_EQUAL_UINT(0, result);

// Verify sendingPacket was NOT set (packet was not queued)
TEST_ASSERT_NULL(testRadio->getSendingPacket());

// Verify rejected packet was released to packetPool and its slot is reusable
meshtastic_MeshPacket *reallocated = packetPool.allocZeroed();
TEST_ASSERT_NOT_NULL(reallocated);
TEST_ASSERT_EQUAL_PTR(p, reallocated);
packetPool.release(reallocated);
// LeakSanitizer on CI will automatically detect if p wasn't released to packetPool
}

void setUp(void)
Expand Down