mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
return StreamErrors for all kinds of stream cancelations (#3681)
* fix: return typed errors when after cancelling actions
This is errors.Is'ed by libp2p and the fmt.Errorf messages didn't passed that test:
82315917f7/p2p/transport/quic/stream.go (L23)
* replace StreamErrorAction with a local / remote flag
Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
This commit is contained in:
parent
dfbfe71309
commit
3f9d8feab2
6 changed files with 69 additions and 27 deletions
|
@ -484,7 +484,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Context("stream cancelations", func() {
|
||||
Context("stream cancellations", func() {
|
||||
Context("canceling read", func() {
|
||||
It("unblocks Read", func() {
|
||||
mockSender.EXPECT().queueControlFrame(gomock.Any())
|
||||
|
@ -492,7 +492,11 @@ var _ = Describe("Receive Stream", func() {
|
|||
go func() {
|
||||
defer GinkgoRecover()
|
||||
_, err := strWithTimeout.Read([]byte{0})
|
||||
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
|
||||
Expect(err).To(Equal(&StreamError{
|
||||
StreamID: streamID,
|
||||
ErrorCode: 1234,
|
||||
Remote: false,
|
||||
}))
|
||||
close(done)
|
||||
}()
|
||||
Consistently(done).ShouldNot(BeClosed())
|
||||
|
@ -504,7 +508,11 @@ var _ = Describe("Receive Stream", func() {
|
|||
mockSender.EXPECT().queueControlFrame(gomock.Any())
|
||||
str.CancelRead(1234)
|
||||
_, err := strWithTimeout.Read([]byte{0})
|
||||
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
|
||||
Expect(err).To(Equal(&StreamError{
|
||||
StreamID: streamID,
|
||||
ErrorCode: 1234,
|
||||
Remote: false,
|
||||
}))
|
||||
})
|
||||
|
||||
It("does nothing when CancelRead is called twice", func() {
|
||||
|
@ -512,7 +520,11 @@ var _ = Describe("Receive Stream", func() {
|
|||
str.CancelRead(1234)
|
||||
str.CancelRead(1234)
|
||||
_, err := strWithTimeout.Read([]byte{0})
|
||||
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
|
||||
Expect(err).To(Equal(&StreamError{
|
||||
StreamID: streamID,
|
||||
ErrorCode: 1234,
|
||||
Remote: false,
|
||||
}))
|
||||
})
|
||||
|
||||
It("queues a STOP_SENDING frame", func() {
|
||||
|
@ -609,9 +621,10 @@ var _ = Describe("Receive Stream", func() {
|
|||
go func() {
|
||||
defer GinkgoRecover()
|
||||
_, err := strWithTimeout.Read([]byte{0})
|
||||
Expect(err).To(MatchError(&StreamError{
|
||||
Expect(err).To(Equal(&StreamError{
|
||||
StreamID: streamID,
|
||||
ErrorCode: 1234,
|
||||
Remote: true,
|
||||
}))
|
||||
close(done)
|
||||
}()
|
||||
|
@ -668,7 +681,7 @@ var _ = Describe("Receive Stream", func() {
|
|||
Expect(str.handleResetStreamFrame(rst)).To(Succeed())
|
||||
})
|
||||
|
||||
It("doesn't do anyting when it was closed for shutdown", func() {
|
||||
It("doesn't do anything when it was closed for shutdown", func() {
|
||||
str.closeForShutdown(nil)
|
||||
err := str.handleResetStreamFrame(rst)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue