MCPcopy Create free account
hub / github.com/cloudflare/computer / startShellHarness

Function startShellHarness

packages/rpc/tests/shell-and-composite.test.ts:108–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106}
107
108async function startShellHarness(): Promise<ShellHarness> {
109 const runner = makeFakeRunner();
110 const rpc = createShellServer(runner);
111 const http: Server = createServer();
112 const wss = new WebSocketServer({ server: http, path: "/rpc" });
113 wss.on("connection", (ws) => {
114 acceptWebSocketSession(ws, rpc);
115 });
116 await new Promise<void>((res) => http.listen(0, "127.0.0.1", res));
117 const { port } = http.address() as AddressInfo;
118 return {
119 url: `ws://127.0.0.1:${port}/rpc`,
120 runner,
121 close: async () => {
122 await new Promise<void>((res) => wss.close(() => res()));
123 await new Promise<void>((res) => http.close(() => res()));
124 },
125 };
126}
127
128async function drainExec(stream: ReadableStream<ExecEvent>): Promise<ExecEvent[]> {
129 const events: ExecEvent[] = [];

Callers 1

Calls 6

makeFakeRunnerFunction · 0.85
createShellServerFunction · 0.85
acceptWebSocketSessionFunction · 0.85
listenMethod · 0.65
addressMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected