split the qlog package into a logging and a qlog package

This commit is contained in:
Marten Seemann 2020-06-29 11:31:50 +07:00
parent 7c42d7941a
commit 78ba619a0b
25 changed files with 525 additions and 460 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/internal/wire"
"github.com/lucas-clemente/quic-go/logging"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -15,59 +16,10 @@ import (
var _ = Describe("Packet Header", func() {
It("determines the packet type from the encryption level", func() {
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(Equal(PacketTypeInitial))
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(Equal(PacketTypeHandshake))
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(Equal(PacketType0RTT))
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(Equal(PacketType1RTT))
})
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,
})).To(Equal(PacketTypeInitial))
})
It("recognizes Handshake packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
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,
})).To(Equal(PacketTypeRetry))
})
It("recognizes 0-RTT packets", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
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))
})
It("handles unrecognized packet types", func() {
Expect(PacketTypeFromHeader(&wire.Header{
IsLongHeader: true,
Version: protocol.VersionTLS,
})).To(Equal(PacketTypeNotDetermined))
})
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionInitial)).To(Equal(logging.PacketTypeInitial))
Expect(getPacketTypeFromEncryptionLevel(protocol.EncryptionHandshake)).To(Equal(logging.PacketTypeHandshake))
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption0RTT)).To(Equal(logging.PacketType0RTT))
Expect(getPacketTypeFromEncryptionLevel(protocol.Encryption1RTT)).To(Equal(logging.PacketType1RTT))
})
Context("marshalling", func() {