...

Source file src/golang.org/x/net/quic/conn_recv_test.go

Documentation: golang.org/x/net/quic

     1  // Copyright 2024 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build go1.21
     6  
     7  package quic
     8  
     9  import (
    10  	"crypto/tls"
    11  	"testing"
    12  )
    13  
    14  func TestConnReceiveAckForUnsentPacket(t *testing.T) {
    15  	tc := newTestConn(t, serverSide, permissiveTransportParameters)
    16  	tc.handshake()
    17  	tc.writeFrames(packetType1RTT,
    18  		debugFrameAck{
    19  			ackDelay: 0,
    20  			ranges:   []i64range[packetNumber]{{0, 10}},
    21  		})
    22  	tc.wantFrame("ACK for unsent packet causes CONNECTION_CLOSE",
    23  		packetType1RTT, debugFrameConnectionCloseTransport{
    24  			code: errProtocolViolation,
    25  		})
    26  }
    27  
    28  // Issue #70703: If a packet contains both a CRYPTO frame which causes us to
    29  // drop state for a number space, and also contains a valid ACK frame for that space,
    30  // we shouldn't complain about the ACK.
    31  func TestConnReceiveAckForDroppedSpace(t *testing.T) {
    32  	tc := newTestConn(t, serverSide, permissiveTransportParameters)
    33  	tc.ignoreFrame(frameTypeAck)
    34  	tc.ignoreFrame(frameTypeNewConnectionID)
    35  
    36  	tc.writeFrames(packetTypeInitial,
    37  		debugFrameCrypto{
    38  			data: tc.cryptoDataIn[tls.QUICEncryptionLevelInitial],
    39  		})
    40  	tc.wantFrame("send Initial crypto",
    41  		packetTypeInitial, debugFrameCrypto{
    42  			data: tc.cryptoDataOut[tls.QUICEncryptionLevelInitial],
    43  		})
    44  	tc.wantFrame("send Handshake crypto",
    45  		packetTypeHandshake, debugFrameCrypto{
    46  			data: tc.cryptoDataOut[tls.QUICEncryptionLevelHandshake],
    47  		})
    48  
    49  	tc.writeFrames(packetTypeHandshake,
    50  		debugFrameCrypto{
    51  			data: tc.cryptoDataIn[tls.QUICEncryptionLevelHandshake],
    52  		},
    53  		debugFrameAck{
    54  			ackDelay: 0,
    55  			ranges:   []i64range[packetNumber]{{0, tc.lastPacket.num + 1}},
    56  		})
    57  	tc.wantFrame("handshake finishes",
    58  		packetType1RTT, debugFrameHandshakeDone{})
    59  	tc.wantIdle("connection is idle")
    60  }
    61  

View as plain text