golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/quic/ping_test.go (about)

     1  // Copyright 2023 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 "testing"
    10  
    11  func TestPing(t *testing.T) {
    12  	tc := newTestConn(t, clientSide)
    13  	tc.handshake()
    14  
    15  	tc.conn.ping(appDataSpace)
    16  	tc.wantFrame("connection should send a PING frame",
    17  		packetType1RTT, debugFramePing{})
    18  
    19  	tc.advanceToTimer()
    20  	tc.wantFrame("on PTO, connection should send another PING frame",
    21  		packetType1RTT, debugFramePing{})
    22  
    23  	tc.wantIdle("after sending PTO probe, no additional frames to send")
    24  }
    25  
    26  func TestAck(t *testing.T) {
    27  	tc := newTestConn(t, serverSide)
    28  	tc.handshake()
    29  
    30  	// Send two packets, to trigger an immediate ACK.
    31  	tc.writeFrames(packetType1RTT,
    32  		debugFramePing{},
    33  	)
    34  	tc.writeFrames(packetType1RTT,
    35  		debugFramePing{},
    36  	)
    37  	tc.wantFrame("connection should respond to ack-eliciting packet with an ACK frame",
    38  		packetType1RTT,
    39  		debugFrameAck{
    40  			ranges: []i64range[packetNumber]{{0, 4}},
    41  		},
    42  	)
    43  }