From 6f7b052a47a346360885ac128a9a8d661f51d539 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 21:43:22 +0200 Subject: [PATCH] Fix P17 to actually kill its mutant: check refCount, not connectionCount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The synthetic connection P17 drives directly at acceptConnection() never reaches CONNECTED (it was never dialed anywhere), so it never joins `peers` either way — connectionCount alone couldn't tell "refused" apart from "attached but still handshaking". Manually restoring the disposed-check's removal and rerunning showed the original assertion passing regardless. retain() is synchronous and only the attach path calls it, so comparing CultMeshQuicNativeRuntime.refCount immediately around the acceptConnection() call is what actually distinguishes the two: confirmed by hand that the mutation now fails this test by assertion (2 !== 1) before restoring it. Co-Authored-By: Claude Sonnet 5 --- .../cultmesh-ts/test/realtime-quic-provider.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/cultmesh-ts/test/realtime-quic-provider.test.ts b/packages/cultmesh-ts/test/realtime-quic-provider.test.ts index 23d6a3f9..8a541641 100644 --- a/packages/cultmesh-ts/test/realtime-quic-provider.test.ts +++ b/packages/cultmesh-ts/test/realtime-quic-provider.test.ts @@ -979,9 +979,21 @@ test("P17: an accept arriving after dispose is refused, not attached as a peer", // depending on real listener-close timing to reproduce it. connectionId = runtime.connectionOpen("127.0.0.1", 1); provider.dispose(); + // This synthetic connection never reaches CONNECTED either way (it was + // never dialed anywhere), so `connectionCount` alone cannot distinguish + // "refused" from "attached but still handshaking". `retain()` is + // synchronous and only the attach path calls it: a stable `refCount` + // across the call proves no transport (and no runtime reference) was + // ever allocated for this connection. + const beforeRefCount = CultMeshQuicNativeRuntime.refCount; assert.doesNotThrow(() => (provider as unknown as { acceptConnection(id: bigint): void }).acceptConnection(connectionId!), ); + assert.equal( + CultMeshQuicNativeRuntime.refCount, + beforeRefCount, + "a post-dispose accept must never retain a runtime reference for a new transport", + ); assert.equal(provider.connectionCount, 0, "a post-dispose accept must never join peers"); } finally { if (connectionId !== undefined) {