forked from quic-go/quic-go
return the invalid stream ID if no streams are allowed
This commit is contained in:
@@ -5,7 +5,7 @@ type StreamID int64
|
||||
|
||||
// InvalidPacketNumber is a stream ID that is invalid.
|
||||
// The first valid stream ID in QUIC is 0.
|
||||
const InvalidStreamID = -1
|
||||
const InvalidStreamID StreamID = -1
|
||||
|
||||
// StreamType encodes if this is a unidirectional or bidirectional stream
|
||||
type StreamType uint8
|
||||
@@ -43,7 +43,7 @@ func (s StreamID) StreamNum() uint64 {
|
||||
// when it is allowed to open numStreams.
|
||||
func MaxStreamID(stype StreamType, numStreams uint64, pers Perspective) StreamID {
|
||||
if numStreams == 0 {
|
||||
return 0
|
||||
return InvalidStreamID
|
||||
}
|
||||
var first StreamID
|
||||
switch stype {
|
||||
|
||||
@@ -44,10 +44,10 @@ var _ = Describe("Stream ID", func() {
|
||||
|
||||
Context("maximum stream IDs", func() {
|
||||
It("doesn't allow any", func() {
|
||||
Expect(MaxStreamID(StreamTypeBidi, 0, PerspectiveClient)).To(Equal(StreamID(0)))
|
||||
Expect(MaxStreamID(StreamTypeBidi, 0, PerspectiveServer)).To(Equal(StreamID(0)))
|
||||
Expect(MaxStreamID(StreamTypeUni, 0, PerspectiveClient)).To(Equal(StreamID(0)))
|
||||
Expect(MaxStreamID(StreamTypeUni, 0, PerspectiveServer)).To(Equal(StreamID(0)))
|
||||
Expect(MaxStreamID(StreamTypeBidi, 0, PerspectiveClient)).To(Equal(InvalidStreamID))
|
||||
Expect(MaxStreamID(StreamTypeBidi, 0, PerspectiveServer)).To(Equal(InvalidStreamID))
|
||||
Expect(MaxStreamID(StreamTypeUni, 0, PerspectiveClient)).To(Equal(InvalidStreamID))
|
||||
Expect(MaxStreamID(StreamTypeUni, 0, PerspectiveServer)).To(Equal(InvalidStreamID))
|
||||
})
|
||||
|
||||
It("allows one", func() {
|
||||
|
||||
Reference in New Issue
Block a user