From 394bc9c4658610cfd66cb2d2ed90e36369cf4a86 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 1 May 2026 13:27:56 +0100 Subject: [PATCH] refactor: trim gateway helper state exports --- src/gateway/test-helpers.runtime-state.ts | 12 ++++++------ src/gateway/test-helpers.server.ts | 15 --------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/gateway/test-helpers.runtime-state.ts b/src/gateway/test-helpers.runtime-state.ts index 318ebde048a..9fcd44f4e84 100644 --- a/src/gateway/test-helpers.runtime-state.ts +++ b/src/gateway/test-helpers.runtime-state.ts @@ -17,16 +17,16 @@ export type GetReplyFromConfigFn = ( opts?: GetReplyOptions, configOverride?: OpenClawConfig, ) => Promise; -export type CronIsolatedRunFn = (...args: unknown[]) => Promise; -export type AgentCommandFn = (...args: unknown[]) => Promise; -export type SendWhatsAppFn = (...args: unknown[]) => Promise<{ messageId: string; toJid: string }>; +type CronIsolatedRunFn = (...args: unknown[]) => Promise; +type AgentCommandFn = (...args: unknown[]) => Promise; +type SendWhatsAppFn = (...args: unknown[]) => Promise<{ messageId: string; toJid: string }>; export type RunBtwSideQuestionFn = (...args: unknown[]) => Promise; -export type DispatchInboundMessageFn = (...args: unknown[]) => Promise; -export type CompactEmbeddedPiSessionFn = (...args: unknown[]) => Promise; +type DispatchInboundMessageFn = (...args: unknown[]) => Promise; +type CompactEmbeddedPiSessionFn = (...args: unknown[]) => Promise; const GATEWAY_TEST_CONFIG_ROOT_KEY = Symbol.for("openclaw.gatewayTestHelpers.configRoot"); -export type GatewayTestHoistedState = { +type GatewayTestHoistedState = { testTailnetIPv4: { value: string | undefined }; piSdkMock: { enabled: boolean; diff --git a/src/gateway/test-helpers.server.ts b/src/gateway/test-helpers.server.ts index 0f8ac192aa7..4c032eda556 100644 --- a/src/gateway/test-helpers.server.ts +++ b/src/gateway/test-helpers.server.ts @@ -1,5 +1,4 @@ import fs from "node:fs/promises"; -import { type AddressInfo, createServer } from "node:net"; import os from "node:os"; import path from "node:path"; import { afterAll, afterEach, beforeAll, beforeEach, expect, vi } from "vitest"; @@ -492,20 +491,6 @@ export async function getFreePort(): Promise { return await getDeterministicFreePortBlock({ offsets: [0, 1, 2, 3, 4] }); } -export async function occupyPort(): Promise<{ - server: ReturnType; - port: number; -}> { - return await new Promise((resolve, reject) => { - const server = createServer(); - server.once("error", reject); - server.listen(0, "127.0.0.1", () => { - const port = (server.address() as AddressInfo).port; - resolve({ server, port }); - }); - }); -} - type GatewayTestMessage = { type?: string; id?: string;