Merge pull request #1930 from lucas-clemente/invalid-stream-id

introduce invalid stream ID to simplify the outgoing streams map
This commit is contained in:
Marten Seemann
2019-05-30 18:07:39 +08:00
committed by GitHub
6 changed files with 50 additions and 54 deletions

View File

@@ -1,7 +1,11 @@
package protocol
// A StreamID in QUIC
type StreamID uint64
type StreamID int64
// InvalidPacketNumber is a stream ID that is invalid.
// The first valid stream ID in QUIC is 0.
const InvalidStreamID = -1
// StreamType encodes if this is a unidirectional or bidirectional stream
type StreamType uint8

View File

@@ -6,6 +6,10 @@ import (
)
var _ = Describe("Stream ID", func() {
It("InvalidStreamID is smaller than all valid stream IDs", func() {
Expect(InvalidStreamID).To(BeNumerically("<", 0))
})
It("says who initiated a stream", func() {
Expect(StreamID(4).InitiatedBy()).To(Equal(PerspectiveClient))
Expect(StreamID(5).InitiatedBy()).To(Equal(PerspectiveServer))

View File

@@ -38,12 +38,12 @@ var _ = Describe("Frame logging", func() {
It("logs sent frames", func() {
LogFrame(logger, &ResetStreamFrame{}, true)
Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n"))
Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID:0, ErrorCode:0x0, ByteOffset:0x0}\n"))
})
It("logs received frames", func() {
LogFrame(logger, &ResetStreamFrame{}, false)
Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n"))
Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID:0, ErrorCode:0x0, ByteOffset:0x0}\n"))
})
It("logs CRYPTO frames", func() {