github.com/tumi8/quic-go@v0.37.4-tum/noninternal/logutils/frame_test.go (about) 1 package logutils 2 3 import ( 4 "github.com/tumi8/quic-go/noninternal/wire" 5 "github.com/tumi8/quic-go/logging" 6 . "github.com/onsi/ginkgo/v2" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("CRYPTO frame", func() { 11 It("converts CRYPTO frames", func() { 12 f := ConvertFrame(&wire.CryptoFrame{ 13 Offset: 1234, 14 Data: []byte("foobar"), 15 }) 16 Expect(f).To(BeAssignableToTypeOf(&logging.CryptoFrame{})) 17 cf := f.(*logging.CryptoFrame) 18 Expect(cf.Offset).To(Equal(logging.ByteCount(1234))) 19 Expect(cf.Length).To(Equal(logging.ByteCount(6))) 20 }) 21 22 It("converts STREAM frames", func() { 23 f := ConvertFrame(&wire.StreamFrame{ 24 StreamID: 42, 25 Offset: 1234, 26 Data: []byte("foo"), 27 Fin: true, 28 }) 29 Expect(f).To(BeAssignableToTypeOf(&logging.StreamFrame{})) 30 sf := f.(*logging.StreamFrame) 31 Expect(sf.StreamID).To(Equal(logging.StreamID(42))) 32 Expect(sf.Offset).To(Equal(logging.ByteCount(1234))) 33 Expect(sf.Length).To(Equal(logging.ByteCount(3))) 34 Expect(sf.Fin).To(BeTrue()) 35 }) 36 37 It("converts DATAGRAM frames", func() { 38 f := ConvertFrame(&wire.DatagramFrame{Data: []byte("foobar")}) 39 Expect(f).To(BeAssignableToTypeOf(&logging.DatagramFrame{})) 40 df := f.(*logging.DatagramFrame) 41 Expect(df.Length).To(Equal(logging.ByteCount(6))) 42 }) 43 44 It("converts other frames", func() { 45 f := ConvertFrame(&wire.MaxDataFrame{MaximumData: 1234}) 46 Expect(f).To(BeAssignableToTypeOf(&logging.MaxDataFrame{})) 47 Expect(f).ToNot(BeAssignableToTypeOf(&logging.MaxStreamDataFrame{})) 48 mdf := f.(*logging.MaxDataFrame) 49 Expect(mdf.MaximumData).To(Equal(logging.ByteCount(1234))) 50 }) 51 })