-
Notifications
You must be signed in to change notification settings - Fork 0
/
quic_header_test.go
68 lines (54 loc) · 1.66 KB
/
quic_header_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package clienthellod_test
import (
"bytes"
"testing"
. "github.com/refraction-networking/clienthellod"
)
// TODO: update test data to the latest and move test data to separate files (in binary format)
var (
quicHeaderTruth_Chrome125_PKN1 = &QUICHeader{
Version: []byte{0x00, 0x00, 0x00, 0x01},
DCIDLength: 8,
SCIDLength: 0,
PacketNumber: []byte{0x01},
HasToken: false,
}
quicHeaderTruth_Chrome125_PKN2 = &QUICHeader{
Version: []byte{0x00, 0x00, 0x00, 0x01},
DCIDLength: 8,
SCIDLength: 0,
PacketNumber: []byte{0x02},
HasToken: false,
}
quicHeaderTruth_Firefox126 = &QUICHeader{
Version: []byte{0x00, 0x00, 0x00, 0x01},
DCIDLength: 8,
SCIDLength: 3,
PacketNumber: []byte{0x00},
HasToken: false,
}
quicHeaderTruth_Firefox126_0_RTT = &QUICHeader{
Version: []byte{0x00, 0x00, 0x00, 0x01},
DCIDLength: 9,
SCIDLength: 3,
PacketNumber: []byte{0x00},
HasToken: true,
}
)
func testQUICHeaderEqualsTruth(t *testing.T, header, truth *QUICHeader) {
if !bytes.Equal(header.Version, truth.Version) {
t.Errorf("header.Version = %x, want %x", header.Version, truth.Version)
}
if header.DCIDLength != truth.DCIDLength {
t.Errorf("header.DCIDLength = %d, want %d", header.DCIDLength, truth.DCIDLength)
}
if header.SCIDLength != truth.SCIDLength {
t.Errorf("header.SCIDLength = %d, want %d", header.SCIDLength, truth.SCIDLength)
}
if !bytes.Equal(header.PacketNumber, truth.PacketNumber) {
t.Errorf("header.PacketNumber = %x, want %x", header.PacketNumber, truth.PacketNumber)
}
if header.HasToken != truth.HasToken {
t.Errorf("header.HasToken = %t, want %t", header.HasToken, truth.HasToken)
}
}