Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/test/first-contact.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ function send(socket: dgram.Socket, payload: unknown, port: number): void {
socket.send(JSON.stringify(payload), port, "127.0.0.1");
}

/** The presence reports its own failed sends through onError (a host with no broadcast route fails every limited-broadcast send with EHOSTUNREACH), which says nothing about how it handled a received packet. */
function isOwnSendFailure(error: Error): boolean {
return "syscall" in error && error.syscall === "send";
}

async function settle(): Promise<void> {
return new Promise((resolve) => {
setTimeout(resolve, SETTLE_MS);
Expand Down Expand Up @@ -222,7 +227,7 @@ describe("FirstContact", () => {
await settle();

expect(discovered).toEqual([]);
expect(errors).toEqual([]);
expect(errors.filter((error) => !isOwnSendFailure(error))).toEqual([]);
presence.stop();
});

Expand Down
Loading