mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
don't explicitely pass the header binary to the unpacker
This commit is contained in:
parent
ce6b9f2f1d
commit
c912860a94
5 changed files with 24 additions and 24 deletions
|
@ -33,7 +33,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
It("errors if the packet doesn't contain any payload", func() {
|
||||
data := []byte("foobar")
|
||||
aead.EXPECT().Open1RTT(gomock.Any(), []byte("foobar"), hdr.PacketNumber, hdr.Raw).Return([]byte{}, nil)
|
||||
_, err := unpacker.Unpack(hdr.Raw, hdr, data)
|
||||
_, err := unpacker.Unpack(hdr, data)
|
||||
Expect(err).To(MatchError(qerr.MissingPayload))
|
||||
})
|
||||
|
||||
|
@ -41,7 +41,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
hdr.IsLongHeader = true
|
||||
hdr.Type = protocol.PacketTypeInitial
|
||||
aead.EXPECT().OpenInitial(gomock.Any(), gomock.Any(), hdr.PacketNumber, hdr.Raw).Return([]byte{0}, nil)
|
||||
packet, err := unpacker.Unpack(hdr.Raw, hdr, nil)
|
||||
packet, err := unpacker.Unpack(hdr, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.encryptionLevel).To(Equal(protocol.EncryptionInitial))
|
||||
})
|
||||
|
@ -50,7 +50,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
hdr.IsLongHeader = true
|
||||
hdr.Type = protocol.PacketTypeHandshake
|
||||
aead.EXPECT().OpenHandshake(gomock.Any(), gomock.Any(), hdr.PacketNumber, hdr.Raw).Return([]byte{0}, nil)
|
||||
packet, err := unpacker.Unpack(hdr.Raw, hdr, nil)
|
||||
packet, err := unpacker.Unpack(hdr, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.encryptionLevel).To(Equal(protocol.EncryptionHandshake))
|
||||
})
|
||||
|
@ -59,7 +59,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
hdr.IsLongHeader = true
|
||||
hdr.Type = protocol.PacketTypeHandshake
|
||||
aead.EXPECT().OpenHandshake(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, errors.New("test err"))
|
||||
_, err := unpacker.Unpack(hdr.Raw, hdr, nil)
|
||||
_, err := unpacker.Unpack(hdr, nil)
|
||||
Expect(err).To(MatchError(qerr.Error(qerr.DecryptionFailure, "test err")))
|
||||
})
|
||||
|
||||
|
@ -69,7 +69,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
PacketNumberLen: 2,
|
||||
}
|
||||
aead.EXPECT().Open1RTT(gomock.Any(), gomock.Any(), firstHdr.PacketNumber, gomock.Any()).Return([]byte{0}, nil)
|
||||
packet, err := unpacker.Unpack(firstHdr.Raw, firstHdr, nil)
|
||||
packet, err := unpacker.Unpack(firstHdr, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.packetNumber).To(Equal(protocol.PacketNumber(0x1337)))
|
||||
// the real packet number is 0x1338, but only the last byte is sent
|
||||
|
@ -79,7 +79,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
}
|
||||
// expect the call with the decoded packet number
|
||||
aead.EXPECT().Open1RTT(gomock.Any(), gomock.Any(), protocol.PacketNumber(0x1338), gomock.Any()).Return([]byte{0}, nil)
|
||||
packet, err = unpacker.Unpack(secondHdr.Raw, secondHdr, nil)
|
||||
packet, err = unpacker.Unpack(secondHdr, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.packetNumber).To(Equal(protocol.PacketNumber(0x1338)))
|
||||
})
|
||||
|
@ -89,7 +89,7 @@ var _ = Describe("Packet Unpacker", func() {
|
|||
(&wire.PingFrame{}).Write(buf, protocol.VersionWhatever)
|
||||
(&wire.DataBlockedFrame{}).Write(buf, protocol.VersionWhatever)
|
||||
aead.EXPECT().Open1RTT(gomock.Any(), gomock.Any(), hdr.PacketNumber, hdr.Raw).Return(buf.Bytes(), nil)
|
||||
packet, err := unpacker.Unpack(hdr.Raw, hdr, nil)
|
||||
packet, err := unpacker.Unpack(hdr, nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.frames).To(Equal([]wire.Frame{&wire.PingFrame{}, &wire.DataBlockedFrame{}}))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue