MCPcopy Create free account
hub / github.com/deepclause/agentvm / test

Function test

test-tcp-abort.js:3–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1const { AgentVM } = require("./src/index.js");
2
3async function test() {
4 const vm = new AgentVM({ network: true, debug: true });
5 await vm.start();
6 console.log("VM READY");
7
8 // Test DNS first
9 console.log("\n=== TEST 1: DNS before download ===");
10 let r = await vm.exec("nslookup google.com 2>&1 | head -3");
11 console.log(r.stdout);
12
13 // Start a download and abort it by running a timeout curl
14 console.log("\n=== TEST 2: Short download (should complete) ===");
15 r = await vm.exec("curl -s -o /dev/null -w '%{http_code}' http://google.com");
16 console.log("HTTP status:", r.stdout);
17
18 // Start a larger download with a timeout that will abort it
19 console.log("\n=== TEST 3: Download with timeout (will abort) ===");
20 r = await vm.exec("timeout 3 curl -o /dev/null http://ipv4.download.thinkbroadband.com/10MB.zip 2>&1 || echo 'Download aborted as expected'");
21 console.log(r.stdout);
22
23 // Test DNS after abort
24 console.log("\n=== TEST 4: DNS after aborted download ===");
25 r = await vm.exec("nslookup google.com 2>&1 | head -3");
26 console.log(r.stdout);
27
28 // Try another download
29 console.log("\n=== TEST 5: HTTP after aborted download ===");
30 r = await vm.exec("curl -s -o /dev/null -w '%{http_code}' http://google.com");
31 console.log("HTTP status:", r.stdout);
32
33 console.log("\n=== ALL TESTS COMPLETE ===");
34 process.exit(0);
35}
36
37test().catch(e => {
38 console.error("ERROR:", e);

Callers 1

test-tcp-abort.jsFile · 0.70

Calls 2

startMethod · 0.95
execMethod · 0.95

Tested by

no test coverage detected