MCPcopy Index your code
hub / github.com/BlockRunAI/ClawRouter / startTestProxy

Function startTestProxy

test/integration/setup.ts:33–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 * Reuses an existing handle if already started.
32 */
33export async function startTestProxy(): Promise<ProxyHandle> {
34 if (proxyHandle) return proxyHandle;
35
36 const wallet = await resolveOrGenerateWalletKey();
37 const testPort = getTestPort();
38
39 proxyHandle = await startProxy({
40 wallet,
41 port: testPort,
42 skipBalanceCheck: true,
43 });
44
45 // Wait for /health to return 200
46 const deadline = Date.now() + HEALTH_TIMEOUT_MS;
47 while (Date.now() < deadline) {
48 try {
49 const res = await fetch(`${proxyHandle.baseUrl}/health`);
50 if (res.ok) return proxyHandle;
51 } catch {
52 // proxy not ready yet
53 }
54 await new Promise((r) => setTimeout(r, HEALTH_POLL_INTERVAL_MS));
55 }
56
57 throw new Error(`Test proxy did not become healthy within ${HEALTH_TIMEOUT_MS}ms`);
58}
59
60/**
61 * Stop the test proxy and clear the cached handle.

Callers 3

full-flow.test.tsFile · 0.85
lifecycle.test.tsFile · 0.85

Calls 3

getTestPortFunction · 0.85
startProxyFunction · 0.85

Tested by

no test coverage detected