uquic/internal/wire/blocked_frame_test.go
Marten Seemann 759b0d87b1 refactor packet unpacking
This replaces version.UsesMaxDataFrame by versoin.UsesIETFFrameFormat.
That way, we can have two separate code paths in the unpacker to unpack
either gQUIC frames or IETF frames.
2017-12-08 09:18:54 +07:00

41 lines
1,016 B
Go

package wire
import (
"bytes"
"github.com/lucas-clemente/quic-go/internal/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("BLOCKED frame", func() {
Context("when parsing", func() {
It("accepts sample frame", func() {
b := bytes.NewReader([]byte{0x08})
_, err := ParseBlockedFrame(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Len()).To(BeZero())
})
It("errors on EOFs", func() {
_, err := ParseBlockedFrame(bytes.NewReader(nil), protocol.VersionWhatever)
Expect(err).To(HaveOccurred())
})
})
Context("when writing", func() {
It("writes a sample frame", func() {
b := &bytes.Buffer{}
frame := BlockedFrame{}
err := frame.Write(b, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b.Bytes()).To(Equal([]byte{0x08}))
})
It("has the correct min length", func() {
frame := BlockedFrame{}
Expect(frame.MinLength(versionIETFFrames)).To(Equal(protocol.ByteCount(1)))
})
})
})