rename MaxStreamDataFrame.ByteOffset to MaximumStreamData

This commit is contained in:
Marten Seemann 2020-07-02 16:24:57 +07:00
parent f4519cfd32
commit 5466de6565
14 changed files with 43 additions and 43 deletions

View file

@ -149,12 +149,12 @@ func getFrames() []wire.Frame {
MaximumData: protocol.MaxByteCount,
},
&wire.MaxStreamDataFrame{
StreamID: protocol.StreamID(getRandomNumber()),
ByteOffset: protocol.ByteCount(getRandomNumber()),
StreamID: protocol.StreamID(getRandomNumber()),
MaximumStreamData: protocol.ByteCount(getRandomNumber()),
},
&wire.MaxStreamDataFrame{
StreamID: protocol.StreamID(getRandomNumber()),
ByteOffset: protocol.MaxByteCount,
StreamID: protocol.StreamID(getRandomNumber()),
MaximumStreamData: protocol.MaxByteCount,
},
&wire.MaxStreamsFrame{
Type: protocol.StreamTypeUni,

View file

@ -155,8 +155,8 @@ var _ = Describe("Frame parsing", func() {
It("unpacks MAX_STREAM_DATA frames", func() {
f := &MaxStreamDataFrame{
StreamID: 0xdeadbeef,
ByteOffset: 0xdecafbad,
StreamID: 0xdeadbeef,
MaximumStreamData: 0xdecafbad,
}
buf := &bytes.Buffer{}
err := f.Write(buf, versionIETFFrames)
@ -287,8 +287,8 @@ var _ = Describe("Frame parsing", func() {
It("errors on invalid frames", func() {
f := &MaxStreamDataFrame{
StreamID: 0x1337,
ByteOffset: 0xdeadbeef,
StreamID: 0x1337,
MaximumStreamData: 0xdeadbeef,
}
b := &bytes.Buffer{}
f.Write(b, versionIETFFrames)

View file

@ -38,7 +38,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) {
case *MaxDataFrame:
logger.Debugf("\t%s &wire.MaxDataFrame{MaximumData: %d}", dir, f.MaximumData)
case *MaxStreamDataFrame:
logger.Debugf("\t%s &wire.MaxStreamDataFrame{StreamID: %d, ByteOffset: %d}", dir, f.StreamID, f.ByteOffset)
logger.Debugf("\t%s &wire.MaxStreamDataFrame{StreamID: %d, MaximumStreamData: %d}", dir, f.StreamID, f.MaximumStreamData)
case *DataBlockedFrame:
logger.Debugf("\t%s &wire.DataBlockedFrame{DataLimit: %d}", dir, f.DataLimit)
case *StreamDataBlockedFrame:

View file

@ -106,11 +106,11 @@ var _ = Describe("Frame logging", func() {
It("logs MAX_STREAM_DATA frames", func() {
frame := &MaxStreamDataFrame{
StreamID: 10,
ByteOffset: 42,
StreamID: 10,
MaximumStreamData: 42,
}
LogFrame(logger, frame, false)
Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxStreamDataFrame{StreamID: 10, ByteOffset: 42}\n"))
Expect(buf.String()).To(ContainSubstring("\t<- &wire.MaxStreamDataFrame{StreamID: 10, MaximumStreamData: 42}\n"))
})
It("logs DATA_BLOCKED frames", func() {

View file

@ -9,8 +9,8 @@ import (
// A MaxStreamDataFrame is a MAX_STREAM_DATA frame
type MaxStreamDataFrame struct {
StreamID protocol.StreamID
ByteOffset protocol.ByteCount
StreamID protocol.StreamID
MaximumStreamData protocol.ByteCount
}
func parseMaxStreamDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStreamDataFrame, error) {
@ -28,19 +28,19 @@ func parseMaxStreamDataFrame(r *bytes.Reader, _ protocol.VersionNumber) (*MaxStr
}
return &MaxStreamDataFrame{
StreamID: protocol.StreamID(sid),
ByteOffset: protocol.ByteCount(offset),
StreamID: protocol.StreamID(sid),
MaximumStreamData: protocol.ByteCount(offset),
}, nil
}
func (f *MaxStreamDataFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
b.WriteByte(0x11)
utils.WriteVarInt(b, uint64(f.StreamID))
utils.WriteVarInt(b, uint64(f.ByteOffset))
utils.WriteVarInt(b, uint64(f.MaximumStreamData))
return nil
}
// Length of a written frame
func (f *MaxStreamDataFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ByteOffset))
return 1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.MaximumStreamData))
}

View file

@ -19,7 +19,7 @@ var _ = Describe("MAX_STREAM_DATA frame", func() {
frame, err := parseMaxStreamDataFrame(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x12345678)))
Expect(frame.MaximumStreamData).To(Equal(protocol.ByteCount(0x12345678)))
Expect(b.Len()).To(BeZero())
})
@ -39,17 +39,17 @@ var _ = Describe("MAX_STREAM_DATA frame", func() {
Context("writing", func() {
It("has proper min length", func() {
f := &MaxStreamDataFrame{
StreamID: 0x1337,
ByteOffset: 0xdeadbeef,
StreamID: 0x1337,
MaximumStreamData: 0xdeadbeef,
}
Expect(f.Length(protocol.VersionWhatever)).To(Equal(1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.ByteOffset))))
Expect(f.Length(protocol.VersionWhatever)).To(Equal(1 + utils.VarIntLen(uint64(f.StreamID)) + utils.VarIntLen(uint64(f.MaximumStreamData))))
})
It("writes a sample frame", func() {
b := &bytes.Buffer{}
f := &MaxStreamDataFrame{
StreamID: 0xdecafbad,
ByteOffset: 0xdeadbeefcafe42,
StreamID: 0xdecafbad,
MaximumStreamData: 0xdeadbeefcafe42,
}
expected := []byte{0x11}
expected = append(expected, encodeVarInt(0xdecafbad)...)

View file

@ -179,7 +179,7 @@ func marshalMaxDataFrame(enc *gojay.Encoder, f *wire.MaxDataFrame) {
func marshalMaxStreamDataFrame(enc *gojay.Encoder, f *wire.MaxStreamDataFrame) {
enc.StringKey("frame_type", "max_stream_data")
enc.Int64Key("stream_id", int64(f.StreamID))
enc.Int64Key("maximum", int64(f.ByteOffset))
enc.Int64Key("maximum", int64(f.MaximumStreamData))
}
func marshalMaxStreamsFrame(enc *gojay.Encoder, f *wire.MaxStreamsFrame) {

View file

@ -187,8 +187,8 @@ var _ = Describe("Frames", func() {
It("marshals MAX_STREAM_DATA frames", func() {
check(
&wire.MaxStreamDataFrame{
StreamID: 1234,
ByteOffset: 1337,
StreamID: 1234,
MaximumStreamData: 1337,
},
map[string]interface{}{
"frame_type": "max_stream_data",

View file

@ -270,7 +270,7 @@ var _ = Describe("Tracer", func() {
987,
nil,
[]wire.Frame{
&wire.MaxStreamDataFrame{StreamID: 42, ByteOffset: 987},
&wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987},
&wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true},
},
)
@ -327,7 +327,7 @@ var _ = Describe("Tracer", func() {
},
789,
[]wire.Frame{
&wire.MaxStreamDataFrame{StreamID: 42, ByteOffset: 987},
&wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987},
&wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true},
},
)

View file

@ -430,7 +430,7 @@ func (s *sendStream) handleMaxStreamDataFrame(frame *wire.MaxStreamDataFrame) {
hasStreamData := s.dataForWriting != nil || s.nextFrame != nil
s.mutex.Unlock()
s.flowController.UpdateSendWindow(frame.ByteOffset)
s.flowController.UpdateSendWindow(frame.MaximumStreamData)
if hasStreamData {
s.sender.onHasStreamData(s.streamID)
}

View file

@ -653,8 +653,8 @@ var _ = Describe("Send Stream", func() {
It("informs the flow controller", func() {
mockFC.EXPECT().UpdateSendWindow(protocol.ByteCount(0x1337))
str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{
StreamID: streamID,
ByteOffset: 0x1337,
StreamID: streamID,
MaximumStreamData: 0x1337,
})
})
@ -671,8 +671,8 @@ var _ = Describe("Send Stream", func() {
waitForWrite()
mockSender.EXPECT().onHasStreamData(streamID)
str.handleMaxStreamDataFrame(&wire.MaxStreamDataFrame{
StreamID: streamID,
ByteOffset: 42,
StreamID: streamID,
MaximumStreamData: 42,
})
// make sure the Write go routine returns
str.closeForShutdown(nil)

View file

@ -212,8 +212,8 @@ var _ = Describe("Session", func() {
It("updates the flow control window of a stream", func() {
f := &wire.MaxStreamDataFrame{
StreamID: 12345,
ByteOffset: 0x1337,
StreamID: 12345,
MaximumStreamData: 0x1337,
}
str := NewMockSendStreamI(mockCtrl)
streamManager.EXPECT().GetOrOpenSendStream(protocol.StreamID(12345)).Return(str, nil)
@ -231,8 +231,8 @@ var _ = Describe("Session", func() {
It("ignores MAX_STREAM_DATA frames for a closed stream", func() {
streamManager.EXPECT().GetOrOpenSendStream(protocol.StreamID(10)).Return(nil, nil)
Expect(sess.handleFrame(&wire.MaxStreamDataFrame{
StreamID: 10,
ByteOffset: 1337,
StreamID: 10,
MaximumStreamData: 1337,
}, protocol.EncryptionUnspecified)).To(Succeed())
})
})

View file

@ -63,8 +63,8 @@ func (q *windowUpdateQueue) QueueAll() {
continue
}
q.callback(&wire.MaxStreamDataFrame{
StreamID: id,
ByteOffset: offset,
StreamID: id,
MaximumStreamData: offset,
})
}
q.mutex.Unlock()

View file

@ -36,8 +36,8 @@ var _ = Describe("Window Update Queue", func() {
q.AddStream(3)
q.AddStream(1)
q.QueueAll()
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 1, ByteOffset: 10}))
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 3, ByteOffset: 30}))
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 1, MaximumStreamData: 10}))
Expect(queuedFrames).To(ContainElement(&wire.MaxStreamDataFrame{StreamID: 3, MaximumStreamData: 30}))
})
It("deletes the entry after getting the MAX_STREAM_DATA frame", func() {
@ -106,7 +106,7 @@ var _ = Describe("Window Update Queue", func() {
q.AddStream(10)
q.QueueAll()
Expect(queuedFrames).To(Equal([]wire.Frame{
&wire.MaxStreamDataFrame{StreamID: 10, ByteOffset: 200},
&wire.MaxStreamDataFrame{StreamID: 10, MaximumStreamData: 200},
}))
})
})