MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / daemonOn

Function daemonOn

__tests__/daemon-proof.test.ts:178–191  ·  view source on GitHub ↗

A real Daemon's connection handling, on a socket of its own. Opens no index.

(socketPath: string)

Source from the content-addressed store, hash-verified

176describe('the daemon answers a challenge in its handshake (#3284)', () => {
177 /** A real Daemon's connection handling, on a socket of its own. Opens no index. */
178 async function daemonOn(socketPath: string): Promise<void> {
179 const daemon = new Daemon(tempDir('cg-proofroot-'), { idleTimeoutMs: 0 }) as unknown as {
180 socketPath: string;
181 handleConnection(socket: net.Socket): void;
182 };
183 daemon.socketPath = socketPath;
184 const accepted = new Set<net.Socket>();
185 const server = net.createServer((socket) => { accepted.add(socket); daemon.handleConnection(socket); });
186 await new Promise<void>((resolve) => server.listen(socketPath, resolve));
187 cleanups.push(() => new Promise<void>((resolve) => {
188 for (const socket of accepted) socket.destroy();
189 server.close(() => resolve());
190 }));
191 }
192
193 async function connect(socketPath: string): Promise<{ socket: net.Socket; next: () => Promise<string> }> {
194 const socket = net.createConnection(socketPath);

Callers 1

Calls 8

handleConnectionMethod · 0.80
listenMethod · 0.80
pushMethod · 0.80
tempDirFunction · 0.70
resolveFunction · 0.70
closeMethod · 0.65
addMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected