From 421adc9888ca3e597059a3d07faedfe8458b8b4d Mon Sep 17 00:00:00 2001 From: Robert Walton Date: Mon, 26 Jul 2021 21:52:05 +0100 Subject: [PATCH] unittests: Fix Test_LoRaWANStack.acquire_tx_metadata This test was relying on the state of `LoRaMac_stub::bool_true_counter` to be set to 1 from a previous test. When the test was ran in isolation the `LoRaWANStack::rx_timeout_interrupt_handler` callback would fail because we weren't returning true from the stub implementation of `LoRaMac::nwk_joined`. Due to this `LoRaWANStack::post_process_tx_no_reception` was never called. This caused the LoRaWANStack object to think the "tx_metadata" was "stale" (i.e the data hadn't changed since any previous read). So, when we attempted to call `LoRaWANStack::acquire_tx_metadata` it returned `LORAWAN_STATUS_METADATA_NOT_AVAILABLE` as it thought we had no new metadata to report, causing the test assertion to fail. --- .../features/lorawan/lorawanstack/Test_LoRaWANStack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/connectivity/lorawan/tests/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp b/connectivity/lorawan/tests/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp index 4903dd75b5..33057fddaf 100644 --- a/connectivity/lorawan/tests/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp +++ b/connectivity/lorawan/tests/UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp @@ -631,6 +631,7 @@ TEST_F(Test_LoRaWANStack, acquire_tx_metadata) memset(&conf, 0, sizeof(conf)); conf.status = LORAMAC_EVENT_INFO_STATUS_OK; LoRaMac_stub::mcps_conf_ptr = &conf; + LoRaMac_stub::bool_true_counter = 1; radio._ev->tx_done(); LoRaMac_stub::slot_value = RX_SLOT_WIN_2;