forked from quic-go/quic-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection_logging_test.go
52 lines (46 loc) · 1.56 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
package quic
import (
"github.com/xtls/quic-go/internal/wire"
"github.com/xtls/quic-go/logging"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("CRYPTO frame", func() {
It("converts CRYPTO frames", func() {
f := toLoggingFrame(&wire.CryptoFrame{
Offset: 1234,
Data: []byte("foobar"),
})
Expect(f).To(BeAssignableToTypeOf(&logging.CryptoFrame{}))
cf := f.(*logging.CryptoFrame)
Expect(cf.Offset).To(Equal(logging.ByteCount(1234)))
Expect(cf.Length).To(Equal(logging.ByteCount(6)))
})
It("converts STREAM frames", func() {
f := toLoggingFrame(&wire.StreamFrame{
StreamID: 42,
Offset: 1234,
Data: []byte("foo"),
Fin: true,
})
Expect(f).To(BeAssignableToTypeOf(&logging.StreamFrame{}))
sf := f.(*logging.StreamFrame)
Expect(sf.StreamID).To(Equal(logging.StreamID(42)))
Expect(sf.Offset).To(Equal(logging.ByteCount(1234)))
Expect(sf.Length).To(Equal(logging.ByteCount(3)))
Expect(sf.Fin).To(BeTrue())
})
It("converts DATAGRAM frames", func() {
f := toLoggingFrame(&wire.DatagramFrame{Data: []byte("foobar")})
Expect(f).To(BeAssignableToTypeOf(&logging.DatagramFrame{}))
df := f.(*logging.DatagramFrame)
Expect(df.Length).To(Equal(logging.ByteCount(6)))
})
It("converts other frames", func() {
f := toLoggingFrame(&wire.MaxDataFrame{MaximumData: 1234})
Expect(f).To(BeAssignableToTypeOf(&logging.MaxDataFrame{}))
Expect(f).ToNot(BeAssignableToTypeOf(&logging.MaxStreamDataFrame{}))
mdf := f.(*logging.MaxDataFrame)
Expect(mdf.MaximumData).To(Equal(logging.ByteCount(1234)))
})
})