Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
Libby
8090eeb839 cultmesh-browser test: make the unallocatable-size refusal certain on hosts that overcommit
All checks were successful
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 20m40s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 42s
The 64 TiB manifest allocated lazily on the forge runner, so the reader went on to fetch and the test saw a network error. The test now makes Uint8Array refuse sizes past 2^40 for its duration.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 06:26:21 +00:00

View file

@ -567,8 +567,14 @@ test("a size the runtime cannot allocate is too-large in both exports, not a Ran
const count = 2 ** 15;
const huge = { ...manifest, sizeBytes: count * int32Max, chunks: Array.from({ length: count }, (_, index) => ({ ...manifest.chunks[0]!, offset: index * int32Max, sizeBytes: int32Max })) };
const server = double(() => { throw new Error("no request expected"); });
await assert.rejects(fetchVerifiedContent(ENDPOINT, huge, { fetch: server.fetch, maxBytes: size }), codeOf("too-large"));
await assert.rejects(fetchVerifiedChunk(ENDPOINT, manifest.chunks[0]!.chunkHash!, size, { fetch: server.fetch, maxBytes: size }), codeOf("too-large"));
// a host with overcommit hands out 64 TiB lazily, so the refusal is made certain: the runtime cannot allocate it
const native = globalThis.Uint8Array;
const refusing = new Proxy(native, { construct: (target, args, receiver) => { if (typeof args[0] === "number" && args[0] > 2 ** 40) throw new RangeError("Array buffer allocation failed"); return Reflect.construct(target, args, receiver); } });
globalThis.Uint8Array = refusing;
try {
await assert.rejects(fetchVerifiedContent(ENDPOINT, huge, { fetch: server.fetch, maxBytes: size }), codeOf("too-large"));
await assert.rejects(fetchVerifiedChunk(ENDPOINT, manifest.chunks[0]!.chunkHash!, size, { fetch: server.fetch, maxBytes: size }), codeOf("too-large"));
} finally { globalThis.Uint8Array = native; }
assert.equal(server.calls.length, 0);
});