Files
firmware/test/support/AdminModuleTestShim.h
T
James Rich b65fa9505c Send admin-made owner changes and admin NodeInfo requests past the routine throttle
An admin set_owner announced the new name through the routine NodeInfo path, so a rename made within
30 minutes of the last NodeInfo never went out - and the reboot set_owner schedules inherits that
throttle from the persisted transmit history. Inside an edit transaction nothing was sent at all.
The change is now announced on the 60 s interactive gate once it is saved, at commit for a
transaction.

A signed NodeInfo request from a node holding a live PKC admin session is likewise answered on the
60 s gate, past the 30 minute floor and the 12 h per-requester suppression.
2026-10-30 13:59:44 -05:00

52 lines
2.1 KiB
C++

#pragma once
// The one class AdminModule.h befriends (test seam): exposes the protected/private handlers to the
// native suites and defers persistence so setters exercise in-RAM logic without disk/reboot effects.
#include "MeshTypes.h" // packetPool
#include "UptimeClock.h"
#include "modules/AdminModule.h"
class AdminModuleTestShim : public AdminModule
{
public:
using AdminModule::checkPassKey; // session-key gate seam (see test_admin_session_repro)
using AdminModule::handleGetConfig;
using AdminModule::handleGetModuleConfig;
using AdminModule::handleReceivedProtobuf;
using AdminModule::handleSetConfig;
using AdminModule::handleSetModuleConfig;
using AdminModule::handleSetOwner;
using AdminModule::responseIsSolicited; // request/response pairing gate
using AdminModule::setPassKey;
// Peek at the reply a handler queued, before drainReply() releases it.
meshtastic_MeshPacket *reply() { return myReply; }
// With an "open edit transaction" saveChanges() is a pure no-op: no reloadConfig/saveToDisk/reboot.
// Stamps the clock like begin_edit_settings, so a slow suite can't age the transaction into expiry.
void deferSaves()
{
hasOpenEditTransaction = true;
editTransactionActivityMs = millis();
}
int savedSegments() const { return lastSaveWhatForTest; }
bool editTransactionOpen() const { return hasOpenEditTransaction; }
// Stand in for a PKC-authorized admin message from `node`, without the key setup that path needs.
void openRemoteSession(NodeNum node)
{
remoteSessionNode = node;
remoteSessionMs = Time::stampMillis();
}
// Backdate past the idle window so a test sees an abandoned transaction without waiting it out.
void ageEditTransaction() { editTransactionActivityMs = millis() - EDIT_TRANSACTION_IDLE_MS - 1; }
// Setters may allocate an error reply from packetPool; drain it each iteration or the pool leaks.
void drainReply()
{
if (myReply) {
packetPool.release(myReply);
myReply = nullptr;
}
}
};