76 lines
2.1 KiB
JavaScript
76 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { readFile } from "node:fs/promises";
|
|
import { fileURLToPath } from "node:url";
|
|
import { ARENA_SOURCE_HASHES } from "../src/arena/sourceHashes.ts";
|
|
|
|
const root = fileURLToPath(new URL("../", import.meta.url));
|
|
const sharedEnvironment = [
|
|
"src/arena/base.ts",
|
|
"src/arena/checksum.ts",
|
|
"src/arena/random.ts",
|
|
"src/arena/scenarios.ts",
|
|
"src/arena/types.ts",
|
|
];
|
|
|
|
const sourceSets = {
|
|
"drive-101-v1": {
|
|
environment: [...sharedEnvironment, "src/arena/drive101.ts"],
|
|
simulator: [
|
|
"src/transport/california.ts",
|
|
"src/transport/types.ts",
|
|
"src/transport/vehicleController.ts",
|
|
"src/transport/vehicleSim.ts",
|
|
],
|
|
},
|
|
"office-nav-v1": {
|
|
environment: [...sharedEnvironment, "src/arena/officeNav.ts"],
|
|
simulator: [
|
|
"src/interiors/plan.ts",
|
|
"src/interiors/types.ts",
|
|
"src/interiors/walker.ts",
|
|
"src/offices/frontier-valley.ts",
|
|
],
|
|
},
|
|
"crow-nav-v1": {
|
|
environment: [...sharedEnvironment, "src/arena/crowNav.ts"],
|
|
simulator: ["src/actors/controller.ts"],
|
|
},
|
|
"california-flight-v1": {
|
|
environment: [...sharedEnvironment, "src/arena/californiaFlight.ts"],
|
|
simulator: ["src/aircraft/controller.ts"],
|
|
},
|
|
};
|
|
|
|
async function digest(paths) {
|
|
const hash = createHash("sha256");
|
|
for (const relative of [...paths].sort()) {
|
|
hash.update(relative);
|
|
hash.update("\0");
|
|
hash.update(await readFile(new URL(`../${relative}`, import.meta.url)));
|
|
hash.update("\0");
|
|
}
|
|
return `sha256:${hash.digest("hex")}`;
|
|
}
|
|
|
|
let failed = false;
|
|
for (const [envId, sets] of Object.entries(sourceSets)) {
|
|
const actual = {
|
|
environment: await digest(sets.environment),
|
|
simulator: await digest(sets.simulator),
|
|
};
|
|
const expected = ARENA_SOURCE_HASHES[envId];
|
|
try {
|
|
assert.deepEqual(actual, expected);
|
|
console.log(`arena source hashes: ${envId} ok`);
|
|
} catch {
|
|
failed = true;
|
|
console.error(`arena source hashes: ${envId} mismatch`);
|
|
console.error(JSON.stringify(actual, null, 2));
|
|
}
|
|
}
|
|
|
|
if (failed) process.exitCode = 1;
|