diff --git a/streams_map.go b/streams_map.go index 4dc8fc313..6559adae5 100644 --- a/streams_map.go +++ b/streams_map.go @@ -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("") } diff --git a/streams_map_test.go b/streams_map_test.go index 7ab5bf7de..701cb63e2 100644 --- a/streams_map_test.go +++ b/streams_map_test.go @@ -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 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 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 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 stream %d", id))) + }) }) Context("getting streams", func() {