introduce a logging.CloseReason for version negotiation errors

This commit is contained in:
Marten Seemann
2021-03-15 13:20:23 +08:00
parent 3bce408c8d
commit 5208845191
5 changed files with 55 additions and 6 deletions

View File

@@ -2630,9 +2630,12 @@ var _ = Describe("Client Session", func() {
errChan <- sess.run()
}()
sessionRunner.EXPECT().Remove(srcConnID).MaxTimes(1)
var closeReason logging.CloseReason
gomock.InOrder(
tracer.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any(), gomock.Any()),
tracer.EXPECT().ClosedConnection(gomock.Any()),
tracer.EXPECT().ClosedConnection(gomock.Any()).Do(func(r logging.CloseReason) {
closeReason = r
}),
tracer.EXPECT().Close(),
)
cryptoSetup.EXPECT().Close()
@@ -2641,7 +2644,10 @@ var _ = Describe("Client Session", func() {
Eventually(errChan).Should(Receive(&err))
Expect(err).To(HaveOccurred())
Expect(err).ToNot(BeAssignableToTypeOf(&errCloseForRecreating{}))
Expect(err.Error()).To(ContainSubstring("No compatible QUIC version found"))
Expect(err.Error()).To(ContainSubstring("no compatible QUIC version found"))
vns, ok := closeReason.VersionNegotiation()
Expect(ok).To(BeTrue())
Expect(vns).To(ContainElement(logging.VersionNumber(12345678)))
})
It("ignores Version Negotiation packets that offer the current version", func() {