never send 1-byte packet numbers

This commit is contained in:
Marten Seemann 2016-08-25 12:34:55 +07:00
parent 9bd9c8aa54
commit eabd38238a
No known key found for this signature in database
GPG key ID: 3603F40B121FCDEA
3 changed files with 13 additions and 15 deletions

View file

@ -128,20 +128,20 @@ var _ = Describe("packet number calculation", func() {
Context("shortening a packet number for the publicHeader", func() {
Context("shortening", func() {
It("sends out low packet numbers as 1 byte", func() {
It("sends out low packet numbers as 2 byte", func() {
length := GetPacketNumberLengthForPublicHeader(4, 2)
Expect(length).To(Equal(PacketNumberLen1))
})
It("sends out high packet numbers as 1 byte, if all ACKs are received", func() {
length := GetPacketNumberLengthForPublicHeader(0xDEADBEEF, 0xDEADBEEF-1)
Expect(length).To(Equal(PacketNumberLen1))
})
It("sends out higher packet numbers as 2 bytes, if a lot of ACKs are missing", func() {
length := GetPacketNumberLengthForPublicHeader(200, 2)
Expect(length).To(Equal(PacketNumberLen2))
})
It("sends out high packet numbers as 2 byte, if all ACKs are received", func() {
length := GetPacketNumberLengthForPublicHeader(0xDEADBEEF, 0xDEADBEEF-1)
Expect(length).To(Equal(PacketNumberLen2))
})
It("sends out higher packet numbers as 4 bytes, if a lot of ACKs are missing", func() {
length := GetPacketNumberLengthForPublicHeader(40000, 2)
Expect(length).To(Equal(PacketNumberLen4))
})
})
Context("self-consistency", func() {