42 lines
1016 B
Go
42 lines
1016 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)))
|
||
|
})
|
||
|
})
|
||
|
})
|