mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
test: dedupe channel/web cases and tighten gateway e2e waits
This commit is contained in:
@@ -29,9 +29,12 @@ type NodeListPayload = {
|
||||
nodes?: Array<{ nodeId?: string; connected?: boolean; paired?: boolean }>;
|
||||
};
|
||||
|
||||
const GATEWAY_START_TIMEOUT_MS = 45_000;
|
||||
const GATEWAY_START_TIMEOUT_MS = 20_000;
|
||||
const GATEWAY_STOP_TIMEOUT_MS = 1_500;
|
||||
const E2E_TIMEOUT_MS = 120_000;
|
||||
const GATEWAY_CONNECT_STATUS_TIMEOUT_MS = 2_000;
|
||||
const GATEWAY_NODE_STATUS_TIMEOUT_MS = 4_000;
|
||||
const GATEWAY_NODE_STATUS_POLL_MS = 20;
|
||||
|
||||
const getFreePort = async () => {
|
||||
const srv = net.createServer();
|
||||
@@ -80,7 +83,7 @@ const waitForPortOpen = async (
|
||||
// keep polling
|
||||
}
|
||||
|
||||
await sleep(25);
|
||||
await sleep(10);
|
||||
}
|
||||
const stdout = chunksOut.join("");
|
||||
const stderr = chunksErr.join("");
|
||||
@@ -265,7 +268,7 @@ const connectNode = async (
|
||||
|
||||
const connectStatusClient = async (
|
||||
inst: GatewayInstance,
|
||||
timeoutMs = 5_000,
|
||||
timeoutMs = GATEWAY_CONNECT_STATUS_TIMEOUT_MS,
|
||||
): Promise<GatewayClient> => {
|
||||
let settled = false;
|
||||
let timer: NodeJS.Timeout | null = null;
|
||||
@@ -312,9 +315,16 @@ const connectStatusClient = async (
|
||||
});
|
||||
};
|
||||
|
||||
const waitForNodeStatus = async (inst: GatewayInstance, nodeId: string, timeoutMs = 10_000) => {
|
||||
const waitForNodeStatus = async (
|
||||
inst: GatewayInstance,
|
||||
nodeId: string,
|
||||
timeoutMs = GATEWAY_NODE_STATUS_TIMEOUT_MS,
|
||||
) => {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
const client = await connectStatusClient(inst);
|
||||
const client = await connectStatusClient(
|
||||
inst,
|
||||
Math.min(GATEWAY_CONNECT_STATUS_TIMEOUT_MS, timeoutMs),
|
||||
);
|
||||
try {
|
||||
while (Date.now() < deadline) {
|
||||
const list = await client.request<NodeListPayload>("node.list", {});
|
||||
@@ -322,7 +332,7 @@ const waitForNodeStatus = async (inst: GatewayInstance, nodeId: string, timeoutM
|
||||
if (match?.connected && match?.paired) {
|
||||
return;
|
||||
}
|
||||
await sleep(50);
|
||||
await sleep(GATEWAY_NODE_STATUS_POLL_MS);
|
||||
}
|
||||
} finally {
|
||||
client.stop();
|
||||
|
||||
Reference in New Issue
Block a user