Reuse verified immutable plans and streamline cooperative hashing
Continue final hosted development reliability qualification.
This commit is contained in:
+13
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user