diff --git a/test/fixtures/remote_cli_command_identity/test.cpp b/test/fixtures/remote_cli_command_identity/test.cpp index 4d7c932c6..37cbb8c85 100644 --- a/test/fixtures/remote_cli_command_identity/test.cpp +++ b/test/fixtures/remote_cli_command_identity/test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #undef MESH_DEBUG_PRINTLN @@ -18,9 +19,6 @@ #ifndef MESH_ENABLE_HOST_CLI #define MESH_ENABLE_HOST_CLI 0 #endif -#define PAYLOAD_TYPE_REQ 0 -#define PAYLOAD_TYPE_RESPONSE 1 -#define PAYLOAD_TYPE_TXT_MSG 2 #define TXT_TYPE_PLAIN 0 #define TXT_TYPE_CLI_DATA 1 #define TXT_TYPE_CLI_COMMAND 2 @@ -28,13 +26,6 @@ #define TXT_ACK_DELAY 1 namespace mesh { -struct Packet { - uint8_t path[MAX_PATH_SIZE] = {}; - uint8_t path_len = 0, radio_profile = 0; - uint32_t radio_generation = 1; - bool isRouteFlood() const { return false; } - uint8_t getPathHashSize() const { return 1; } -}; struct Utils { template static void sha256(uint8_t* dest, size_t size, Args...) { memset(dest, 0, size); } @@ -135,18 +126,21 @@ public: std::vector reply_destinations; MyMesh() { now_millis = 100;mesh::console.records.clear(); + queued_ack.header = ROUTE_TYPE_DIRECT; queued_ack.radio_generation = 1; acl.clients[0].id.pub_key[0] = 0x12; acl.clients[1].id.pub_key[0] = 0x77; acl.clients[2].id.pub_key[0] = 0x88; } Clock* getRTCClock() { return &clock; } RNG* getRNG() { return &rng; } uint32_t futureMillis(uint32_t delay) const { return millis() + delay; } bool millisHasNowPassed(uint32_t deadline) const { return int32_t(millis() - deadline) >= 0; } - int handleRequest(ClientInfo*, uint32_t, uint8_t*, size_t) { return 0; } + int handleRequest(ClientInfo*, uint32_t, uint8_t*, size_t, size_t) { return 0; } template mesh::Packet* createPathReturn(Args...) { return nullptr; } template mesh::Packet* createDatagram(Args...) { return nullptr; } - template void sendFloodReply(Args...) {} + template bool sendFloodReply(Args...) { return queue_accepts; } mesh::Packet* createAck(uint32_t) { return nullptr; } - template void sendClientReply(Args...) { ++acknowledgements; } + template bool sendClientReply(Args...) { + ++acknowledgements; return queue_accepts; + } bool sendRemoteCliReply(ClientInfo* client, const uint8_t* secret, uint8_t, uint32_t, const char* reply, const TransportKey*, mesh::Packet** queued = nullptr) { if (!queue_accepts) return false; @@ -209,6 +203,8 @@ public: 5, strlen(text), logical_id); assert(size != 0); mesh::Packet packet; + packet.header = ROUTE_TYPE_DIRECT; + packet.radio_generation = 1; onPeerDataRecv(&packet, PAYLOAD_TYPE_TXT_MSG, sender, secret, wire, size); if (process) processDeferredCliCommand(); } diff --git a/test/test_remote_cli_command_identity.py b/test/test_remote_cli_command_identity.py index aad76f88c..1f9c75f4b 100644 --- a/test/test_remote_cli_command_identity.py +++ b/test/test_remote_cli_command_identity.py @@ -40,12 +40,16 @@ class RemoteCliCommandIdentityTest(unittest.TestCase): completion = extract_braced(source, "bool MyMesh::completeHostCliRequest(") serial_reply = extract_braced(source, "bool MyMesh::handleHostCliSerialReply(") clear = extract_braced(source, "void MyMesh::clearDeferredCliCommand()") + packet = (ROOT / "src/Packet.cpp").read_text(encoding="utf-8") + packet_methods = "namespace mesh {\n" + "\n".join( + extract_braced(packet, signature) for signature in ( + "Packet::Packet()", "bool Packet::isValidPathLen(")) + "\n}\n" with tempfile.TemporaryDirectory(prefix="meshcore-cli-identity-") as directory: work = Path(directory) (work / "normalization.inc").write_text(generated, encoding="utf-8") (work / "acl_delete.inc").write_text(acl[delete_start:delete_end], encoding="utf-8") (work / "production.inc").write_text("\n".join( - (receive, dispatch, completion, serial_reply, clear)), encoding="utf-8") + (packet_methods, receive, dispatch, completion, serial_reply, clear)), encoding="utf-8") binary = work / "cli-identity.exe" sanitizer = ["-fsanitize=address,undefined", "-fno-sanitize-recover=all", "-fno-pie", "-no-pie"] if sys.platform.startswith("linux") else []