test(gateway): speed up contract and polling suites

This commit is contained in:
Peter Steinberger
2026-02-24 00:31:30 +00:00
parent 7d55277d72
commit f58c1ef34e
7 changed files with 103 additions and 146 deletions

View File

@@ -23,6 +23,7 @@ import { installGatewayTestHooks, onceMessage, rpcReq } from "./test-helpers.js"
import { installConnectedControlUiServerSuite } from "./test-with-server.js";
installGatewayTestHooks({ scope: "suite" });
const FAST_WAIT_OPTS = { timeout: 1_000, interval: 2 } as const;
let ws: WebSocket;
let port: number;
@@ -139,12 +140,9 @@ describe("gateway update.run", () => {
const res = await onceMessage(ws, (o) => o.type === "res" && o.id === id);
expect(res.ok).toBe(true);
await vi.waitFor(
() => {
expect(sigusr1.mock.calls.length).toBeGreaterThan(0);
},
{ timeout: 2_000, interval: 10 },
);
await vi.waitFor(() => {
expect(sigusr1.mock.calls.length).toBeGreaterThan(0);
}, FAST_WAIT_OPTS);
expect(sigusr1).toHaveBeenCalled();
const sentinelPath = path.join(os.homedir(), ".openclaw", "restart-sentinel.json");
@@ -193,16 +191,13 @@ describe("gateway node command allowlist", () => {
test("enforces command allowlists across node clients", async () => {
const waitForConnectedCount = async (count: number) => {
await expect
.poll(
async () => {
const listRes = await rpcReq<{
nodes?: Array<{ nodeId: string; connected?: boolean }>;
}>(ws, "node.list", {});
const nodes = listRes.payload?.nodes ?? [];
return nodes.filter((node) => node.connected).length;
},
{ timeout: 2_000 },
)
.poll(async () => {
const listRes = await rpcReq<{
nodes?: Array<{ nodeId: string; connected?: boolean }>;
}>(ws, "node.list", {});
const nodes = listRes.payload?.nodes ?? [];
return nodes.filter((node) => node.connected).length;
}, FAST_WAIT_OPTS)
.toBe(count);
};