remove version 32 from tests

ref 
This commit is contained in:
Marten Seemann 2016-07-31 16:19:03 +07:00 committed by Lucas Clemente
parent e2d5d7e3a6
commit a8764d923e
4 changed files with 38 additions and 38 deletions

View file

@ -14,7 +14,7 @@ var _ = Describe("AckFrame", func() {
Context("when parsing", func() {
It("accepts sample frame", func() {
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.Entropy).To(Equal(byte(0xA4)))
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0x03)))
@ -25,7 +25,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame with a 48 bit packet number", func() {
b := bytes.NewReader([]byte{0x4C, 0xA4, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
Expect(b.Len()).To(Equal(0))
@ -33,14 +33,14 @@ var _ = Describe("AckFrame", func() {
It("completely parses a frame with multiple timestamps", func() {
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x03, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0x12, 0x34, 0x56, 0x78, 0x90, 0xA0})
_, err := ParseAckFrameLegacy(b, protocol.Version32)
_, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Len()).To(Equal(0))
})
It("parses a frame containing one NACK range", func() {
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.HasNACK()).To(Equal(true))
Expect(frame.NackRanges).To(HaveLen(1))
@ -52,7 +52,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame containing one NACK range with a 48 bit LargestObserved and missingPacketSequenceNumberDelta", func() {
var rangeLength uint64 = 3
b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, byte(rangeLength)})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
Expect(frame.HasNACK()).To(Equal(true))
@ -64,7 +64,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame containing multiple NACK ranges", func() {
// sent packets 1, 3, 7, 15
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.HasNACK()).To(Equal(true))
Expect(frame.NackRanges).To(HaveLen(3))
@ -77,13 +77,13 @@ var _ = Describe("AckFrame", func() {
It("rejects a packet with an invalid NACK range", func() {
// LargestObserved: 8, NackRange: (8-7-3) to (8-7)
b := bytes.NewReader([]byte{0x60, 0x8, 0x7, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x7, 0x3})
_, err := ParseAckFrameLegacy(b, protocol.Version32)
_, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).To(MatchError(errInvalidNackRanges))
})
It("accepts truncated acks", func() {
b := bytes.NewReader([]byte{0x50, 0xA4, 0x03, 0x23, 0x45})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.Truncated).To(BeTrue())
Expect(b.Len()).To(BeZero())
@ -91,7 +91,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame with the largest observed missing", func() {
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x1, 0x0, 0x0})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.HasNACK()).To(Equal(true))
Expect(frame.NackRanges).To(HaveLen(1))
@ -102,7 +102,7 @@ var _ = Describe("AckFrame", func() {
Context("contiguous NACK ranges", func() {
It("parses a frame with a contiguous NACK range spanning two fields", func() {
b := bytes.NewReader([]byte{0x64, 0x8, 0x2E, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(302)))
Expect(frame.NackRanges).To(HaveLen(1))
@ -111,7 +111,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame with a contiguous NACK range spanning more than two fields", func() {
b := bytes.NewReader([]byte{0x64, 0x8, 0x16, 0x05, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x6, 0x1, 0x13, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(1302)))
Expect(frame.NackRanges).To(HaveLen(1))
@ -120,7 +120,7 @@ var _ = Describe("AckFrame", func() {
It("parses a frame with two contiguous NACK ranges", func() {
b := bytes.NewReader([]byte{0x64, 0x8, 0x23, 0x03, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x4, 0x1, 0x8f, 0x0, 0xff, 0x1, 0x8f, 0x0, 0xff})
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
frame, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(803)))
Expect(frame.NackRanges).To(HaveLen(2))
@ -131,7 +131,7 @@ var _ = Describe("AckFrame", func() {
It("rejects a frame with an invalid NACK range", func() {
// LargestObserved: 280, but NACK range is 301 packets long
b := bytes.NewReader([]byte{0x64, 0x8, 0x18, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
_, err := ParseAckFrameLegacy(b, protocol.Version32)
_, err := ParseAckFrameLegacy(b, protocol.VersionWhatever)
Expect(err).To(MatchError(errInvalidNackRanges))
})
})
@ -266,7 +266,7 @@ var _ = Describe("AckFrame", func() {
Entropy: 2,
LargestObserved: 1,
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
// check all values except the DelayTime
Expect(b.Bytes()[0:3]).To(Equal([]byte{0x40, 0x02, 0x01}))
@ -278,7 +278,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 5,
PacketReceivedTime: time.Now().Add(-750 * time.Millisecond),
}
frame.Write(b, protocol.Version32)
frame.Write(b, protocol.VersionWhatever)
Expect(frame.DelayTime).To(BeNumerically("~", 750*time.Millisecond, 10*time.Millisecond))
delayTime := frame.DelayTime
var b2 bytes.Buffer
@ -292,7 +292,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 4,
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-8:]
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
@ -310,7 +310,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 7,
NackRanges: []NackRange{nackRange1, nackRange2},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
@ -331,7 +331,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 258,
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 257}},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges
@ -345,7 +345,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 302,
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 301}},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
@ -361,7 +361,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 259,
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 258}},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges
@ -377,7 +377,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 603,
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 601}},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges
@ -397,7 +397,7 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 655,
NackRanges: []NackRange{nackRange2, nackRange1},
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):]
Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges
@ -416,7 +416,7 @@ var _ = Describe("AckFrame", func() {
frame := AckFrameLegacy{
LargestObserved: 7,
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x40)))
Expect(b.Bytes()[2]).To(Equal(uint8(7)))
@ -426,7 +426,7 @@ var _ = Describe("AckFrame", func() {
frame := AckFrameLegacy{
LargestObserved: 0x1337,
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x44)))
Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13}))
@ -436,7 +436,7 @@ var _ = Describe("AckFrame", func() {
frame := AckFrameLegacy{
LargestObserved: 0xDECAFBAD,
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x48)))
Expect(b.Bytes()[2:6]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
@ -446,7 +446,7 @@ var _ = Describe("AckFrame", func() {
frame := AckFrameLegacy{
LargestObserved: 0xDEADBEEFCAFE,
}
err := frame.Write(b, protocol.Version32)
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x4C)))
Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE}))
@ -508,9 +508,9 @@ var _ = Describe("AckFrame", func() {
Entropy: 0xDE,
LargestObserved: 6789,
}
err := frameOrig.Write(b, protocol.Version32)
err := frameOrig.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
frame, err := ParseAckFrameLegacy(bytes.NewReader(b.Bytes()), protocol.Version32)
frame, err := ParseAckFrameLegacy(bytes.NewReader(b.Bytes()), protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.Entropy).To(Equal(frameOrig.Entropy))
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
@ -526,10 +526,10 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 15,
NackRanges: nackRanges,
}
err := frameOrig.Write(b, protocol.Version32)
err := frameOrig.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
r := bytes.NewReader(b.Bytes())
frame, err := ParseAckFrameLegacy(r, protocol.Version32)
frame, err := ParseAckFrameLegacy(r, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
@ -546,10 +546,10 @@ var _ = Describe("AckFrame", func() {
LargestObserved: 1600,
NackRanges: nackRanges,
}
err := frameOrig.Write(b, protocol.Version32)
err := frameOrig.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
r := bytes.NewReader(b.Bytes())
frame, err := ParseAckFrameLegacy(r, protocol.Version32)
frame, err := ParseAckFrameLegacy(r, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))

View file

@ -883,7 +883,7 @@ var _ = Describe("AckFrame", func() {
Context("Legacy AckFrame wrapping", func() {
It("parses a ACK frame", func() {
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
frame, err := ParseAckFrame(b, protocol.Version32)
frame, err := ParseAckFrame(b, protocol.Version33)
Expect(err).ToNot(HaveOccurred())
Expect(frame.AckFrameLegacy).ToNot(BeNil())
Expect(frame.AckFrameLegacy.Entropy).To(Equal(byte(0xA4)))
@ -903,9 +903,9 @@ var _ = Describe("AckFrame", func() {
frame := AckFrame{
AckFrameLegacy: ackLegacy,
}
err := frame.Write(b1, protocol.Version32)
err := frame.Write(b1, protocol.Version33)
Expect(err).ToNot(HaveOccurred())
err = ackLegacy.Write(b2, protocol.Version32)
err = ackLegacy.Write(b2, protocol.Version33)
Expect(err).ToNot(HaveOccurred())
Expect(b1.Bytes()).To(Equal(b2.Bytes()))
})

View file

@ -160,7 +160,7 @@ var _ = Describe("Packet packer", func() {
It("packs many control frames into 1 packets", func() {
f := &frames.AckFrameLegacy{LargestObserved: 1}
b := &bytes.Buffer{}
f.Write(b, protocol.Version32)
f.Write(b, protocol.VersionWhatever)
maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len()
var controlFrames []frames.Frame
for i := 0; i < maxFramesPerPacket; i++ {

View file

@ -87,10 +87,10 @@ var _ = Describe("Packet unpacker", func() {
Entropy: 0x37,
},
}
err := f.Write(buf, protocol.Version32)
err := f.Write(buf, protocol.Version33)
Expect(err).ToNot(HaveOccurred())
setData(buf.Bytes())
unpacker.version = protocol.Version32
unpacker.version = protocol.Version33
packet, err := unpacker.Unpack(hdrBin, hdr, data)
Expect(err).ToNot(HaveOccurred())
Expect(packet.frames).To(HaveLen(1))