forked from quic-go/quic-go
append to a byte slice instead of a bytes.Buffer when serializing frames
This commit is contained in:
39
internal/wire/handshake_done_frame_test.go
Normal file
39
internal/wire/handshake_done_frame_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package wire
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("HANDSHAKE_DONE frame", func() {
|
||||
Context("when parsing", func() {
|
||||
It("accepts sample frame", func() {
|
||||
b := bytes.NewReader([]byte{0x1e})
|
||||
_, err := parseHandshakeDoneFrame(b, protocol.VersionWhatever)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(BeZero())
|
||||
})
|
||||
|
||||
It("errors on EOFs", func() {
|
||||
_, err := parseHandshakeDoneFrame(bytes.NewReader(nil), protocol.VersionWhatever)
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("when writing", func() {
|
||||
It("writes a sample frame", func() {
|
||||
frame := HandshakeDoneFrame{}
|
||||
b, err := frame.Write(nil, protocol.VersionWhatever)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b).To(Equal([]byte{0x1e}))
|
||||
})
|
||||
|
||||
It("has the correct min length", func() {
|
||||
frame := HandshakeDoneFrame{}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(protocol.ByteCount(1)))
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user