Keep cold Candidate verification cooperative with controller renewals
This commit is contained in:
@@ -3,6 +3,7 @@ import { test } from "node:test";
|
||||
import { capabilityId as id, valueType, validateWorkspaceRevision } from "../src/capability-model/index.js";
|
||||
import {
|
||||
contentDigest,
|
||||
contentDigestAsync,
|
||||
planEvolution,
|
||||
reviewSemanticMajors,
|
||||
runtimeContracts,
|
||||
@@ -51,6 +52,27 @@ test("hashing is canonical and rejects values outside the persisted JSON contrac
|
||||
assert.throws(() => contentDigest(new Date()));
|
||||
});
|
||||
|
||||
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] } }];
|
||||
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 large = Array.from({ length: 50000 }, (_, index) => ({ z: "definition".repeat(8), a: index }));
|
||||
const expected = contentDigest(large);
|
||||
let serviced = false;
|
||||
const timer = setTimeout(() => {
|
||||
serviced = true;
|
||||
}, 0);
|
||||
try {
|
||||
assert.equal(await contentDigestAsync(large), expected);
|
||||
assert.equal(serviced, true, "large verification must let host renewals and RPCs run");
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
});
|
||||
|
||||
test("a workspace root change and display names do not restart package runtimes", () => {
|
||||
const before = makeValidCapabilityWorkspace();
|
||||
const after = structuredClone(before);
|
||||
|
||||
Reference in New Issue
Block a user