append to a byte slice instead of a bytes.Buffer when serializing frames

This commit is contained in:
Marten Seemann
2022-08-28 23:05:07 +03:00
parent 65dd82ad90
commit 3ca1001951
50 changed files with 443 additions and 425 deletions

View File

@@ -32,14 +32,13 @@ var _ = Describe("PATH_RESPONSE frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
b := &bytes.Buffer{}
frame := PathResponseFrame{Data: [8]byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}}
err := frame.Write(b, protocol.VersionWhatever)
b, err := frame.Write(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()).To(Equal([]byte{0x1b, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
Expect(b).To(Equal([]byte{0x1b, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
})
It("has the correct min length", func() {
It("has the correct length", func() {
frame := PathResponseFrame{}
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(protocol.ByteCount(9)))
})