rename StreamDataBlockedFrame.DataLimit to MaximumStreamData

This commit is contained in:
Marten Seemann 2020-07-02 16:28:23 +07:00
parent fa07078d81
commit cc340b2887
10 changed files with 31 additions and 31 deletions

View file

@ -171,12 +171,12 @@ func getFrames() []wire.Frame {
MaximumData: protocol.MaxByteCount,
},
&wire.StreamDataBlockedFrame{
StreamID: protocol.StreamID(getRandomNumber()),
DataLimit: protocol.ByteCount(getRandomNumber()),
StreamID: protocol.StreamID(getRandomNumber()),
MaximumStreamData: protocol.ByteCount(getRandomNumber()),
},
&wire.StreamDataBlockedFrame{
StreamID: protocol.StreamID(getRandomNumber()),
DataLimit: protocol.MaxByteCount,
StreamID: protocol.StreamID(getRandomNumber()),
MaximumStreamData: protocol.MaxByteCount,
},
&wire.StreamsBlockedFrame{
Type: protocol.StreamTypeUni,

View file

@ -191,8 +191,8 @@ var _ = Describe("Frame parsing", func() {
It("unpacks STREAM_DATA_BLOCKED frames", func() {
f := &StreamDataBlockedFrame{
StreamID: 0xdeadbeef,
DataLimit: 0xdead,
StreamID: 0xdeadbeef,
MaximumStreamData: 0xdead,
}
err := f.Write(buf, versionIETFFrames)
Expect(err).ToNot(HaveOccurred())

View file

@ -42,7 +42,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) {
case *DataBlockedFrame:
logger.Debugf("\t%s &wire.DataBlockedFrame{MaximumData: %d}", dir, f.MaximumData)
case *StreamDataBlockedFrame:
logger.Debugf("\t%s &wire.StreamDataBlockedFrame{StreamID: %d, DataLimit: %d}", dir, f.StreamID, f.DataLimit)
logger.Debugf("\t%s &wire.StreamDataBlockedFrame{StreamID: %d, MaximumStreamData: %d}", dir, f.StreamID, f.MaximumStreamData)
case *MaxStreamsFrame:
switch f.Type {
case protocol.StreamTypeUni:

View file

@ -123,11 +123,11 @@ var _ = Describe("Frame logging", func() {
It("logs STREAM_DATA_BLOCKED frames", func() {
frame := &StreamDataBlockedFrame{
StreamID: 42,
DataLimit: 1000,
StreamID: 42,
MaximumStreamData: 1000,
}
LogFrame(logger, frame, false)
Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamDataBlockedFrame{StreamID: 42, DataLimit: 1000}\n"))
Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamDataBlockedFrame{StreamID: 42, MaximumStreamData: 1000}\n"))
})
It("logs STREAMS_BLOCKED frames", func() {

View file

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

View file

@ -20,7 +20,7 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
frame, err := parseStreamDataBlockedFrame(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
Expect(frame.DataLimit).To(Equal(protocol.ByteCount(0xdecafbad)))
Expect(frame.MaximumStreamData).To(Equal(protocol.ByteCount(0xdecafbad)))
Expect(b.Len()).To(BeZero())
})
@ -40,8 +40,8 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
Context("writing", func() {
It("has proper min length", func() {
f := &StreamDataBlockedFrame{
StreamID: 0x1337,
DataLimit: 0xdeadbeef,
StreamID: 0x1337,
MaximumStreamData: 0xdeadbeef,
}
Expect(f.Length(0)).To(Equal(1 + utils.VarIntLen(0x1337) + utils.VarIntLen(0xdeadbeef)))
})
@ -49,14 +49,14 @@ var _ = Describe("STREAM_DATA_BLOCKED frame", func() {
It("writes a sample frame", func() {
b := &bytes.Buffer{}
f := &StreamDataBlockedFrame{
StreamID: 0xdecafbad,
DataLimit: 0x1337,
StreamID: 0xdecafbad,
MaximumStreamData: 0x1337,
}
err := f.Write(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred())
expected := []byte{0x15}
expected = append(expected, encodeVarInt(uint64(f.StreamID))...)
expected = append(expected, encodeVarInt(uint64(f.DataLimit))...)
expected = append(expected, encodeVarInt(uint64(f.MaximumStreamData))...)
Expect(b.Bytes()).To(Equal(expected))
})
})

View file

@ -196,7 +196,7 @@ func marshalDataBlockedFrame(enc *gojay.Encoder, f *wire.DataBlockedFrame) {
func marshalStreamDataBlockedFrame(enc *gojay.Encoder, f *wire.StreamDataBlockedFrame) {
enc.StringKey("frame_type", "stream_data_blocked")
enc.Int64Key("stream_id", int64(f.StreamID))
enc.Int64Key("limit", int64(f.DataLimit))
enc.Int64Key("limit", int64(f.MaximumStreamData))
}
func marshalStreamsBlockedFrame(enc *gojay.Encoder, f *wire.StreamsBlockedFrame) {

View file

@ -227,8 +227,8 @@ var _ = Describe("Frames", func() {
It("marshals STREAM_DATA_BLOCKED frames", func() {
check(
&wire.StreamDataBlockedFrame{
StreamID: 42,
DataLimit: 1337,
StreamID: 42,
MaximumStreamData: 1337,
},
map[string]interface{}{
"frame_type": "stream_data_blocked",

View file

@ -242,8 +242,8 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
if sendWindow == 0 {
if isBlocked, offset := s.flowController.IsNewlyBlocked(); isBlocked {
s.sender.queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: s.streamID,
DataLimit: offset,
StreamID: s.streamID,
MaximumStreamData: offset,
})
return nil, false
}

View file

@ -311,8 +311,8 @@ var _ = Describe("Send Stream", func() {
mockFC.EXPECT().SendWindowSize().Return(protocol.ByteCount(0))
mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(12))
mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: streamID,
DataLimit: 12,
StreamID: streamID,
MaximumStreamData: 12,
})
done := make(chan struct{})
go func() {
@ -354,8 +354,8 @@ var _ = Describe("Send Stream", func() {
// don't use offset 3 here, to make sure the BLOCKED frame contains the number returned by the flow controller
mockFC.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(10))
mockSender.EXPECT().queueControlFrame(&wire.StreamDataBlockedFrame{
StreamID: streamID,
DataLimit: 10,
StreamID: streamID,
MaximumStreamData: 10,
})
f, hasMoreData = str.popStreamFrame(1000)
Expect(f).To(BeNil())