forked from quic-go/quic-go
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconnection_logging_test.go
72 lines (64 loc) · 1.61 KB
/
connection_logging_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
69
70
71
72
package quic
import (
"testing"
"github.com/quic-go/quic-go/internal/wire"
"github.com/quic-go/quic-go/logging"
"github.com/stretchr/testify/require"
)
func TestConnectionLoggingCryptoFrame(t *testing.T) {
f := toLoggingFrame(&wire.CryptoFrame{
Offset: 1234,
Data: []byte("foobar"),
})
require.Equal(t, &logging.CryptoFrame{
Offset: 1234,
Length: 6,
}, f)
}
func TestConnectionLoggingStreamFrame(t *testing.T) {
f := toLoggingFrame(&wire.StreamFrame{
StreamID: 42,
Offset: 1234,
Data: []byte("foo"),
Fin: true,
})
require.Equal(t, &logging.StreamFrame{
StreamID: 42,
Offset: 1234,
Length: 3,
Fin: true,
}, f)
}
func TestConnectionLoggingAckFrame(t *testing.T) {
ack := &wire.AckFrame{
AckRanges: []wire.AckRange{
{Smallest: 1, Largest: 3},
{Smallest: 6, Largest: 7},
},
DelayTime: 42,
ECNCE: 123,
ECT0: 456,
ECT1: 789,
}
f := toLoggingFrame(ack)
// now modify the ACK range in the original frame
ack.AckRanges[0].Smallest = 2
require.Equal(t, &logging.AckFrame{
AckRanges: []wire.AckRange{
{Smallest: 1, Largest: 3}, // unchanged, since the ACK ranges were cloned
{Smallest: 6, Largest: 7},
},
DelayTime: 42,
ECNCE: 123,
ECT0: 456,
ECT1: 789,
}, f)
}
func TestConnectionLoggingDatagramFrame(t *testing.T) {
f := toLoggingFrame(&wire.DatagramFrame{Data: []byte("foobar")})
require.Equal(t, &logging.DatagramFrame{Length: 6}, f)
}
func TestConnectionLoggingOtherFrames(t *testing.T) {
f := toLoggingFrame(&wire.MaxDataFrame{MaximumData: 1234})
require.Equal(t, &logging.MaxDataFrame{MaximumData: 1234}, f)
}