add SendUsrChk and test it

This commit is contained in:
DavidVentura
2024-01-25 10:09:41 +01:00
parent 723384b89a
commit 957a4b5cab
4 changed files with 29 additions and 4 deletions
+12 -1
View File
@@ -1,9 +1,10 @@
import "../shim.js";
import "../shim.ts";
import assert from "assert";
import { placeholderTypes, sprintf } from "../utils.js";
import { XqBytesDec, XqBytesEnc } from "../func_replacements.js";
import { SendUsrChk } from "../impl.ts";
describe("debug_tools", () => {
it("parses printed data", () => {
@@ -89,3 +90,13 @@ describe("module", () => {
assert.deepEqual(new Uint8Array(in_buf.buffer), long_dec_bytes); //DEC
});
});
const hstrToBA = (hs) => new Uint8Array(hs.match(/../g).map((h) => parseInt(h, 16))).buffer;
describe("make packet", () => {
it("builds a good SendUsrChk", () => {
const expected_str =
"f1d000b0d1000000110a2010a400ff00000000006f01010101010101010101010101010101010101010101010101010160656c686f01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010160656c68";
const expected = hstrToBA(expected_str);
assert.deepEqual(SendUsrChk("admin", "admin").buffer, expected);
});
});