From 11ab1597f6a8359bdf656cd46fc44ab75198d796 Mon Sep 17 00:00:00 2001 From: David Ventura Date: Tue, 30 Apr 2024 11:58:04 +0200 Subject: [PATCH] test punchpkt parsing --- tests/fn.test.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/fn.test.js b/tests/fn.test.js index 3d4df96..8d48872 100644 --- a/tests/fn.test.js +++ b/tests/fn.test.js @@ -3,9 +3,8 @@ import "../shim.ts"; import assert from "assert"; import { XqBytesDec, XqBytesEnc } from "../func_replacements.js"; -import { createResponseForControlCommand } from "../handlers.js"; import { hexdump } from "../hexdump.js"; -import { SendStartVideo, SendDevStatus, SendUsrChk, SendWifiDetails } from "../impl.ts"; +import { SendStartVideo, SendDevStatus, SendUsrChk, SendWifiDetails, parse_PunchPkt } from "../impl.ts"; import { placeholderTypes, sprintf } from "../utils.js"; describe("debug_tools", () => { @@ -128,6 +127,21 @@ describe("events", () => { // TODO }); }); +describe("parse packet", () => { + it("parses PunchPkt", () => { + const in_pkt_str = "f14100144241544400000000000262ca574f4e4a4d000000"; + const pkt = new DataView(hstrToBA(in_pkt_str)); + const expected = { + prefix: "BATD", + serial: "156362", + suffix: "WONJM", + serialU64: bigint(156362), + devId: "BATD156362WONJM", + }; + + assert.equal(parse_PunchPkt(pkt), expected); + }); +}); describe("make packet", () => { it("builds a good SendUsrChk", () => { const expected_str =