mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-04 03:18:10 +10:00
fix(NodeDB): reset a persisted event firmware_edition on vanilla builds (#11504)
* fix(NodeDB): reset a persisted event firmware_edition on vanilla builds myNodeInfo lives in devicestate, which survives a firmware reinstall, and the boot-time edition stamp was compiled out entirely on builds without USERPREFS_FIRMWARE_EDITION. A device flashed from an event build back to vanilla therefore kept reporting the event edition forever, and clients kept its branding until a factory reset. Stamp VANILLA in the else branch so the running build is always the source of truth. * Stamp the edition before the boot save decision, and assert the on-disk value Review follow-up: the stamp sat after the devicestate CRC compare, so an edition-only change stayed RAM-only and the persisted event edition survived on disk. Move it next to the other running-build-wins fixups (device_id, min_app_version), which run inside the CRC window, and extend the test to read device.proto back so the persisted value is asserted too.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
# suite flags reason
|
||||
test_admin_radio writes=config.proto,module.proto,device.proto,channels.proto,nodes.proto,warm.dat,Messages_default.msgs per-test NodeDB fixture, and the admin handlers under test persist config, channels and node metadata
|
||||
test_admin_session_repro writes=config.proto,module.proto,device.proto,channels.proto,nodes.proto constructs a NodeDB, whose constructor persists a default set when the prefs directory is empty
|
||||
test_firmware_edition writes=config.proto,module.proto,device.proto,channels.proto,nodes.proto persists an event firmware_edition in devicestate, then reboots a NodeDB to prove a vanilla build resets it
|
||||
test_fuzz_packets writes=config.proto,module.proto,device.proto,channels.proto,nodes.proto,warm.dat,Messages_default.msgs drives decode of fuzzed packets through the real NodeDB and message store
|
||||
test_hop_scaling writes=config.proto,module.proto,device.proto,channels.proto,nodes.proto constructs a NodeDB to hold the hop-distance fixtures
|
||||
test_mesh_beacon writes=module.proto exercises the beacon's module-config save path
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 48.
|
@@ -0,0 +1,49 @@
|
||||
// devicestate.my_node survives a firmware reinstall, so a vanilla build (no
|
||||
// USERPREFS_FIRMWARE_EDITION) must reset a persisted event edition at boot.
|
||||
#include "MeshTypes.h" // Include BEFORE TestUtil.h
|
||||
#include "TestUtil.h"
|
||||
#include "mesh/NodeDB.h"
|
||||
#include <unity.h>
|
||||
|
||||
#if defined(ARCH_PORTDUINO)
|
||||
#define FE_TEST_ENTRY extern "C"
|
||||
#else
|
||||
#define FE_TEST_ENTRY
|
||||
#endif
|
||||
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
|
||||
static meshtastic_FirmwareEdition persistedEdition()
|
||||
{
|
||||
meshtastic_DeviceState saved = meshtastic_DeviceState_init_zero;
|
||||
TEST_ASSERT_EQUAL(LoadFileResult::LOAD_SUCCESS, nodeDB->loadProto(deviceStateFileName, meshtastic_DeviceState_size,
|
||||
sizeof(saved), &meshtastic_DeviceState_msg, &saved));
|
||||
return saved.my_node.firmware_edition;
|
||||
}
|
||||
|
||||
static void test_vanillaBoot_resetsPersistedEventEdition(void)
|
||||
{
|
||||
devicestate.my_node.firmware_edition = meshtastic_FirmwareEdition_DEFCON;
|
||||
TEST_ASSERT_TRUE(nodeDB->saveToDisk(SEGMENT_DEVICESTATE));
|
||||
TEST_ASSERT_EQUAL(meshtastic_FirmwareEdition_DEFCON, persistedEdition());
|
||||
|
||||
NodeDB *rebooted = new NodeDB();
|
||||
delete nodeDB;
|
||||
nodeDB = rebooted;
|
||||
|
||||
TEST_ASSERT_EQUAL(meshtastic_FirmwareEdition_VANILLA, devicestate.my_node.firmware_edition);
|
||||
// On disk too, not just in RAM: the stamp must land before the boot save decision.
|
||||
TEST_ASSERT_EQUAL(meshtastic_FirmwareEdition_VANILLA, persistedEdition());
|
||||
}
|
||||
|
||||
FE_TEST_ENTRY void setup()
|
||||
{
|
||||
initializeTestEnvironment();
|
||||
nodeDB = new NodeDB();
|
||||
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_vanillaBoot_resetsPersistedEventEdition);
|
||||
exit(UNITY_END());
|
||||
}
|
||||
FE_TEST_ENTRY void loop() {}
|
||||
Reference in New Issue
Block a user