mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
implement handling of MAX_STREAM_ID frames
This commit is contained in:
parent
cd4bcda458
commit
46e20ce8c9
11 changed files with 350 additions and 53 deletions
|
@ -5,8 +5,10 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/flowcontrol"
|
||||
"github.com/lucas-clemente/quic-go/internal/handshake"
|
||||
"github.com/lucas-clemente/quic-go/internal/mocks"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||
"github.com/lucas-clemente/quic-go/qerr"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -50,12 +52,20 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
|
|||
Context(perspective.String(), func() {
|
||||
var m *streamsMap
|
||||
|
||||
allowUnlimitedStreams := func() {
|
||||
m.UpdateLimits(&handshake.TransportParameters{
|
||||
MaxBidiStreamID: 0xffffffff,
|
||||
MaxUniStreamID: 0xffffffff,
|
||||
})
|
||||
}
|
||||
|
||||
BeforeEach(func() {
|
||||
m = newStreamsMap(nil, newFlowController, perspective, versionIETFFrames).(*streamsMap)
|
||||
})
|
||||
|
||||
Context("opening", func() {
|
||||
It("opens bidirectional streams", func() {
|
||||
allowUnlimitedStreams()
|
||||
str, err := m.OpenStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str).To(BeAssignableToTypeOf(&stream{}))
|
||||
|
@ -67,6 +77,7 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
|
|||
})
|
||||
|
||||
It("opens unidirectional streams", func() {
|
||||
allowUnlimitedStreams()
|
||||
str, err := m.OpenUniStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str).To(BeAssignableToTypeOf(&sendStream{}))
|
||||
|
@ -99,6 +110,10 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
|
|||
})
|
||||
|
||||
Context("deleting", func() {
|
||||
BeforeEach(func() {
|
||||
allowUnlimitedStreams()
|
||||
})
|
||||
|
||||
It("deletes outgoing bidirectional streams", func() {
|
||||
id := ids.firstOutgoingBidiStream
|
||||
str, err := m.OpenStream()
|
||||
|
@ -145,6 +160,10 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
|
|||
})
|
||||
|
||||
Context("getting streams", func() {
|
||||
BeforeEach(func() {
|
||||
allowUnlimitedStreams()
|
||||
})
|
||||
|
||||
Context("send streams", func() {
|
||||
It("gets an outgoing bidirectional stream", func() {
|
||||
// need to open the stream ourselves first
|
||||
|
@ -231,6 +250,62 @@ var _ = Describe("Streams Map (for IETF QUIC)", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("updating stream ID limits", func() {
|
||||
It("processes the parameter for outgoing bidirectional streams", func() {
|
||||
_, err := m.OpenStream()
|
||||
Expect(err).To(MatchError(qerr.TooManyOpenStreams))
|
||||
m.UpdateLimits(&handshake.TransportParameters{
|
||||
MaxBidiStreamID: ids.firstOutgoingBidiStream,
|
||||
})
|
||||
str, err := m.OpenStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.StreamID()).To(Equal(ids.firstOutgoingBidiStream))
|
||||
})
|
||||
|
||||
It("processes the parameter for outgoing bidirectional streams", func() {
|
||||
_, err := m.OpenUniStream()
|
||||
Expect(err).To(MatchError(qerr.TooManyOpenStreams))
|
||||
m.UpdateLimits(&handshake.TransportParameters{
|
||||
MaxUniStreamID: ids.firstOutgoingUniStream,
|
||||
})
|
||||
str, err := m.OpenUniStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.StreamID()).To(Equal(ids.firstOutgoingUniStream))
|
||||
})
|
||||
})
|
||||
|
||||
Context("handling MAX_STREAM_ID frames", func() {
|
||||
It("processes IDs for outgoing bidirectional streams", func() {
|
||||
_, err := m.OpenStream()
|
||||
Expect(err).To(MatchError(qerr.TooManyOpenStreams))
|
||||
err = m.HandleMaxStreamIDFrame(&wire.MaxStreamIDFrame{StreamID: ids.firstOutgoingBidiStream})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str, err := m.OpenStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.StreamID()).To(Equal(ids.firstOutgoingBidiStream))
|
||||
})
|
||||
|
||||
It("processes IDs for outgoing bidirectional streams", func() {
|
||||
_, err := m.OpenUniStream()
|
||||
Expect(err).To(MatchError(qerr.TooManyOpenStreams))
|
||||
err = m.HandleMaxStreamIDFrame(&wire.MaxStreamIDFrame{StreamID: ids.firstOutgoingUniStream})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str, err := m.OpenUniStream()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(str.StreamID()).To(Equal(ids.firstOutgoingUniStream))
|
||||
})
|
||||
|
||||
It("rejects IDs for incoming bidirectional streams", func() {
|
||||
err := m.HandleMaxStreamIDFrame(&wire.MaxStreamIDFrame{StreamID: ids.firstIncomingBidiStream})
|
||||
Expect(err).To(MatchError(fmt.Sprintf("received MAX_STREAM_DATA frame for incoming stream %d", ids.firstIncomingBidiStream)))
|
||||
})
|
||||
|
||||
It("rejects IDs for incoming unidirectional streams", func() {
|
||||
err := m.HandleMaxStreamIDFrame(&wire.MaxStreamIDFrame{StreamID: ids.firstIncomingUniStream})
|
||||
Expect(err).To(MatchError(fmt.Sprintf("received MAX_STREAM_DATA frame for incoming stream %d", ids.firstIncomingUniStream)))
|
||||
})
|
||||
})
|
||||
|
||||
It("closes", func() {
|
||||
testErr := errors.New("test error")
|
||||
m.CloseWithError(testErr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue