...
1
2
3
4
5
6
7 package quic
8
9 import (
10 "testing"
11 "time"
12 )
13
14 func TestAckElicitingAck(t *testing.T) {
15
16
17
18
19
20
21
22
23 tc := newTestConn(t, clientSide, permissiveTransportParameters)
24 tc.handshake()
25 const count = 100
26 for i := 0; i < count; i++ {
27 tc.advance(1 * time.Millisecond)
28 tc.writeFrames(packetType1RTT,
29 debugFramePing{},
30 )
31 got, _ := tc.readFrame()
32 switch got.(type) {
33 case debugFrameAck:
34 continue
35 case debugFramePing:
36 return
37 }
38 }
39 t.Errorf("after sending %v PINGs, got no ack-eliciting response", count)
40 }
41
42 func TestSendPacketNumberSize(t *testing.T) {
43 tc := newTestConn(t, clientSide, permissiveTransportParameters)
44 tc.handshake()
45
46 recvPing := func() *testPacket {
47 t.Helper()
48 tc.conn.ping(appDataSpace)
49 p := tc.readPacket()
50 if p == nil {
51 t.Fatalf("want packet containing PING, got none")
52 }
53 return p
54 }
55
56
57
58 for i := 0; i < 16; i++ {
59 recvPing()
60 }
61
62
63 maxAcked := recvPing().num
64 tc.writeAckForAll()
65
66
67
68
69 for want := maxAcked + 1; want < maxAcked+0x100; want++ {
70 p := recvPing()
71 if p.num != want {
72 t.Fatalf("received packet number %v, want %v", p.num, want)
73 }
74 gotPnumLen := int(p.header&0x03) + 1
75 wantPnumLen := 1
76 if p.num-maxAcked >= 0x80 {
77 wantPnumLen = 2
78 }
79 if gotPnumLen != wantPnumLen {
80 t.Fatalf("packet number 0x%x encoded with %v bytes, want %v (max acked = %v)", p.num, gotPnumLen, wantPnumLen, maxAcked)
81 }
82 }
83 }
84
View as plain text