rename frame.Write to frame.Append

This commit is contained in:
Marten Seemann 2022-08-28 23:13:19 +03:00
parent 3ca1001951
commit ab6d664b43
50 changed files with 112 additions and 112 deletions

View file

@ -561,7 +561,7 @@ var _ = Describe("Connection", func() {
}
Expect(hdr.Write(buf, conn.version)).To(Succeed())
unpacker.EXPECT().Unpack(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*wire.Header, time.Time, []byte) (*unpackedPacket, error) {
b, err := (&wire.ConnectionCloseFrame{ErrorCode: uint64(qerr.StreamLimitError)}).Write(nil, conn.version)
b, err := (&wire.ConnectionCloseFrame{ErrorCode: uint64(qerr.StreamLimitError)}).Append(nil, conn.version)
Expect(err).ToNot(HaveOccurred())
return &unpackedPacket{
hdr: hdr,
@ -754,7 +754,7 @@ var _ = Describe("Connection", func() {
PacketNumberLen: protocol.PacketNumberLen1,
}
rcvTime := time.Now().Add(-10 * time.Second)
b, err := (&wire.PingFrame{}).Write(nil, conn.version)
b, err := (&wire.PingFrame{}).Append(nil, conn.version)
Expect(err).ToNot(HaveOccurred())
packet := getPacket(hdr, nil)
packet.ecn = protocol.ECT1

View file

@ -252,7 +252,7 @@ func getFrames() []wire.Frame {
func main() {
for _, f := range getFrames() {
b, err := f.Write(nil, version)
b, err := f.Append(nil, version)
if err != nil {
log.Fatal(err)
}
@ -271,7 +271,7 @@ func main() {
}
f := frames[rand.Intn(len(frames))]
var err error
b, err = f.Write(b, version)
b, err = f.Append(b, version)
if err != nil {
log.Fatal(err)
}

View file

@ -69,7 +69,7 @@ func Fuzz(data []byte) int {
}
}
lenBefore := len(b)
b, err := f.Write(b, version)
b, err := f.Append(b, version)
if err != nil {
panic(fmt.Sprintf("Error writing frame %#v: %s", f, err))
}

View file

@ -23,7 +23,7 @@ func packRawPayload(version protocol.VersionNumber, frames []wire.Frame) []byte
var b []byte
for _, cf := range frames {
var err error
b, err = cf.Write(b, version)
b, err = cf.Append(b, version)
if err != nil {
panic(err)
}

View file

@ -107,7 +107,7 @@ func parseAckFrame(r *bytes.Reader, ackDelayExponent uint8, _ protocol.VersionNu
}
// Write writes an ACK frame.
func (f *AckFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *AckFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
hasECN := f.ECT0 > 0 || f.ECT1 > 0 || f.ECNCE > 0
if hasECN {
b = append(b, 0b11)

View file

@ -120,7 +120,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
AckRanges: []AckRange{{Smallest: 1, Largest: 1}},
DelayTime: delayTime,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
for i := uint8(0); i < 8; i++ {
r := bytes.NewReader(b)
@ -205,7 +205,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
f := &AckFrame{
AckRanges: []AckRange{{Smallest: 100, Largest: 1337}},
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x2}
expected = append(expected, encodeVarInt(1337)...) // largest acked
@ -222,7 +222,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
ECT1: 37,
ECNCE: 12345,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
expected := []byte{0x3}
@ -241,7 +241,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
AckRanges: []AckRange{{Smallest: 0x2eadbeef, Largest: 0x2eadbeef}},
DelayTime: 18 * time.Millisecond,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
r := bytes.NewReader(b)
@ -257,7 +257,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
f := &AckFrame{
AckRanges: []AckRange{{Smallest: 0x1337, Largest: 0x2eadbeef}},
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
r := bytes.NewReader(b)
@ -276,7 +276,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
},
}
Expect(f.validateAckRanges()).To(BeTrue())
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
r := bytes.NewReader(b)
@ -297,7 +297,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
},
}
Expect(f.validateAckRanges()).To(BeTrue())
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
r := bytes.NewReader(b)
@ -316,7 +316,7 @@ var _ = Describe("ACK Frame (for IETF QUIC)", func() {
}
f := &AckFrame{AckRanges: ackRanges}
Expect(f.validateAckRanges()).To(BeTrue())
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
// make sure the ACK frame is *a little bit* smaller than the MaxAckFrameSize

View file

@ -66,7 +66,7 @@ func (f *ConnectionCloseFrame) Length(protocol.VersionNumber) protocol.ByteCount
return length
}
func (f *ConnectionCloseFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *ConnectionCloseFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
if f.IsApplicationError {
b = append(b, 0x1d)
} else {

View file

@ -88,7 +88,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
ErrorCode: 0xbeef,
FrameType: 0x12345,
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x1c}
expected = append(expected, encodeVarInt(0xbeef)...)
@ -102,7 +102,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
ErrorCode: 0xdead,
ReasonPhrase: "foobar",
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x1c}
expected = append(expected, encodeVarInt(0xdead)...)
@ -118,7 +118,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
ErrorCode: 0xdead,
ReasonPhrase: "foobar",
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x1d}
expected = append(expected, encodeVarInt(0xdead)...)
@ -133,7 +133,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
FrameType: 0xdeadbeef,
ReasonPhrase: "foobar",
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
})
@ -144,7 +144,7 @@ var _ = Describe("CONNECTION_CLOSE Frame", func() {
ErrorCode: 0xcafe,
ReasonPhrase: "foobar",
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(f.Length(protocol.Version1))))
})

View file

@ -42,7 +42,7 @@ func parseCryptoFrame(r *bytes.Reader, _ protocol.VersionNumber) (*CryptoFrame,
return frame, nil
}
func (f *CryptoFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *CryptoFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x6)
b = quicvarint.Append(b, uint64(f.Offset))
b = quicvarint.Append(b, uint64(len(f.Data)))

View file

@ -45,7 +45,7 @@ var _ = Describe("CRYPTO frame", func() {
Offset: 0x123456,
Data: []byte("foobar"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x6}
expected = append(expected, encodeVarInt(0x123456)...) // offset
@ -70,13 +70,13 @@ var _ = Describe("CRYPTO frame", func() {
if maxDataLen == 0 { // 0 means that no valid CRYTPO frame can be written
// check that writing a minimal size CRYPTO frame (i.e. with 1 byte data) is actually larger than the desired size
f.Data = []byte{0}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(BeNumerically(">", i))
continue
}
f.Data = data[:int(maxDataLen)]
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
// There's *one* pathological case, where a data length of x can be encoded into 1 byte
// but a data lengths of x+1 needs 2 bytes

View file

@ -25,7 +25,7 @@ func parseDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DataBloc
}, nil
}
func (f *DataBlockedFrame) Write(b []byte, version protocol.VersionNumber) ([]byte, error) {
func (f *DataBlockedFrame) Append(b []byte, version protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x14)
b = quicvarint.Append(b, uint64(f.MaximumData))
return b, nil

View file

@ -38,7 +38,7 @@ var _ = Describe("DATA_BLOCKED frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := DataBlockedFrame{MaximumData: 0xdeadbeef}
b, err := frame.Write(nil, protocol.VersionWhatever)
b, err := frame.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x14}
expected = append(expected, encodeVarInt(0xdeadbeef)...)

View file

@ -44,7 +44,7 @@ func parseDatagramFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DatagramFra
return f, nil
}
func (f *DatagramFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *DatagramFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
typeByte := uint8(0x30)
if f.DataLenPresent {
typeByte ^= 0b1

View file

@ -64,7 +64,7 @@ var _ = Describe("STREAM frame", func() {
DataLenPresent: true,
Data: []byte("foobar"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x30 ^ 0x1}
expected = append(expected, encodeVarInt(0x6)...)
@ -74,7 +74,7 @@ var _ = Describe("STREAM frame", func() {
It("writes a frame without length", func() {
f := &DatagramFrame{Data: []byte("Lorem ipsum")}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x30}
expected = append(expected, []byte("Lorem ipsum")...)
@ -111,13 +111,13 @@ var _ = Describe("STREAM frame", func() {
if maxDataLen == 0 { // 0 means that no valid STREAM frame can be written
// check that writing a minimal size STREAM frame (i.e. with 1 byte data) is actually larger than the desired size
f.Data = []byte{0}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(BeNumerically(">", i))
continue
}
f.Data = data[:int(maxDataLen)]
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(i))
}
@ -133,13 +133,13 @@ var _ = Describe("STREAM frame", func() {
if maxDataLen == 0 { // 0 means that no valid STREAM frame can be written
// check that writing a minimal size STREAM frame (i.e. with 1 byte data) is actually larger than the desired size
f.Data = []byte{0}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(BeNumerically(">", i))
continue
}
f.Data = data[:int(maxDataLen)]
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
// There's *one* pathological case, where a data length of x can be encoded into 1 byte
// but a data lengths of x+1 needs 2 bytes

View file

@ -25,7 +25,7 @@ var _ = Describe("Frame parsing", func() {
It("skips PADDING frames", func() {
b := []byte{0} // PADDING frame
b, err := (&PingFrame{}).Write(b, protocol.Version1)
b, err := (&PingFrame{}).Append(b, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
f, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -42,7 +42,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks ACK frames", func() {
f := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 0x13}}}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -57,7 +57,7 @@ var _ = Describe("Frame parsing", func() {
AckRanges: []AckRange{{Smallest: 1, Largest: 1}},
DelayTime: time.Second,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -72,7 +72,7 @@ var _ = Describe("Frame parsing", func() {
AckRanges: []AckRange{{Smallest: 1, Largest: 1}},
DelayTime: time.Second,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.EncryptionHandshake)
Expect(err).ToNot(HaveOccurred())
@ -85,7 +85,7 @@ var _ = Describe("Frame parsing", func() {
FinalSize: 0xdecafbad1234,
ErrorCode: 0x1337,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -94,7 +94,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks STOP_SENDING frames", func() {
f := &StopSendingFrame{StreamID: 0x42}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -106,7 +106,7 @@ var _ = Describe("Frame parsing", func() {
Offset: 0x1337,
Data: []byte("lorem ipsum"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -116,7 +116,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks NEW_TOKEN frames", func() {
f := &NewTokenFrame{Token: []byte("foobar")}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -131,7 +131,7 @@ var _ = Describe("Frame parsing", func() {
Fin: true,
Data: []byte("foobar"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -143,7 +143,7 @@ var _ = Describe("Frame parsing", func() {
f := &MaxDataFrame{
MaximumData: 0xcafe,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -155,7 +155,7 @@ var _ = Describe("Frame parsing", func() {
StreamID: 0xdeadbeef,
MaximumStreamData: 0xdecafbad,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -167,7 +167,7 @@ var _ = Describe("Frame parsing", func() {
Type: protocol.StreamTypeBidi,
MaxStreamNum: 0x1337,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -176,7 +176,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks DATA_BLOCKED frames", func() {
f := &DataBlockedFrame{MaximumData: 0x1234}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -188,7 +188,7 @@ var _ = Describe("Frame parsing", func() {
StreamID: 0xdeadbeef,
MaximumStreamData: 0xdead,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -200,7 +200,7 @@ var _ = Describe("Frame parsing", func() {
Type: protocol.StreamTypeBidi,
StreamLimit: 0x1234567,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -213,7 +213,7 @@ var _ = Describe("Frame parsing", func() {
ConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
StatelessResetToken: protocol.StatelessResetToken{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -222,7 +222,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks RETIRE_CONNECTION_ID frames", func() {
f := &RetireConnectionIDFrame{SequenceNumber: 0x1337}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -231,7 +231,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks PATH_CHALLENGE frames", func() {
f := &PathChallengeFrame{Data: [8]byte{1, 2, 3, 4, 5, 6, 7, 8}}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -242,7 +242,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks PATH_RESPONSE frames", func() {
f := &PathResponseFrame{Data: [8]byte{1, 2, 3, 4, 5, 6, 7, 8}}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -256,7 +256,7 @@ var _ = Describe("Frame parsing", func() {
IsApplicationError: true,
ReasonPhrase: "foobar",
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -265,7 +265,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks HANDSHAKE_DONE frames", func() {
f := &HandshakeDoneFrame{}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -274,7 +274,7 @@ var _ = Describe("Frame parsing", func() {
It("unpacks DATAGRAM frames", func() {
f := &DatagramFrame{Data: []byte("foobar")}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
frame, err := parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).ToNot(HaveOccurred())
@ -284,7 +284,7 @@ var _ = Describe("Frame parsing", func() {
It("errors when DATAGRAM frames are not supported", func() {
parser = NewFrameParser(false, protocol.Version1)
f := &DatagramFrame{Data: []byte("foobar")}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
_, err = parser.ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
Expect(err).To(MatchError(&qerr.TransportError{
@ -308,7 +308,7 @@ var _ = Describe("Frame parsing", func() {
StreamID: 0x1337,
MaximumStreamData: 0xdeadbeef,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
_, err = parser.ParseNext(bytes.NewReader(b[:len(b)-2]), protocol.Encryption1RTT)
Expect(err).To(HaveOccurred())
@ -344,7 +344,7 @@ var _ = Describe("Frame parsing", func() {
BeforeEach(func() {
framesSerialized = nil
for _, frame := range frames {
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
framesSerialized = append(framesSerialized, b)
}

View file

@ -17,7 +17,7 @@ func parseHandshakeDoneFrame(r *bytes.Reader, _ protocol.VersionNumber) (*Handsh
return &HandshakeDoneFrame{}, nil
}
func (f *HandshakeDoneFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *HandshakeDoneFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
return append(b, 0x1e), nil
}

View file

@ -26,7 +26,7 @@ var _ = Describe("HANDSHAKE_DONE frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := HandshakeDoneFrame{}
b, err := frame.Write(nil, protocol.VersionWhatever)
b, err := frame.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(Equal([]byte{0x1e}))
})

View file

@ -8,7 +8,7 @@ import (
// A Frame in QUIC
type Frame interface {
Write(b []byte, version protocol.VersionNumber) ([]byte, error)
Append(b []byte, version protocol.VersionNumber) ([]byte, error)
Length(version protocol.VersionNumber) protocol.ByteCount
}

View file

@ -28,7 +28,7 @@ func parseMaxDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxDataFrame
}
// Write writes a MAX_STREAM_DATA frame
func (f *MaxDataFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *MaxDataFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x10)
b = quicvarint.Append(b, uint64(f.MaximumData))
return b, nil

View file

@ -46,7 +46,7 @@ var _ = Describe("MAX_DATA frame", func() {
f := &MaxDataFrame{
MaximumData: 0xdeadbeefcafe,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x10}
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)

View file

@ -33,7 +33,7 @@ func parseMaxStreamDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStr
}, nil
}
func (f *MaxStreamDataFrame) Write(b []byte, version protocol.VersionNumber) ([]byte, error) {
func (f *MaxStreamDataFrame) Append(b []byte, version protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x11)
b = quicvarint.Append(b, uint64(f.StreamID))
b = quicvarint.Append(b, uint64(f.MaximumStreamData))

View file

@ -54,7 +54,7 @@ var _ = Describe("MAX_STREAM_DATA frame", func() {
expected := []byte{0x11}
expected = append(expected, encodeVarInt(0xdecafbad)...)
expected = append(expected, encodeVarInt(0xdeadbeefcafe42)...)
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(Equal(expected))
})

View file

@ -38,7 +38,7 @@ func parseMaxStreamsFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStream
return f, nil
}
func (f *MaxStreamsFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *MaxStreamsFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
switch f.Type {
case protocol.StreamTypeBidi:
b = append(b, 0x12)

View file

@ -54,7 +54,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
Type: streamType,
MaxStreamNum: protocol.MaxStreamCount,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
frame, err := parseMaxStreamsFrame(bytes.NewReader(b), protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
@ -66,7 +66,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
Type: streamType,
MaxStreamNum: protocol.MaxStreamCount + 1,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
_, err = parseMaxStreamsFrame(bytes.NewReader(b), protocol.VersionWhatever)
Expect(err).To(MatchError(fmt.Sprintf("%d exceeds the maximum stream count", protocol.MaxStreamCount+1)))
@ -80,7 +80,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
Type: protocol.StreamTypeBidi,
MaxStreamNum: 0xdeadbeef,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x12}
expected = append(expected, encodeVarInt(0xdeadbeef)...)
@ -92,7 +92,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
Type: protocol.StreamTypeUni,
MaxStreamNum: 0xdecafbad,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x13}
expected = append(expected, encodeVarInt(0xdecafbad)...)

View file

@ -60,7 +60,7 @@ func parseNewConnectionIDFrame(r *bytes.Reader, _ protocol.VersionNumber) (*NewC
return frame, nil
}
func (f *NewConnectionIDFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *NewConnectionIDFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x18)
b = quicvarint.Append(b, f.SequenceNumber)
b = quicvarint.Append(b, f.RetirePriorTo)

View file

@ -77,7 +77,7 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
ConnectionID: protocol.ConnectionID{1, 2, 3, 4, 5, 6},
StatelessResetToken: token,
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x18}
expected = append(expected, encodeVarInt(0x1337)...)
@ -96,7 +96,7 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
ConnectionID: protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8},
StatelessResetToken: token,
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(frame.Length(protocol.Version1))))
})

View file

@ -35,7 +35,7 @@ func parseNewTokenFrame(r *bytes.Reader, _ protocol.VersionNumber) (*NewTokenFra
return &NewTokenFrame{Token: token}, nil
}
func (f *NewTokenFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *NewTokenFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x7)
b = quicvarint.Append(b, uint64(len(f.Token)))
b = append(b, f.Token...)

View file

@ -50,7 +50,7 @@ var _ = Describe("NEW_TOKEN frame", func() {
It("writes a sample frame", func() {
token := "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
f := &NewTokenFrame{Token: []byte(token)}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x7}
expected = append(expected, encodeVarInt(uint64(len(token)))...)

View file

@ -26,7 +26,7 @@ func parsePathChallengeFrame(r *bytes.Reader, _ protocol.VersionNumber) (*PathCh
return frame, nil
}
func (f *PathChallengeFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *PathChallengeFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x1a)
b = append(b, f.Data[:]...)
return b, nil

View file

@ -34,7 +34,7 @@ var _ = Describe("PATH_CHALLENGE frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := PathChallengeFrame{Data: [8]byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}}
b, err := frame.Write(nil, protocol.VersionWhatever)
b, err := frame.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(Equal([]byte{0x1a, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
})

View file

@ -26,7 +26,7 @@ func parsePathResponseFrame(r *bytes.Reader, _ protocol.VersionNumber) (*PathRes
return frame, nil
}
func (f *PathResponseFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *PathResponseFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x1b)
b = append(b, f.Data[:]...)
return b, nil

View file

@ -33,7 +33,7 @@ var _ = Describe("PATH_RESPONSE frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := PathResponseFrame{Data: [8]byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}}
b, err := frame.Write(nil, protocol.VersionWhatever)
b, err := frame.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(Equal([]byte{0x1b, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
})

View file

@ -16,7 +16,7 @@ func parsePingFrame(r *bytes.Reader, _ protocol.VersionNumber) (*PingFrame, erro
return &PingFrame{}, nil
}
func (f *PingFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *PingFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
return append(b, 0x1), nil
}

View file

@ -26,7 +26,7 @@ var _ = Describe("PING frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := PingFrame{}
b, err := frame.Write(nil, protocol.VersionWhatever)
b, err := frame.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(Equal([]byte{0x1}))
})

View file

@ -44,7 +44,7 @@ func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStr
}, nil
}
func (f *ResetStreamFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *ResetStreamFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x4)
b = quicvarint.Append(b, uint64(f.StreamID))
b = quicvarint.Append(b, uint64(f.ErrorCode))

View file

@ -47,7 +47,7 @@ var _ = Describe("RESET_STREAM frame", func() {
FinalSize: 0x11223344decafbad,
ErrorCode: 0xcafe,
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x4}
expected = append(expected, encodeVarInt(0x1337)...)

View file

@ -24,7 +24,7 @@ func parseRetireConnectionIDFrame(r *bytes.Reader, _ protocol.VersionNumber) (*R
return &RetireConnectionIDFrame{SequenceNumber: seq}, nil
}
func (f *RetireConnectionIDFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *RetireConnectionIDFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x19)
b = quicvarint.Append(b, f.SequenceNumber)
return b, nil

View file

@ -36,7 +36,7 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
Context("when writing", func() {
It("writes a sample frame", func() {
frame := &RetireConnectionIDFrame{SequenceNumber: 0x1337}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x19}
expected = append(expected, encodeVarInt(0x1337)...)
@ -45,7 +45,7 @@ var _ = Describe("NEW_CONNECTION_ID frame", func() {
It("has the correct length", func() {
frame := &RetireConnectionIDFrame{SequenceNumber: 0xdecafbad}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(b).To(HaveLen(int(frame.Length(protocol.Version1))))
})

View file

@ -40,7 +40,7 @@ func (f *StopSendingFrame) Length(_ protocol.VersionNumber) protocol.ByteCount {
return 1 + quicvarint.Len(uint64(f.StreamID)) + quicvarint.Len(uint64(f.ErrorCode))
}
func (f *StopSendingFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *StopSendingFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x5)
b = quicvarint.Append(b, uint64(f.StreamID))
b = quicvarint.Append(b, uint64(f.ErrorCode))

View file

@ -44,7 +44,7 @@ var _ = Describe("STOP_SENDING frame", func() {
StreamID: 0xdeadbeefcafe,
ErrorCode: 0xdecafbad,
}
b, err := frame.Write(nil, protocol.Version1)
b, err := frame.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x5}
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)

View file

@ -33,7 +33,7 @@ func parseStreamDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*St
}, nil
}
func (f *StreamDataBlockedFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *StreamDataBlockedFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
b = append(b, 0x15)
b = quicvarint.Append(b, uint64(f.StreamID))
b = quicvarint.Append(b, uint64(f.MaximumStreamData))

View file

@ -51,7 +51,7 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
StreamID: 0xdecafbad,
MaximumStreamData: 0x1337,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x15}
expected = append(expected, encodeVarInt(uint64(f.StreamID))...)

View file

@ -84,7 +84,7 @@ func parseStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StreamFrame,
}
// Write writes a STREAM frame
func (f *StreamFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *StreamFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
if len(f.Data) == 0 && !f.Fin {
return nil, errors.New("StreamFrame: attempting to write empty frame without FIN")
}

View file

@ -145,7 +145,7 @@ var _ = Describe("STREAM frame", func() {
StreamID: 0x1337,
Data: []byte("foobar"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x8}
expected = append(expected, encodeVarInt(0x1337)...) // stream ID
@ -159,7 +159,7 @@ var _ = Describe("STREAM frame", func() {
Offset: 0x123456,
Data: []byte("foobar"),
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x8 ^ 0x4}
expected = append(expected, encodeVarInt(0x1337)...) // stream ID
@ -174,7 +174,7 @@ var _ = Describe("STREAM frame", func() {
Offset: 0x123456,
Fin: true,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x8 ^ 0x4 ^ 0x1}
expected = append(expected, encodeVarInt(0x1337)...) // stream ID
@ -188,7 +188,7 @@ var _ = Describe("STREAM frame", func() {
Data: []byte("foobar"),
DataLenPresent: true,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x8 ^ 0x2}
expected = append(expected, encodeVarInt(0x1337)...) // stream ID
@ -204,7 +204,7 @@ var _ = Describe("STREAM frame", func() {
DataLenPresent: true,
Offset: 0x123456,
}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x8 ^ 0x4 ^ 0x2}
expected = append(expected, encodeVarInt(0x1337)...) // stream ID
@ -219,7 +219,7 @@ var _ = Describe("STREAM frame", func() {
StreamID: 0x42,
Offset: 0x1337,
}
_, err := f.Write(nil, protocol.Version1)
_, err := f.Append(nil, protocol.Version1)
Expect(err).To(MatchError("StreamFrame: attempting to write empty frame without FIN"))
})
})
@ -268,13 +268,13 @@ var _ = Describe("STREAM frame", func() {
if maxDataLen == 0 { // 0 means that no valid STREAM frame can be written
// check that writing a minimal size STREAM frame (i.e. with 1 byte data) is actually larger than the desired size
f.Data = []byte{0}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(BeNumerically(">", i))
continue
}
f.Data = data[:int(maxDataLen)]
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(Equal(i))
}
@ -294,13 +294,13 @@ var _ = Describe("STREAM frame", func() {
if maxDataLen == 0 { // 0 means that no valid STREAM frame can be written
// check that writing a minimal size STREAM frame (i.e. with 1 byte data) is actually larger than the desired size
f.Data = []byte{0}
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(len(b)).To(BeNumerically(">", i))
continue
}
f.Data = data[:int(maxDataLen)]
b, err := f.Write(nil, protocol.Version1)
b, err := f.Append(nil, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
// There's *one* pathological case, where a data length of x can be encoded into 1 byte
// but a data lengths of x+1 needs 2 bytes

View file

@ -38,7 +38,7 @@ func parseStreamsBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*Strea
return f, nil
}
func (f *StreamsBlockedFrame) Write(b []byte, _ protocol.VersionNumber) ([]byte, error) {
func (f *StreamsBlockedFrame) Append(b []byte, _ protocol.VersionNumber) ([]byte, error) {
switch f.Type {
case protocol.StreamTypeBidi:
b = append(b, 0x16)

View file

@ -55,7 +55,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
Type: streamType,
StreamLimit: protocol.MaxStreamCount,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
frame, err := parseStreamsBlockedFrame(bytes.NewReader(b), protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
@ -67,7 +67,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
Type: streamType,
StreamLimit: protocol.MaxStreamCount + 1,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
_, err = parseStreamsBlockedFrame(bytes.NewReader(b), protocol.VersionWhatever)
Expect(err).To(MatchError(fmt.Sprintf("%d exceeds the maximum stream count", protocol.MaxStreamCount+1)))
@ -81,7 +81,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
Type: protocol.StreamTypeBidi,
StreamLimit: 0xdeadbeefcafe,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x16}
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)
@ -93,7 +93,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
Type: protocol.StreamTypeUni,
StreamLimit: 0xdeadbeefcafe,
}
b, err := f.Write(nil, protocol.VersionWhatever)
b, err := f.Append(nil, protocol.VersionWhatever)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x17}
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)

View file

@ -834,7 +834,7 @@ func (p *packetPacker) appendPacket(buffer *packetBuffer, header *wire.ExtendedH
if payload.ack != nil {
var err error
raw, err = payload.ack.Write(raw, p.version)
raw, err = payload.ack.Append(raw, p.version)
if err != nil {
return nil, err
}
@ -844,7 +844,7 @@ func (p *packetPacker) appendPacket(buffer *packetBuffer, header *wire.ExtendedH
}
for _, frame := range payload.frames {
var err error
raw, err = frame.Write(raw, p.version)
raw, err = frame.Append(raw, p.version)
if err != nil {
return nil, err
}

View file

@ -499,7 +499,7 @@ var _ = Describe("Packet packer", func() {
p, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
b, err := f.Write(nil, packer.version)
b, err := f.Append(nil, packer.version)
Expect(err).ToNot(HaveOccurred())
Expect(p.frames).To(Equal([]ackhandler.Frame{{Frame: f}}))
Expect(p.buffer.Data).To(ContainSubstring(string(b)))

View file

@ -640,7 +640,7 @@ func (s *baseServer) sendError(remoteAddr net.Addr, hdr *wire.Header, sealer han
payloadOffset := buf.Len()
raw := buf.Bytes()
raw, err := ccf.Write(raw, hdr.Version)
raw, err := ccf.Append(raw, hdr.Version)
if err != nil {
return err
}

View file

@ -43,7 +43,7 @@ var _ = Describe("Streams Map (incoming)", func() {
// check that the frame can be serialized and deserialized
checkFrameSerialization := func(f wire.Frame) {
b, err := f.Write(nil, protocol.VersionTLS)
b, err := f.Append(nil, protocol.VersionTLS)
ExpectWithOffset(1, err).ToNot(HaveOccurred())
frame, err := wire.NewFrameParser(false, protocol.VersionTLS).ParseNext(bytes.NewReader(b), protocol.Encryption1RTT)
ExpectWithOffset(1, err).ToNot(HaveOccurred())