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
+3 -6
View File
@@ -154,7 +154,9 @@ test("asked for again, a retired consumer is created again and announced re-enab
}
});
test("five passes are not enough: the same set must also hold for stableForMs", async () => {
test("five passes are not enough: the same set must also hold for stableForMs, ten minutes by default", async () => {
const { STABLE_FOR_MS } = await import("../dist/provider-loop/index.js");
assert.equal(STABLE_FOR_MS, 10 * 60_000);
const HOLD = 400;
const w = await world(["a", "b", "c"], { stableForMs: HOLD });
try {
@@ -170,11 +172,6 @@ test("five passes are not enough: the same set must also hold for stableForMs",
}
});
test("the default hold is ten minutes", async () => {
const { STABLE_FOR_MS } = await import("../dist/provider-loop/index.js");
assert.equal(STABLE_FOR_MS, 10 * 60_000);
});
test("an adapter without retire is MARK-ONLY: nothing changes in the backend, remove only on delete", async () => {
const w = await world(["a", "b", "c"], { retire: false, del: false });
try {
+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/);
});
+1 -3
View File
@@ -224,7 +224,7 @@ test("a failing consumer the mesh stopped asking for is said recovered when it i
}
});
test("an error is classed by its words", () => {
test("an error is classed by its words, and an adapter that classes its own errors is believed", async () => {
const table: Record<string, string> = {
'Keycloak token request failed: 401 {"error":"invalid_grant"}': CLASS_CREDENTIALS,
'FATAL: password authentication failed for user "postgres"': CLASS_CREDENTIALS,
@@ -235,9 +235,7 @@ test("an error is classed by its words", () => {
'extension "nope" is not available': CLASS_REFUSED,
};
for (const [text, want] of Object.entries(table)) assert.equal(classOf(text), want, text);
});
test("an adapter that classes its own errors is believed", async () => {
const w = await world({ classify: true });
try {
w.failing = new Error("anything");