forked from quic-go/quic-go
append to a byte slice instead of a bytes.Buffer when serializing frames
This commit is contained in:
@@ -77,15 +77,15 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
|
||||
ConnectionID: protocol.ConnectionID{1, 2, 3, 4, 5, 6},
|
||||
StatelessResetToken: token,
|
||||
}
|
||||
b := &bytes.Buffer{}
|
||||
Expect(frame.Write(b, protocol.Version1)).To(Succeed())
|
||||
b, err := frame.Write(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{0x18}
|
||||
expected = append(expected, encodeVarInt(0x1337)...)
|
||||
expected = append(expected, encodeVarInt(0x42)...)
|
||||
expected = append(expected, 6)
|
||||
expected = append(expected, []byte{1, 2, 3, 4, 5, 6}...)
|
||||
expected = append(expected, token[:]...)
|
||||
Expect(b.Bytes()).To(Equal(expected))
|
||||
Expect(b).To(Equal(expected))
|
||||
})
|
||||
|
||||
It("has the correct length", func() {
|
||||
@@ -96,9 +96,9 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
|
||||
ConnectionID: protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8},
|
||||
StatelessResetToken: token,
|
||||
}
|
||||
b := &bytes.Buffer{}
|
||||
Expect(frame.Write(b, protocol.Version1)).To(Succeed())
|
||||
Expect(frame.Length(protocol.Version1)).To(BeEquivalentTo(b.Len()))
|
||||
b, err := frame.Write(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b).To(HaveLen(int(frame.Length(protocol.Version1))))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user