test punchpkt parsing

This commit is contained in:
David Ventura
2024-04-30 12:00:37 +02:00
parent 3edccdc4ab
commit 11ab1597f6
+16 -2
View File
@@ -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 =