mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
use an errors.As comparison to detect stateless resets in the session
This commit is contained in:
parent
e7fa420e26
commit
1f676c2a6c
4 changed files with 29 additions and 9 deletions
|
@ -242,10 +242,12 @@ var _ = Describe("Packet Handler Map", func() {
|
|||
packet = append(packet, token[:]...)
|
||||
destroyed := make(chan struct{})
|
||||
packetHandler.EXPECT().destroy(gomock.Any()).Do(func(err error) {
|
||||
defer GinkgoRecover()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(BeAssignableToTypeOf(&statelessResetErr{}))
|
||||
var resetErr statelessResetErr
|
||||
Expect(errors.As(err, &resetErr)).To(BeTrue())
|
||||
Expect(err.Error()).To(ContainSubstring("received a stateless reset"))
|
||||
Expect(*err.(*statelessResetErr).StatelessResetToken()).To(Equal(token))
|
||||
Expect(resetErr.token).To(Equal(&token))
|
||||
close(destroyed)
|
||||
})
|
||||
conn.dataToRead <- packet
|
||||
|
@ -261,10 +263,12 @@ var _ = Describe("Packet Handler Map", func() {
|
|||
packet = append(packet, token[:]...)
|
||||
destroyed := make(chan struct{})
|
||||
packetHandler.EXPECT().destroy(gomock.Any()).Do(func(err error) {
|
||||
defer GinkgoRecover()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(BeAssignableToTypeOf(&statelessResetErr{}))
|
||||
var resetErr statelessResetErr
|
||||
Expect(errors.As(err, &resetErr)).To(BeTrue())
|
||||
Expect(err.Error()).To(ContainSubstring("received a stateless reset"))
|
||||
Expect(*err.(*statelessResetErr).StatelessResetToken()).To(Equal(token))
|
||||
Expect(resetErr.token).To(Equal(&token))
|
||||
close(destroyed)
|
||||
})
|
||||
conn.dataToRead <- packet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue