mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
introduce a dedicated qerr.TransportError and qerr.ApplicationError
This commit is contained in:
parent
ddeb2281fc
commit
592fb9cad9
57 changed files with 845 additions and 521 deletions
|
@ -339,7 +339,10 @@ var _ = Describe("Packet packer", func() {
|
|||
sealingManager.EXPECT().GetHandshakeSealer().Return(nil, handshake.ErrKeysDropped)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
// expect no framer.PopStreamFrames
|
||||
p, err := packer.PackConnectionClose(qerr.NewError(qerr.CryptoBufferExceeded, "test error"))
|
||||
p, err := packer.PackConnectionClose(&qerr.TransportError{
|
||||
ErrorCode: qerr.CryptoBufferExceeded,
|
||||
ErrorMessage: "test error",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.packets).To(HaveLen(1))
|
||||
Expect(p.packets[0].header.IsLongHeader).To(BeFalse())
|
||||
|
@ -347,7 +350,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.CryptoBufferExceeded))
|
||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.CryptoBufferExceeded))
|
||||
Expect(ccf.ReasonPhrase).To(Equal("test error"))
|
||||
})
|
||||
|
||||
|
@ -361,7 +364,10 @@ var _ = Describe("Packet packer", func() {
|
|||
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
|
||||
sealingManager.EXPECT().GetHandshakeSealer().Return(getSealer(), nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
p, err := packer.PackConnectionClose(qerr.NewApplicationError(0x1337, "test error"))
|
||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||
ErrorCode: 0x1337,
|
||||
ErrorMessage: "test error",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.packets).To(HaveLen(3))
|
||||
Expect(p.packets[0].header.Type).To(Equal(protocol.PacketTypeInitial))
|
||||
|
@ -370,7 +376,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.ApplicationErrorErrorCode))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.Type).To(Equal(protocol.PacketTypeHandshake))
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
@ -378,7 +384,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[1].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf = p.packets[1].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.ApplicationErrorErrorCode))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[2].header.IsLongHeader).To(BeFalse())
|
||||
Expect(p.packets[2].header.PacketNumber).To(Equal(protocol.PacketNumber(3)))
|
||||
|
@ -400,7 +406,10 @@ var _ = Describe("Packet packer", func() {
|
|||
sealingManager.EXPECT().GetHandshakeSealer().Return(getSealer(), nil)
|
||||
sealingManager.EXPECT().Get0RTTSealer().Return(nil, handshake.ErrKeysDropped)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
p, err := packer.PackConnectionClose(qerr.NewApplicationError(0x1337, "test error"))
|
||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||
ErrorCode: 0x1337,
|
||||
ErrorMessage: "test error",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.packets).To(HaveLen(2))
|
||||
Expect(p.buffer.Len()).To(BeNumerically("<", protocol.MinInitialPacketSize))
|
||||
|
@ -410,7 +419,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.ApplicationErrorErrorCode))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.IsLongHeader).To(BeFalse())
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
@ -432,7 +441,10 @@ var _ = Describe("Packet packer", func() {
|
|||
sealingManager.EXPECT().GetHandshakeSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||
sealingManager.EXPECT().Get0RTTSealer().Return(getSealer(), nil)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
|
||||
p, err := packer.PackConnectionClose(qerr.NewApplicationError(0x1337, "test error"))
|
||||
p, err := packer.PackApplicationClose(&qerr.ApplicationError{
|
||||
ErrorCode: 0x1337,
|
||||
ErrorMessage: "test error",
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.packets).To(HaveLen(2))
|
||||
Expect(p.buffer.Len()).To(BeNumerically(">=", protocol.MinInitialPacketSize))
|
||||
|
@ -443,7 +455,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ErrorCode).To(BeEquivalentTo(qerr.ApplicationErrorErrorCode))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.Type).To(Equal(protocol.PacketType0RTT))
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue