...
1
2
3
4
5
6
7 package quic
8
9 import (
10 "testing"
11 )
12
13 func TestPathChallengeReceived(t *testing.T) {
14 for _, test := range []struct {
15 name string
16 padTo int
17 wantPadding int
18 }{{
19 name: "unexpanded",
20 padTo: 0,
21 wantPadding: 0,
22 }, {
23 name: "expanded",
24 padTo: 1200,
25 wantPadding: 1200,
26 }} {
27
28
29
30 tc := newTestConn(t, clientSide)
31 tc.handshake()
32 tc.ignoreFrame(frameTypeAck)
33 data := pathChallengeData{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}
34 tc.writeFrames(packetType1RTT, debugFramePathChallenge{
35 data: data,
36 }, debugFramePadding{
37 to: test.padTo,
38 })
39 tc.wantFrame("response to PATH_CHALLENGE",
40 packetType1RTT, debugFramePathResponse{
41 data: data,
42 })
43 if got, want := tc.lastDatagram.paddedSize, test.wantPadding; got != want {
44 t.Errorf("PATH_RESPONSE expanded to %v bytes, want %v", got, want)
45 }
46 tc.wantIdle("connection is idle")
47 }
48 }
49
50 func TestPathResponseMismatchReceived(t *testing.T) {
51
52
53
54
55 tc := newTestConn(t, clientSide)
56 tc.handshake()
57 tc.ignoreFrame(frameTypeAck)
58 tc.writeFrames(packetType1RTT, debugFramePathResponse{
59 data: pathChallengeData{},
60 })
61 tc.wantFrame("invalid PATH_RESPONSE causes the connection to close",
62 packetType1RTT, debugFrameConnectionCloseTransport{
63 code: errProtocolViolation,
64 },
65 )
66 }
67
View as plain text