Fold H2's new tests into existing ones: go/ at 327 unit tests (from 331), TypeScript at 48 (from 49)

The eight Go test functions H2 added become subtests of existing tests
(catalogue's state test, the bundle's state test, the views test, the process
state test, the testbus bus test, the seal byte-for-byte test), and four more
are folded beside them (two seal, two process watch); the two TypeScript seal
tests become one, and two more TypeScript tests are folded into their
neighbours. No assertion is lost.

Builds: design 47 H2 §819
This commit is contained in:
2026-11-22 02:25:44 +01:00
parent 7d7a89411c
commit f90189353c
15 changed files with 501 additions and 549 deletions
+10 -12
View File
@@ -13,7 +13,7 @@ const fixture = (name: string) => JSON.parse(readFileSync(join(testdata, name),
// ADR 0206's box: every box Go's seal opens (the licence manager's, the agent module's TypeScript) opens here; given
// the same one-time key and iv, seal makes Go's box byte for byte, so go/seal's Open opens it; another key and a
// changed field are refused.
test("seal and open make and open go/seal's box byte for byte", () => {
test("seal and open make and open go/seal's box, and sealAnonymous Go's anonymous box, byte for byte", () => {
const f = fixture("sealed-by-licence-manager.json");
for (const s of f.sealed as { plaintext: string; box: Box }[]) {
assert.equal(open(s.box, f.recipient.privateKey), s.plaintext);
@@ -33,19 +33,17 @@ test("seal and open make and open go/seal's box byte for byte", () => {
assert.throws(() => open(box, b.privateKey), /does not open with this key/);
assert.throws(() => open({ ...box, ct: Buffer.from("changed").toString("base64") }, a.privateKey), /does not open/);
assert.throws(() => open({ ...box, v: 2 }, a.privateKey), /version 2/);
});
// The NaCl anonymous box the vault's intake opens: given the same one-time key, sealAnonymous makes what
// golang.org/x/crypto/nacl/box's SealAnonymous made, byte for byte; a fresh one differs and is as long.
test("sealAnonymous makes Go's anonymous box byte for byte", () => {
const f = fixture("sealed-anonymous-by-go.json");
assert.ok(f.vectors.length > 0);
for (const v of f.vectors as { plaintext: string; ephSecret: string; sealed: string }[]) {
assert.equal(sealAnonymousWith(v.plaintext, f.recipient.public, Buffer.from(v.ephSecret, "base64")), v.sealed);
assert.equal(sealAnonymousWith(Buffer.from(v.plaintext, "utf8"), f.recipient.public, Buffer.from(v.ephSecret, "base64")), v.sealed);
// The NaCl anonymous box the vault's intake opens: given the same one-time key, sealAnonymous makes what
// golang.org/x/crypto/nacl/box's SealAnonymous made, byte for byte; a fresh one differs and is as long.
const an = fixture("sealed-anonymous-by-go.json");
assert.ok(an.vectors.length > 0);
for (const v of an.vectors as { plaintext: string; ephSecret: string; sealed: string }[]) {
assert.equal(sealAnonymousWith(v.plaintext, an.recipient.public, Buffer.from(v.ephSecret, "base64")), v.sealed);
assert.equal(sealAnonymousWith(Buffer.from(v.plaintext, "utf8"), an.recipient.public, Buffer.from(v.ephSecret, "base64")), v.sealed);
}
const fresh = sealAnonymous("a token", f.recipient.public);
assert.notEqual(fresh, sealAnonymous("a token", f.recipient.public));
const fresh = sealAnonymous("a token", an.recipient.public);
assert.notEqual(fresh, sealAnonymous("a token", an.recipient.public));
assert.equal(Buffer.from(fresh, "base64").length, 32 + 16 + "a token".length);
assert.throws(() => sealAnonymous("x", "c2hvcnQ="), /not a raw X25519 public key/);
});