mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
ca7ee018b2
Give concurrent Ghidra and Hopper callers independent waits over one owned startup. Join final-caller cleanup, preserve failed cleanup owners, and derive readiness from the current startup result and live transport. Distinguish provider closure from caller cancellation and clean up interrupted final lineage observation. Reuse the Ghidra socket fixture, replace stale cancellation health assertions with cold and warm reuse controls, and cover public MCP peer cancellation. Validation: 315 affected tests, build, typecheck, lint, docs, and 25 relocated startup controls passed. Controlled child bridges only; real Ghidra JVM and Hopper GUI verification remains unperformed. Refs #3983, #4227, #4274.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { describe, expect, it, onTestFinished } from "vitest";
|
|
import { HopperClient } from "../../../../src/hopper/HopperClient.js";
|
|
|
|
import {
|
|
HopperFixtureLauncher as FixtureLauncher,
|
|
startHopperFixtureClient as startClient,
|
|
} from "./hopperClient.fixture.js";
|
|
|
|
describe("HopperClient restart", () => {
|
|
it("does not finish startup after an immediate close", async () => {
|
|
const client = new HopperClient({
|
|
launcher: new FixtureLauncher(),
|
|
startupTimeoutMs: 1_000,
|
|
});
|
|
onTestFinished(async () => {
|
|
await client.close();
|
|
});
|
|
|
|
const starting = client.start();
|
|
await client.close();
|
|
|
|
const result = await starting;
|
|
expect(result.ok).toBe(false);
|
|
if (!result.ok) expect(result.error._tag).toBe("HopperProtocolError");
|
|
});
|
|
|
|
it("starts a fresh session after close completes", async () => {
|
|
const client = await startClient();
|
|
await client.close();
|
|
|
|
await expect(client.start()).resolves.toEqual({
|
|
ok: true,
|
|
value: {
|
|
name: "REA Hopper bridge",
|
|
version: "1.0.0",
|
|
processId: expect.any(Number),
|
|
},
|
|
});
|
|
});
|
|
|
|
it("serializes a restart requested while close is in progress", async () => {
|
|
const client = await startClient();
|
|
const closing = client.close();
|
|
const restarting = client.start();
|
|
|
|
await closing;
|
|
await expect(restarting).resolves.toEqual({
|
|
ok: true,
|
|
value: {
|
|
name: "REA Hopper bridge",
|
|
version: "1.0.0",
|
|
processId: expect.any(Number),
|
|
},
|
|
});
|
|
await expect(client.callTool("echo", { value: "fresh" })).resolves.toEqual({
|
|
ok: true,
|
|
value: { value: "fresh" },
|
|
});
|
|
});
|
|
});
|