uquic/internal/wire/retire_connection_id_frame_test.go
Gaukas Wang 95575f5fe7
break: update repo url [ci skip]
uTLS is not yet bumped to the new version, so this commit breaks the dependencies relationship by getting rid of the local replace.
2023-08-03 18:58:52 -06:00

51 lines
1.5 KiB
Go

package wire
import (
"bytes"
"io"
"github.com/refraction-networking/uquic/internal/protocol"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("NEW_CONNECTION_ID frame", func() {
Context("when parsing", func() {
It("accepts a sample frame", func() {
data := encodeVarInt(0xdeadbeef) // sequence number
b := bytes.NewReader(data)
frame, err := parseRetireConnectionIDFrame(b, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(frame.SequenceNumber).To(Equal(uint64(0xdeadbeef)))
})
It("errors on EOFs", func() {
data := encodeVarInt(0xdeadbeef) // sequence number
_, err := parseRetireConnectionIDFrame(bytes.NewReader(data), protocol.Version1)
Expect(err).NotTo(HaveOccurred())
for i := range data {
_, err := parseRetireConnectionIDFrame(bytes.NewReader(data[:i]), protocol.Version1)
Expect(err).To(MatchError(io.EOF))
}
})
})
Context("when writing", func() {
It("writes a sample frame", func() {
frame := &RetireConnectionIDFrame{SequenceNumber: 0x1337}
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{retireConnectionIDFrameType}
expected = append(expected, encodeVarInt(0x1337)...)
Expect(b).To(Equal(expected))
})
It("has the correct length", func() {
frame := &RetireConnectionIDFrame{SequenceNumber: 0xdecafbad}
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(frame.Length(protocol.Version1))))
})
})
})