forked from quic-go/quic-go
Merge pull request #2208 from lucas-clemente/fix-stream-deletion-errors
fix error message for stream deletion errors
This commit is contained in:
@@ -139,14 +139,14 @@ func (m *streamsMap) DeleteStream(id protocol.StreamID) error {
|
||||
switch id.Type() {
|
||||
case protocol.StreamTypeUni:
|
||||
if id.InitiatedBy() == m.perspective {
|
||||
return m.outgoingUniStreams.DeleteStream(num)
|
||||
return convertStreamError(m.outgoingUniStreams.DeleteStream(num), protocol.StreamTypeUni, m.perspective)
|
||||
}
|
||||
return m.incomingUniStreams.DeleteStream(num)
|
||||
return convertStreamError(m.incomingUniStreams.DeleteStream(num), protocol.StreamTypeUni, m.perspective.Opposite())
|
||||
case protocol.StreamTypeBidi:
|
||||
if id.InitiatedBy() == m.perspective {
|
||||
return m.outgoingBidiStreams.DeleteStream(num)
|
||||
return convertStreamError(m.outgoingBidiStreams.DeleteStream(num), protocol.StreamTypeBidi, m.perspective)
|
||||
}
|
||||
return m.incomingBidiStreams.DeleteStream(num)
|
||||
return convertStreamError(m.incomingBidiStreams.DeleteStream(num), protocol.StreamTypeBidi, m.perspective.Opposite())
|
||||
}
|
||||
panic("")
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (m *incomingBidiStreamsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
func (m *incomingBidiStreamsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown incoming stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (m *incomingBidiStreamsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if num >= m.nextStreamToAccept {
|
||||
if _, ok := m.streamsToDelete[num]; ok {
|
||||
return streamError{
|
||||
message: "Tried to delete stream %d multiple times",
|
||||
message: "Tried to delete incoming stream %d multiple times",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func (m *incomingItemsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
func (m *incomingItemsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown incoming stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func (m *incomingItemsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if num >= m.nextStreamToAccept {
|
||||
if _, ok := m.streamsToDelete[num]; ok {
|
||||
return streamError{
|
||||
message: "Tried to delete stream %d multiple times",
|
||||
message: "Tried to delete incoming stream %d multiple times",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ var _ = Describe("Streams Map (incoming)", func() {
|
||||
It("errors when deleting a non-existing stream", func() {
|
||||
err := m.DeleteStream(1337)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown stream 1337"))
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown incoming stream 1337"))
|
||||
})
|
||||
|
||||
It("sends MAX_STREAMS frames when streams are deleted", func() {
|
||||
|
||||
@@ -139,7 +139,7 @@ func (m *incomingUniStreamsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
func (m *incomingUniStreamsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown incoming stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (m *incomingUniStreamsMap) deleteStream(num protocol.StreamNum) error {
|
||||
if num >= m.nextStreamToAccept {
|
||||
if _, ok := m.streamsToDelete[num]; ok {
|
||||
return streamError{
|
||||
message: "Tried to delete stream %d multiple times",
|
||||
message: "Tried to delete incoming stream %d multiple times",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func (m *outgoingBidiStreamsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown outgoing stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ func (m *outgoingItemsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown outgoing stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ var _ = Describe("Streams Map (outgoing)", func() {
|
||||
It("errors when deleting a non-existing stream", func() {
|
||||
err := m.DeleteStream(1337)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown stream 1337"))
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown outgoing stream 1337"))
|
||||
})
|
||||
|
||||
It("errors when deleting a stream twice", func() {
|
||||
@@ -83,7 +83,7 @@ var _ = Describe("Streams Map (outgoing)", func() {
|
||||
Expect(m.DeleteStream(1)).To(Succeed())
|
||||
err = m.DeleteStream(1)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown stream 1"))
|
||||
Expect(err.(streamError).TestError()).To(MatchError("Tried to delete unknown outgoing stream 1"))
|
||||
})
|
||||
|
||||
It("closes all streams when CloseWithError is called", func() {
|
||||
|
||||
@@ -155,7 +155,7 @@ func (m *outgoingUniStreamsMap) DeleteStream(num protocol.StreamNum) error {
|
||||
|
||||
if _, ok := m.streams[num]; !ok {
|
||||
return streamError{
|
||||
message: "Tried to delete unknown stream %d",
|
||||
message: "Tried to delete unknown outgoing stream %d",
|
||||
nums: []protocol.StreamNum{num},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +209,26 @@ var _ = Describe("Streams Map", func() {
|
||||
Expect(str).ToNot(BeNil())
|
||||
Expect(str.StreamID()).To(Equal(id))
|
||||
})
|
||||
|
||||
It("errors when deleting unknown incoming unidirectional streams", func() {
|
||||
id := ids.firstIncomingUniStream + 4
|
||||
Expect(m.DeleteStream(id)).To(MatchError(fmt.Sprintf("Tried to delete unknown incoming stream %d", id)))
|
||||
})
|
||||
|
||||
It("errors when deleting unknown outgoing unidirectional streams", func() {
|
||||
id := ids.firstOutgoingUniStream + 4
|
||||
Expect(m.DeleteStream(id)).To(MatchError(fmt.Sprintf("Tried to delete unknown outgoing stream %d", id)))
|
||||
})
|
||||
|
||||
It("errors when deleting unknown incoming bidirectional streams", func() {
|
||||
id := ids.firstIncomingBidiStream + 4
|
||||
Expect(m.DeleteStream(id)).To(MatchError(fmt.Sprintf("Tried to delete unknown incoming stream %d", id)))
|
||||
})
|
||||
|
||||
It("errors when deleting unknown outgoing bidirectional streams", func() {
|
||||
id := ids.firstOutgoingBidiStream + 4
|
||||
Expect(m.DeleteStream(id)).To(MatchError(fmt.Sprintf("Tried to delete unknown outgoing stream %d", id)))
|
||||
})
|
||||
})
|
||||
|
||||
Context("getting streams", func() {
|
||||
|
||||
Reference in New Issue
Block a user