Files
reverse-engineering-anything/tests/boundary/providers/kuna/kunaQueryWork.test.ts
T
morluto b4a2a79c55 test(lifecycle): move local gate copies, tests/process-global and tests/boundary phase gates onto the shared harness (#11412)
* test(lifecycle): replace eight local gate helper copies with the shared harness

* test(lifecycle): count an arrival announced in the turn its operation settles

* test(lifecycle): move tests/process-global phase gates onto the shared harness (#11414)

* test(lifecycle): move tests/process-global phase gates onto the shared harness

* test(lifecycle): move tests/boundary filesystem and process phase gates onto the shared harness (#11418)

* test(lifecycle): move tests/boundary provider phase gates onto the shared harness

* test(lifecycle): move tests/boundary/mcp phase gates onto the shared harness (#11433)

* test(lifecycle): give each phaseGate hold its own promise so unhandled held rejections stay visible

* test(lifecycle): move tests/boundary browser, pcap and CLI worker phase gates onto the shared harness (#11437)

* test(lifecycle): move tests/boundary browser, pcap and CLI worker phase gates onto the shared harness

* test(lifecycle): move fixture-owned and arrival-only provider gates onto the shared harness (#11441)

* test(lifecycle): move src/server and provider phase gates onto the shared harness (#11447)

* test(lifecycle): move the remaining src server, Kuna copy, Frida and Ghidra phase gates onto the shared harness (#11471)
2026-11-16 04:49:19 +08:00

78 lines
2.3 KiB
TypeScript

import { expect, it } from "vitest";
import { phaseArrival } from "../../../support/lifecycleHarness.js";
import { withVerifierCleanup } from "../../../../scripts/lib/verifier-cleanup.mjs";
import { KunaQueryWork } from "../../../../src/kuna/KunaQueryWork.js";
import { KunaRunSlots } from "../../../../src/kuna/KunaRunSlots.js";
import { KunaTargetCommands } from "../../../../src/kuna/KunaTargetCommands.js";
it("does not materialize values for a cancelled queued regex query", async () => {
const lifetime = new AbortController();
// This test exercises worker admission only; no native command reads this target.
const commands = new KunaTargetCommands(
{
path: "/unused/program",
sha256: "a".repeat(64),
kind: "executable",
format: "elf",
architecture: "x86_64",
availableArchitectures: ["x86_64"],
},
{ signal: lifetime.signal },
);
const work = new KunaQueryWork(commands, {
signal: lifetime.signal,
own: (promise) => promise,
runSlots: new KunaRunSlots(1),
});
const workerAdmission = phaseArrival();
const slow = work.match({
operation: "search_strings",
pattern: "^(a+)+$",
caseSensitive: true,
values: () => {
workerAdmission.arrive();
return [`${"a".repeat(40)}!`];
},
});
const cancelled = new AbortController();
let queued: ReturnType<typeof work.match> | undefined;
await withVerifierCleanup(async () => {
await workerAdmission.reached(slow, "regex worker admission");
let materialized = false;
queued = work.match({
operation: "search_procedures",
pattern: "value",
caseSensitive: true,
signal: cancelled.signal,
values: () => {
materialized = true;
return ["value"];
},
});
cancelled.abort();
expect(await queued).toMatchObject({
ok: false,
error: { _tag: "AnalysisCancelledError" },
});
expect(materialized).toBe(false);
lifetime.abort();
expect(await slow).toMatchObject({
ok: false,
error: { _tag: "AnalysisCancelledError" },
});
}, [
() => cancelled.abort(),
() => lifetime.abort(),
async () => {
await queued;
},
async () => {
await slow;
},
async () => {
expect(await commands.close()).toEqual({ ok: true, value: null });
},
]);
});