remove the LongHeader field from the wire.Header

This commit is contained in:
Marten Seemann 2022-12-27 12:03:38 +13:00
parent aca052dc7c
commit 86edf7fd4b
23 changed files with 154 additions and 363 deletions

View file

@ -6,9 +6,6 @@ import (
// PacketTypeFromHeader determines the packet type from a *wire.Header.
func PacketTypeFromHeader(hdr *Header) PacketType {
if !hdr.IsLongHeader {
return PacketType1RTT
}
if hdr.Version == 0 {
return PacketTypeVersionNegotiation
}

View file

@ -12,49 +12,38 @@ var _ = Describe("Packet Header", func() {
Context("determining the packet type from the header", func() {
It("recognizes Initial packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Type: protocol.PacketTypeInitial,
Version: protocol.VersionTLS,
Type: protocol.PacketTypeInitial,
Version: protocol.VersionTLS,
})).To(Equal(PacketTypeInitial))
})
It("recognizes Handshake packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Type: protocol.PacketTypeHandshake,
Version: protocol.VersionTLS,
Type: protocol.PacketTypeHandshake,
Version: protocol.VersionTLS,
})).To(Equal(PacketTypeHandshake))
})
It("recognizes Retry packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Type: protocol.PacketTypeRetry,
Version: protocol.VersionTLS,
Type: protocol.PacketTypeRetry,
Version: protocol.VersionTLS,
})).To(Equal(PacketTypeRetry))
})
It("recognizes 0-RTT packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Type: protocol.PacketType0RTT,
Version: protocol.VersionTLS,
Type: protocol.PacketType0RTT,
Version: protocol.VersionTLS,
})).To(Equal(PacketType0RTT))
})
It("recognizes Version Negotiation packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{IsLongHeader: true})).To(Equal(PacketTypeVersionNegotiation))
})
It("recognizes 1-RTT packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketType1RTT))
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketTypeVersionNegotiation))
})
It("handles unrecognized packet types", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Version: protocol.VersionTLS,
})).To(Equal(PacketTypeNotDetermined))
Expect(PacketTypeFromHeader(&wire.Header{Version: protocol.VersionTLS})).To(Equal(PacketTypeNotDetermined))
})
})
})