@@ -4486,8 +4486,9 @@ func TestSNIAccumulatorPartialDataCannotExtractSNI(t *testing.T) {
44864486// sole CRYPTO frame sits at the given offset with the provided handshake
44874487// data. This lets tests simulate quic-go fragmenting a ClientHello across
44884488// several Initial packets. dcid must be identical across packets that share
4489- // the same connection so decryption uses the same keys.
4490- func buildQUICInitialWithCrypto (t * testing.T , dcid []byte , offset uint64 , data []byte , version uint32 ) []byte {
4489+ // the same connection so decryption uses the same keys. Always builds a
4490+ // QUIC v1 packet since all current callers only exercise v1 fragmentation.
4491+ func buildQUICInitialWithCrypto (t * testing.T , dcid []byte , offset uint64 , data []byte ) []byte {
44914492 t .Helper ()
44924493
44934494 var crypto []byte
@@ -4496,7 +4497,7 @@ func buildQUICInitialWithCrypto(t *testing.T, dcid []byte, offset uint64, data [
44964497 crypto = append (crypto , encodeQUICVarint (uint64 (len (data )))... )
44974498 crypto = append (crypto , data ... )
44984499
4499- return buildQUICInitialFromPlaintext (t , dcid , crypto , version )
4500+ return buildQUICInitialFromPlaintext (t , dcid , crypto , quicVersionV1 )
45004501}
45014502
45024503// TestExtractQUICCryptoDataReturnsOffsetAndData verifies that
@@ -4507,7 +4508,7 @@ func TestExtractQUICCryptoDataReturnsOffsetAndData(t *testing.T) {
45074508 dcid := []byte {0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 }
45084509 payload := []byte ("first-crypto-chunk" )
45094510
4510- packet := buildQUICInitialWithCrypto (t , dcid , 0 , payload , quicVersionV1 )
4511+ packet := buildQUICInitialWithCrypto (t , dcid , 0 , payload )
45114512 got , offset := ExtractQUICCryptoData (packet )
45124513 if offset != 0 {
45134514 t .Errorf ("offset = %d, want 0" , offset )
@@ -4517,7 +4518,7 @@ func TestExtractQUICCryptoDataReturnsOffsetAndData(t *testing.T) {
45174518 }
45184519
45194520 // Non-zero offset packet.
4520- packet2 := buildQUICInitialWithCrypto (t , dcid , 42 , []byte ("later-chunk" ), quicVersionV1 )
4521+ packet2 := buildQUICInitialWithCrypto (t , dcid , 42 , []byte ("later-chunk" ))
45214522 got2 , offset2 := ExtractQUICCryptoData (packet2 )
45224523 if offset2 != 42 {
45234524 t .Errorf ("offset = %d, want 42" , offset2 )
@@ -4675,8 +4676,8 @@ func TestQUICSNIAccumulationAcrossTwoPackets(t *testing.T) {
46754676 part2 := hs [splitAt :]
46764677
46774678 dcid := []byte {0x11 , 0x22 , 0x33 , 0x44 , 0x55 , 0x66 , 0x77 , 0x88 }
4678- packet1 := buildQUICInitialWithCrypto (t , dcid , 0 , part1 , quicVersionV1 )
4679- packet2 := buildQUICInitialWithCrypto (t , dcid , uint64 (splitAt ), part2 , quicVersionV1 )
4679+ packet1 := buildQUICInitialWithCrypto (t , dcid , 0 , part1 )
4680+ packet2 := buildQUICInitialWithCrypto (t , dcid , uint64 (splitAt ), part2 )
46804681
46814682 // Sanity: the first packet alone should NOT produce an SNI via the
46824683 // single-packet path.
@@ -4721,7 +4722,7 @@ func TestQUICSNIAccumulationFallsBackAfterPacketBudget(t *testing.T) {
47214722 destIP := net .ParseIP ("10.77.0.2" )
47224723
47234724 for i := 0 ; i < maxSNIAccumulatorPackets ; i ++ {
4724- packet := buildQUICInitialWithCrypto (t , dcid , uint64 (1000 + i * 16 ), []byte ("gap-bytes-only" ), quicVersionV1 )
4725+ packet := buildQUICInitialWithCrypto (t , dcid , uint64 (1000 + i * 16 ), []byte ("gap-bytes-only" ))
47254726 if _ , err := env .udpConn .WriteTo (wrapInSOCKS5UDP (packet , destIP ), env .bindAddr ); err != nil {
47264727 t .Fatalf ("send packet %d: %v" , i , err )
47274728 }
0 commit comments