Reuse verified immutable plans and streamline cooperative hashing

Continue final hosted development reliability qualification.
This commit is contained in:
Timothy J. Aveni
2026-10-12 20:16:56 -07:00
parent 47b316180d
commit 62a09605cf
15 changed files with 214 additions and 57 deletions
+13 -1
View File
@@ -55,10 +55,22 @@ test("hashing is canonical and rejects values outside the persisted JSON contrac
test("cooperative hashing preserves canonical identities and services the event loop", async () => {
const sparse = [1, 2, 3];
delete sparse[1];
const values = [null, false, -0, "中\\n\ud800", sparse, { z: 1, a: { omitted: undefined, b: [false, 1e100] } }];
const values: unknown[] = [
null,
false,
-0,
"中\\n\ud800",
sparse,
{ z: 1, a: { omitted: undefined, b: [false, 1e100] } },
];
const shared = { text: "中😀".repeat(22000) };
values.push({ first: shared, second: shared });
for (const value of values) assert.equal(await contentDigestAsync(value), contentDigest(value));
for (const value of [undefined, NaN, Infinity, new Date(), [undefined]])
await assert.rejects(contentDigestAsync(value));
const cyclic: { next?: unknown } = {};
cyclic.next = cyclic;
await assert.rejects(contentDigestAsync(cyclic), /cyclic JSON/);
const large = Array.from({ length: 50000 }, (_, index) => ({ z: "definition".repeat(8), a: index }));
const expected = contentDigest(large);
let serviced = false;