mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
return ackhandler.Frames from sendStream.popStreamFrame
This commit is contained in:
parent
e622207822
commit
0edb3f2b93
7 changed files with 89 additions and 64 deletions
|
@ -63,7 +63,8 @@ var _ = Describe("Send Stream", func() {
|
|||
close(done)
|
||||
}()
|
||||
waitForWrite()
|
||||
f, _ := str.popStreamFrame(1000)
|
||||
frame, _ := str.popStreamFrame(1000)
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("foobar")))
|
||||
Expect(f.FinBit).To(BeFalse())
|
||||
Expect(f.Offset).To(BeZero())
|
||||
|
@ -87,12 +88,14 @@ var _ = Describe("Send Stream", func() {
|
|||
close(done)
|
||||
}()
|
||||
waitForWrite()
|
||||
f, _ := str.popStreamFrame(3 + frameHeaderLen)
|
||||
frame, _ := str.popStreamFrame(3 + frameHeaderLen)
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("foo")))
|
||||
Expect(f.FinBit).To(BeFalse())
|
||||
Expect(f.Offset).To(BeZero())
|
||||
Expect(f.DataLenPresent).To(BeTrue())
|
||||
f, _ = str.popStreamFrame(100)
|
||||
frame, _ = str.popStreamFrame(100)
|
||||
f = frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("bar")))
|
||||
Expect(f.FinBit).To(BeFalse())
|
||||
Expect(f.Offset).To(Equal(protocol.ByteCount(3)))
|
||||
|
@ -148,9 +151,11 @@ var _ = Describe("Send Stream", func() {
|
|||
}()
|
||||
waitForWrite()
|
||||
frame, _ := str.popStreamFrame(frameHeaderSize + 1)
|
||||
Expect(frame.Data).To(Equal([]byte("f")))
|
||||
f, _ := str.popStreamFrame(100)
|
||||
Expect(f).ToNot(BeNil())
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("f")))
|
||||
frame, _ = str.popStreamFrame(100)
|
||||
Expect(frame).ToNot(BeNil())
|
||||
f = frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("oo")))
|
||||
s[1] = 'e'
|
||||
Expect(f.Data).To(Equal([]byte("oo")))
|
||||
|
@ -292,7 +297,7 @@ var _ = Describe("Send Stream", func() {
|
|||
Expect(frame).ToNot(BeNil())
|
||||
Expect(hasMoreData).To(BeTrue())
|
||||
Eventually(writeReturned, scaleDuration(80*time.Millisecond)).Should(BeClosed())
|
||||
Expect(n).To(BeEquivalentTo(frame.DataLen()))
|
||||
Expect(n).To(BeEquivalentTo(frame.Frame.(*wire.StreamFrame).DataLen()))
|
||||
})
|
||||
|
||||
It("doesn't pop any data after the deadline expired", func() {
|
||||
|
@ -402,7 +407,8 @@ var _ = Describe("Send Stream", func() {
|
|||
mockSender.EXPECT().onHasStreamData(streamID)
|
||||
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||
str.Close()
|
||||
f, hasMoreData := str.popStreamFrame(1000)
|
||||
frame, hasMoreData := str.popStreamFrame(1000)
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f).ToNot(BeNil())
|
||||
Expect(f.Data).To(BeEmpty())
|
||||
Expect(f.FinBit).To(BeTrue())
|
||||
|
@ -416,12 +422,14 @@ var _ = Describe("Send Stream", func() {
|
|||
mockFC.EXPECT().AddBytesSent(gomock.Any()).Times(2)
|
||||
str.dataForWriting = []byte("foobar")
|
||||
Expect(str.Close()).To(Succeed())
|
||||
f, _ := str.popStreamFrame(3 + frameHeaderLen)
|
||||
frame, _ := str.popStreamFrame(3 + frameHeaderLen)
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f).ToNot(BeNil())
|
||||
Expect(f.Data).To(Equal([]byte("foo")))
|
||||
Expect(f.FinBit).To(BeFalse())
|
||||
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||
f, _ = str.popStreamFrame(100)
|
||||
frame, _ = str.popStreamFrame(100)
|
||||
f = frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Data).To(Equal([]byte("bar")))
|
||||
Expect(f.FinBit).To(BeTrue())
|
||||
})
|
||||
|
@ -437,12 +445,13 @@ var _ = Describe("Send Stream", func() {
|
|||
mockSender.EXPECT().onHasStreamData(streamID)
|
||||
mockSender.EXPECT().onStreamCompleted(streamID)
|
||||
str.Close()
|
||||
f, _ := str.popStreamFrame(1000)
|
||||
frame, _ := str.popStreamFrame(1000)
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f).ToNot(BeNil())
|
||||
Expect(f.Data).To(BeEmpty())
|
||||
Expect(f.FinBit).To(BeTrue())
|
||||
f, hasMoreData := str.popStreamFrame(1000)
|
||||
Expect(f).To(BeNil())
|
||||
frame, hasMoreData := str.popStreamFrame(1000)
|
||||
Expect(frame).To(BeNil())
|
||||
Expect(hasMoreData).To(BeFalse())
|
||||
})
|
||||
})
|
||||
|
@ -550,7 +559,7 @@ var _ = Describe("Send Stream", func() {
|
|||
Expect(frame).ToNot(BeNil())
|
||||
str.CancelWrite(1234)
|
||||
Eventually(writeReturned).Should(BeClosed())
|
||||
Expect(n).To(BeEquivalentTo(frame.DataLen()))
|
||||
Expect(n).To(BeEquivalentTo(frame.Frame.(*wire.StreamFrame).DataLen()))
|
||||
})
|
||||
|
||||
It("doesn't pop STREAM frames after being canceled", func() {
|
||||
|
@ -670,30 +679,33 @@ var _ = Describe("Send Stream", func() {
|
|||
str.queueRetransmission(f)
|
||||
frame, _ := str.popStreamFrame(protocol.MaxByteCount)
|
||||
Expect(frame).ToNot(BeNil())
|
||||
Expect(frame.Offset).To(Equal(protocol.ByteCount(0x42)))
|
||||
Expect(frame.Data).To(Equal([]byte("foobar")))
|
||||
Expect(frame.DataLenPresent).To(BeTrue())
|
||||
f = frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Offset).To(Equal(protocol.ByteCount(0x42)))
|
||||
Expect(f.Data).To(Equal([]byte("foobar")))
|
||||
Expect(f.DataLenPresent).To(BeTrue())
|
||||
})
|
||||
|
||||
It("splits a retransmission", func() {
|
||||
f := &wire.StreamFrame{
|
||||
sf := &wire.StreamFrame{
|
||||
Data: []byte("foobar"),
|
||||
Offset: 0x42,
|
||||
DataLenPresent: false,
|
||||
}
|
||||
mockSender.EXPECT().onHasStreamData(streamID)
|
||||
str.queueRetransmission(f)
|
||||
frame, hasMoreData := str.popStreamFrame(f.Length(str.version) - 3)
|
||||
Expect(hasMoreData).To(BeTrue())
|
||||
str.queueRetransmission(sf)
|
||||
frame, hasMoreData := str.popStreamFrame(sf.Length(str.version) - 3)
|
||||
Expect(frame).ToNot(BeNil())
|
||||
Expect(frame.Offset).To(Equal(protocol.ByteCount(0x42)))
|
||||
Expect(frame.Data).To(Equal([]byte("foo")))
|
||||
Expect(frame.DataLenPresent).To(BeTrue())
|
||||
f := frame.Frame.(*wire.StreamFrame)
|
||||
Expect(hasMoreData).To(BeTrue())
|
||||
Expect(f.Offset).To(Equal(protocol.ByteCount(0x42)))
|
||||
Expect(f.Data).To(Equal([]byte("foo")))
|
||||
Expect(f.DataLenPresent).To(BeTrue())
|
||||
frame, _ = str.popStreamFrame(protocol.MaxByteCount)
|
||||
Expect(frame).ToNot(BeNil())
|
||||
Expect(frame.Offset).To(Equal(protocol.ByteCount(0x45)))
|
||||
Expect(frame.Data).To(Equal([]byte("bar")))
|
||||
Expect(frame.DataLenPresent).To(BeTrue())
|
||||
f = frame.Frame.(*wire.StreamFrame)
|
||||
Expect(f.Offset).To(Equal(protocol.ByteCount(0x45)))
|
||||
Expect(f.Data).To(Equal([]byte("bar")))
|
||||
Expect(f.DataLenPresent).To(BeTrue())
|
||||
})
|
||||
|
||||
It("returns nil if the size is too small", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue