test(quic): exercise the actual driver PTO path, not a simulation

The existing PtoCryptoRetransmitTest simulated the driver inline:
it set pendingPing=true and called requeueAllInflightCrypto by hand,
then asserted the next drain emitted CRYPTO. That checked the helpers
worked but never noticed when the DRIVER stopped calling
requeueAllInflightCrypto — which is exactly the regression that bit
us in commits c0d7b6031 (qlog merge) and again in cf2303a38
(lock-split refactor).

Extract the PTO-fired logic from QuicConnectionDriver.sendLoop into
a top-level internal helper handlePtoFired(conn). Driver and test now
both call the same function — if anyone unwires the requeue from
that helper or rewrites sendLoop to do volatile-only updates, the
test breaks.

Verified the regression-catch by stripping the requeue from
handlePtoFired and re-running the test: it fails with an
AssertionError on the PTO retransmit packet check, as expected.
Restored the helper, test green again.

https://claude.ai/code/session_01HcvfQq1ttPV9PkRoJb4nyT
This commit is contained in:
Claude
2026-05-07 02:50:31 +00:00
parent cf2303a38d
commit b579c766a4
2 changed files with 58 additions and 48 deletions
@@ -91,15 +91,16 @@ class PtoCryptoRetransmitTest {
"no PTO yet, no fresh data → second drain must be empty (got ${emptyDrain?.size} bytes)",
)
// Simulate the driver's PTO branch firing: requeue the
// unacknowledged CRYPTO and set the PING flag.
client.lock.lock()
try {
client.requeueAllInflightCrypto(EncryptionLevel.INITIAL)
client.pendingPing = true
} finally {
client.lock.unlock()
}
// Drive the EXACT helper QuicConnectionDriver.sendLoop
// calls when its PTO timer fires. Earlier versions of
// this test inlined the simulation (set pendingPing,
// call requeueAllInflightCrypto manually) — but that
// hid the regression where the driver itself stopped
// calling requeueAllInflightCrypto. Calling
// [handlePtoFired] keeps the test in lockstep with the
// production code path: if anyone unwires the requeue
// again, this test breaks.
handlePtoFired(client)
// Next drain must emit a fresh Initial packet carrying
// the ClientHello CRYPTO at the original offset.