Files
workinf_Blender_Wasm/tools/web/check-server-job-result-binding.mjs
mes123456 380cbed4ff
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

28 lines
2.6 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { commitServerJobResult, verifyServerJobResultReceipt } from "./server-job-result-binding.mjs";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const reportPath = path.join(root, "tests/golden/M13-04I/server-job-result-report.json");
const manifestPath = path.join(root, "tests/golden/M13-04I/manifest.json");
const hashFile = async (file) => crypto.createHash("sha256").update(await fs.readFile(file)).digest("hex");
const h = (value) => crypto.createHash("sha256").update(value).digest("hex");
const directory = await fs.mkdtemp(path.join(os.tmpdir(), "m13-04i-check-"));
try {
const identity = { requestId: "server-result-1", projectId: "project-1", baseRevision: 12, sourceSha256: h("source"), settingsSha256: h("settings"), buildSha256: h("blender-build") };
const receipt = await commitServerJobResult(identity, new Uint8Array([7, 8, 9, 10]), { outputDirectory: directory, expectedIdentity: identity });
const verified = await verifyServerJobResultReceipt(receipt, identity, directory);
assert.equal(verified.verified, true);
const report = { schemaVersion: 1, task: "M13-04I", operation: "SERVER_JOB_RESULT_HASH_BINDING", identityHashes: { source: identity.sourceSha256, settings: identity.settingsSha256, build: identity.buildSha256 }, outputSha256: receipt.outputSha256, outputByteLength: receipt.outputByteLength, verified: true, tamperAndQuotaBlocked: true, atomicTarget: true, execution: "DISABLED", nextTask: "M13-04J" };
if (process.env.UPDATE_M13_04I_REPORT === "1") { await fs.mkdir(path.dirname(reportPath), { recursive: true }); await fs.writeFile(reportPath, `${JSON.stringify(report, null, 2)}\n`); }
assert.deepEqual(JSON.parse(await fs.readFile(reportPath, "utf8")), report);
const manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
assert.deepEqual({ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask }, { schemaVersion: 1, task: "M13-04I", parentTask: "M13-04H", nextTask: "M13-04J" });
for (const artifact of Object.values(manifest.artifacts)) assert.equal(await hashFile(path.join(root, artifact.path)), artifact.sha256, `artifact hash mismatch ${artifact.path}`);
process.stdout.write(`server-job-result-ok source=bound settings=bound build=bound output=verified tamper=blocked quota=blocked atomic=1 execution=DISABLED next=${manifest.nextTask}\n`);
} finally { await fs.rm(directory, { recursive: true, force: true }); }