github.com/TugasAkhir-QUIC/quic-go@v0.0.2-0.20240215011318-d20e25a9054c/logging/packet_header_test.go (about) 1 package logging_test 2 3 import ( 4 "github.com/TugasAkhir-QUIC/quic-go/internal/protocol" 5 "github.com/TugasAkhir-QUIC/quic-go/internal/wire" 6 . "github.com/TugasAkhir-QUIC/quic-go/logging" 7 8 . "github.com/onsi/ginkgo/v2" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("Packet Header", func() { 13 Context("determining the packet type from the header", func() { 14 It("recognizes Initial packets", func() { 15 Expect(PacketTypeFromHeader(&wire.Header{ 16 Type: protocol.PacketTypeInitial, 17 Version: protocol.Version1, 18 })).To(Equal(PacketTypeInitial)) 19 }) 20 21 It("recognizes Handshake packets", func() { 22 Expect(PacketTypeFromHeader(&wire.Header{ 23 Type: protocol.PacketTypeHandshake, 24 Version: protocol.Version1, 25 })).To(Equal(PacketTypeHandshake)) 26 }) 27 28 It("recognizes Retry packets", func() { 29 Expect(PacketTypeFromHeader(&wire.Header{ 30 Type: protocol.PacketTypeRetry, 31 Version: protocol.Version1, 32 })).To(Equal(PacketTypeRetry)) 33 }) 34 35 It("recognizes 0-RTT packets", func() { 36 Expect(PacketTypeFromHeader(&wire.Header{ 37 Type: protocol.PacketType0RTT, 38 Version: protocol.Version1, 39 })).To(Equal(PacketType0RTT)) 40 }) 41 42 It("recognizes Version Negotiation packets", func() { 43 Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketTypeVersionNegotiation)) 44 }) 45 46 It("handles unrecognized packet types", func() { 47 Expect(PacketTypeFromHeader(&wire.Header{Version: protocol.Version1})).To(Equal(PacketTypeNotDetermined)) 48 }) 49 }) 50 })