github.com/tumi8/quic-go@v0.37.4-tum/logging/packet_header_test.go (about)

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