41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { callProbeComputers, formatFailure, startBridge, startCraftos, waitForComputers } from "./harness.js";
|
|
|
|
test("probe-computers aggregates two real TrapOS mcp-computer programs", async () => {
|
|
const bridge = await startBridge();
|
|
const craftosA = startCraftos("/programs/mcp-computer.lua", {
|
|
computerId: 101,
|
|
computerLabel: "trap-A",
|
|
mountRepo: true,
|
|
shellArgs: [bridge.linkUrl],
|
|
timeoutMs: 15_000,
|
|
});
|
|
const craftosB = startCraftos("/programs/mcp-computer.lua", {
|
|
computerId: 202,
|
|
computerLabel: "trap-B",
|
|
mountRepo: true,
|
|
shellArgs: [bridge.linkUrl],
|
|
timeoutMs: 15_000,
|
|
});
|
|
|
|
try {
|
|
await waitForComputers(bridge.registry, 2, 12_000);
|
|
const lines = (await callProbeComputers(bridge.mcpUrl)).split("\n");
|
|
assert.equal(lines.length, 2);
|
|
assert(lines.some((line) => /^pong from \d+ \(Label: trap-A\)$/.test(line)));
|
|
assert(lines.some((line) => /^pong from \d+ \(Label: trap-B\)$/.test(line)));
|
|
} catch (error) {
|
|
craftosA.abort();
|
|
craftosB.abort();
|
|
const [resultA, resultB] = await Promise.all([craftosA.done, craftosB.done]);
|
|
const output = ["--- craftos A ---", resultA.output, "--- craftos B ---", resultB.output].join("\n");
|
|
throw new Error(formatFailure(error instanceof Error ? error.message : String(error), output), { cause: error });
|
|
} finally {
|
|
craftosA.abort();
|
|
craftosB.abort();
|
|
await Promise.all([craftosA.done, craftosB.done]);
|
|
await bridge.close();
|
|
}
|
|
});
|