Files
amethyst/quic
Claude cd68502355 test(quic): adversarial + parametrized + negative-path tests from review
Builds the test categories the audit identified as missing. Patterns informed
by surveys of Cloudflare quiche (the `Pipe` style + flow-control assertions),
kwik (server-side hostile-peer matrix), and quic-interop-runner (scenario
checklist).

FrameFuzzerTest — 8 tests
  - 2000 random byte sequences fed through decodeFrames; the contract is
    "succeed or throw QuicCodecException, never crash." Catches the C5 class
    (oversized varints) plus general DoS resilience.
  - Crafted hostile vectors: STREAM with length=2^62-1, CRYPTO 1 GiB,
    ACK with 1B range count, NCID with cidLen=255, CONNECTION_CLOSE with
    1 GiB reason, DATAGRAM 1 GiB, valid frame followed by unknown type.

AckTrackerCoalescedTest — 3 tests
  - Two coalesced packets in one datagram both end up in the ACK frame.
    Direct regression test for the C2 bug where the parser fed
    `state.pnSpace.largestReceived` instead of the actual decrypted PN.
  - Gapped PNs produce two ranges with the correct gap encoding (RFC 9000
    §19.3.1 `previous_smallest - current_largest - 2`).
  - Out-of-order arrival of contiguous PNs still merges into one range.

FlowControlEnforcementTest — 6 tests
  - SendBuffer respects maxBytes (the writer's `sendCredit - sentOffset`
    enforcement point).
  - maxBytes=0 with pending data returns null (sender stalls cleanly).
  - Multi-take across chunked-queue boundaries preserves byte order
    (regression coverage for the new O(1) chunked enqueue replacing the
    old O(N²) copyOf path).
  - FIN handling: piggyback on final data chunk vs. zero-length post-data.

TlsSecurityPropertiesTest — 5 tests
  - ServerHello with non-empty session_id_echo rejected (RFC 8446 §4.1.3
    downgrade signal).
  - Pre-TLS-1.3 legacy_version rejected.
  - Server picking unsupported group (secp256r1) rejected — we advertise
    X25519 only.
  - Missing supported_versions / missing key_share extensions rejected.

TlsRoundTripTest — multi-cipher parametrization
  - InProcessTlsServer takes a `preferredCiphers` list.
  - New test forces ChaCha20-Poly1305-SHA256 selection and asserts the
    full handshake completes with that suite, with the
    onApplicationKeysReady callback reporting the actual negotiated
    cipher (not the previously-hardcoded AES). This is direct regression
    coverage for the C1 bug.

Total: 22 new tests + multi-cipher parametrization. All :quic:jvmTest +
:nestsClient:jvmTest pass.

Notable gap acknowledged from surveys: an in-memory `Pipe`-style
client+server harness (quiche pattern). Requires a server-side
QuicConnection implementation, which is ~1 day of work; deferred until we
have a concrete need beyond what the in-process TLS server already covers.

https://claude.ai/code/session_01EC1tfXfap8k8GyKvrxkxZx
2026-04-25 22:19:15 +00:00
..