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

Function runLiveSuite

test/test-e2e.ts:816–1016  ·  view source on GitHub ↗
(startProxy: StartProxy)

Source from the content-addressed store, hash-verified

814}
815
816async function runLiveSuite(startProxy: StartProxy): Promise<boolean> {
817 if (!RUN_PAID_TESTS || !LIVE_WALLET_KEY) {
818 console.log("\n=== Live paid e2e ===\n");
819 skipTest("Live upstream smoke tests", "set funded BLOCKRUN_WALLET_KEY to enable");
820 return true;
821 }
822
823 console.log("\n=== Live paid e2e ===\n");
824 console.log(`Mode: LIVE, wallet=${privateKeyToAccount(LIVE_WALLET_KEY).address}`);
825
826 let proxy: ProxyHandle | undefined;
827 let allPassed = true;
828
829 try {
830 proxy = await startProxy({
831 wallet: LIVE_WALLET_KEY,
832 port: 0,
833 requestTimeoutMs: REQUEST_TIMEOUT_MS,
834 onReady: (port) => console.log(`Proxy ready on port ${port}`),
835 onError: (err) => console.error(`Proxy error: ${err.message}`),
836 onRouted: (d) =>
837 console.log(
838 ` [routed] ${d.model} (${d.tier}, ${d.method}, confidence=${d.confidence.toFixed(2)}, cost=$${d.costEstimate.toFixed(4)}, saved=${(d.savings * 100).toFixed(0)}%)`,
839 ),
840 onPayment: (info) =>
841 console.log(` [payment] ${info.model} ${info.amount} on ${info.network}`),
842 });
843
844 allPassed =
845 (await runTest("Live balance check", async () => {
846 if (!proxy!.balanceMonitor) throw new Error("Balance monitor not available");
847 const balance = await proxy!.balanceMonitor.checkBalance();
848 if (!balance || typeof balance.balanceUSD !== "string") {
849 throw new Error("Balance check returned invalid response");
850 }
851 if (balance.isEmpty) throw new Error("Wallet is empty - please fund it");
852 return `(balance=${balance.balanceUSD})`;
853 })) && allPassed;
854
855 allPassed =
856 (await runTest("Live non-streaming request (deepseek/deepseek-chat)", async () => {
857 const res = await postJson(
858 proxy!,
859 "/v1/chat/completions",
860 {
861 model: "deepseek/deepseek-chat",
862 messages: [{ role: "user", content: "What is 2+2? Reply with just the number." }],
863 max_tokens: 10,
864 stream: false,
865 },
866 60_000,
867 );
868 const content = await expectChatContent(res);
869 if (!content.includes("4")) throw new Error(`Expected "4" in response, got: ${content}`);
870 return `(response="${content.trim()}")`;
871 })) && allPassed;
872
873 allPassed =

Callers 1

mainFunction · 0.85

Calls 11

skipTestFunction · 0.85
startProxyFunction · 0.85
expectChatContentFunction · 0.85
readResponseBodyFunction · 0.85
collectSseFunction · 0.85
asRecordFunction · 0.85
fetchWithTimeoutFunction · 0.85
closeMethod · 0.80
runTestFunction · 0.70
postJsonFunction · 0.70
checkBalanceMethod · 0.45

Tested by

no test coverage detected