chat / client / test / selftest.test.mjs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// lib/selftest.ts's assertion suite, run for real.
//
// It is the app's own dev-time crypto contract: HKDF room derivations, the
// signaling/message/binary round trips with their AAD bindings, IV uniqueness
// for both sealer families, the identity assertion's room+peer binding, the
// at-rest cross-instance round trip and reject table, and the hardened access
// controller's authorship check. In the TypeScript it ran behind
// `import.meta.env.DEV`; here it is a first-class test, so a divergence in any
// of those fails `npm test` rather than a console message nobody reads.
import test from "node:test";
import assert from "node:assert/strict";
import { installDom } from "./harness/dom.mjs";
import { mods } from "./helpers/load.mjs";

installDom();
const M = await mods();

test("runSelfTest passes end to end", async () => {
  const realInfo = console.info;
  const lines = [];
  console.info = (...a) => lines.push(a.join(" "));
  try {
    await M.runSelfTest();
  } finally {
    console.info = realInfo;
  }
  assert.deepEqual(lines, ["✅ crypto self-test passed"]);
});

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/chat.git