Fix P17 to actually kill its mutant: check refCount, not connectionCount

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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-23 21:43:22 +02:00
commit 6f7b052a47

View file

@ -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) {