Some checks failed
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) Failing after 5m49s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 36s
Unscoped npm names are unclaimed and open to dependency confusion; cultcache-ts was already @gamecult/cultcache-ts. package.json names, intra-repo dependencies, package-lock, import specifiers (src, tests, samples, docs/start, first-call docs test), the workspace list in run-typescript-workspaces, the verify-eve module map and package READMEs now use the scoped names. Directory names, workspace paths in CI and release tag prefixes are unchanged. Historical cut docs and past CHANGELOG entries keep the old names. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
32 lines
1.9 KiB
TypeScript
32 lines
1.9 KiB
TypeScript
// The TypeScript reader in its own process, for content-https.test.ts. Argv: <endpoints json> <manifests dir> [only case].
|
|
// One stdout line per case: {case, ok:true, sha256} (hashed here by node:crypto, not by the reader) or {case, ok:false, code, status}.
|
|
import { createHash } from "node:crypto";
|
|
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { decodeManifest } from "@gamecult/cultnet-ts/content";
|
|
import { fetchVerifiedChunk, fetchVerifiedContent, CultMeshContentError } from "../../src/content.js";
|
|
|
|
const [endpointsJson, manifestsDir, only] = process.argv.slice(2) as [string, string, string | undefined];
|
|
const endpoints = JSON.parse(endpointsJson) as Record<"honest" | "tampered" | "corrupt", string>;
|
|
const manifest = (name: string) => decodeManifest(readFileSync(join(manifestsDir, `${name}.manifest`)));
|
|
const single = manifest("single");
|
|
|
|
const cases: Record<string, () => Promise<Uint8Array>> = {
|
|
"honest-multi": () => fetchVerifiedContent(endpoints.honest, manifest("multi")),
|
|
"honest-single": () => fetchVerifiedContent(endpoints.honest, single),
|
|
"honest-empty": () => fetchVerifiedContent(endpoints.honest, manifest("empty")),
|
|
"honest-escape": () => fetchVerifiedContent(endpoints.honest, manifest("escape")),
|
|
"honest-single-chunk": () => fetchVerifiedChunk(endpoints.honest, single.chunks[0]!.chunkHash!, single.chunks[0]!.sizeBytes),
|
|
"tampered-multi": () => fetchVerifiedContent(endpoints.tampered, manifest("multi")),
|
|
"corrupt-single": () => fetchVerifiedContent(endpoints.corrupt, single),
|
|
};
|
|
|
|
for (const [name, run] of Object.entries(cases)) {
|
|
if (only && only !== name) continue;
|
|
try {
|
|
console.log(JSON.stringify({ case: name, ok: true, sha256: createHash("sha256").update(await run()).digest("hex") }));
|
|
} catch (error) {
|
|
const e = error as CultMeshContentError;
|
|
console.log(JSON.stringify({ case: name, ok: false, code: e.code, status: e.status }));
|
|
}
|
|
}
|