pass packet number and packet number length to frames.Write

This commit is contained in:
Marten Seemann 2016-04-25 11:34:18 +07:00
parent 7467e7ebff
commit f2eafb7179
13 changed files with 45 additions and 39 deletions

View file

@ -33,7 +33,7 @@ var _ = Describe("Packet packer", func() {
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
b := &bytes.Buffer{}
f.Write(b)
f.Write(b, 1, 6)
Expect(p.payload).To(Equal(b.Bytes()))
Expect(p.raw).To(ContainSubstring(string(b.Bytes())))
})
@ -47,8 +47,8 @@ var _ = Describe("Packet packer", func() {
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
b := &bytes.Buffer{}
f1.Write(b)
f2.Write(b)
f1.Write(b, 2, 6)
f2.Write(b, 2, 6)
Expect(p.payload).To(Equal(b.Bytes()))
Expect(p.raw).To(ContainSubstring(string(b.Bytes())))
})
@ -56,7 +56,7 @@ var _ = Describe("Packet packer", func() {
It("packs many normal frames into 2 packets", func() {
f := &frames.AckFrame{LargestObserved: 1}
b := &bytes.Buffer{}
f.Write(b)
f.Write(b, 3, 6)
for i := 0; i <= (protocol.MaxFrameSize-1)/b.Len()+1; i++ {
packer.AddFrame(f)
}
@ -78,7 +78,7 @@ var _ = Describe("Packet packer", func() {
Offset: 1,
}
b := &bytes.Buffer{}
f.Write(b)
f.Write(b, 4, 6)
packer.AddFrame(f)
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())