mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:14:58 +00:00
test: make gateway connectReq timeout configurable
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
|||||||
|
|
||||||
installGatewayTestHooks({ scope: "suite" });
|
installGatewayTestHooks({ scope: "suite" });
|
||||||
const NODE_CONNECT_TIMEOUT_MS = 3_000;
|
const NODE_CONNECT_TIMEOUT_MS = 3_000;
|
||||||
|
const CONNECT_REQ_TIMEOUT_MS = 2_000;
|
||||||
|
|
||||||
async function expectNoForwardedInvoke(hasInvoke: () => boolean): Promise<void> {
|
async function expectNoForwardedInvoke(hasInvoke: () => boolean): Promise<void> {
|
||||||
// Yield a couple of macrotasks so any accidental async forwarding would fire.
|
// Yield a couple of macrotasks so any accidental async forwarding would fire.
|
||||||
@@ -107,6 +108,7 @@ describe("node.invoke approval bypass", () => {
|
|||||||
token: "secret",
|
token: "secret",
|
||||||
scopes,
|
scopes,
|
||||||
...(resolveDevice ? { device: resolveDevice(await nonce) } : {}),
|
...(resolveDevice ? { device: resolveDevice(await nonce) } : {}),
|
||||||
|
timeoutMs: CONNECT_REQ_TIMEOUT_MS,
|
||||||
});
|
});
|
||||||
return { ws, res };
|
return { ws, res };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ export async function connectReq(
|
|||||||
nonce?: string;
|
nonce?: string;
|
||||||
} | null;
|
} | null;
|
||||||
skipConnectChallengeNonce?: boolean;
|
skipConnectChallengeNonce?: boolean;
|
||||||
|
timeoutMs?: number;
|
||||||
},
|
},
|
||||||
): Promise<ConnectResponse> {
|
): Promise<ConnectResponse> {
|
||||||
const { randomUUID } = await import("node:crypto");
|
const { randomUUID } = await import("node:crypto");
|
||||||
@@ -566,7 +567,7 @@ export async function connectReq(
|
|||||||
const rec = o as Record<string, unknown>;
|
const rec = o as Record<string, unknown>;
|
||||||
return rec.type === "res" && rec.id === id;
|
return rec.type === "res" && rec.id === id;
|
||||||
};
|
};
|
||||||
return await onceMessage<ConnectResponse>(ws, isResponseForId);
|
return await onceMessage<ConnectResponse>(ws, isResponseForId, opts?.timeoutMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function connectOk(ws: WebSocket, opts?: Parameters<typeof connectReq>[1]) {
|
export async function connectOk(ws: WebSocket, opts?: Parameters<typeof connectReq>[1]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user