From 13a25a5ba5f8becd0018ada1a228d1eca97de09c Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 1 Jun 2017 20:02:57 +0200 Subject: [PATCH] use the correct error code for handshake timeouts --- session.go | 2 +- session_test.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/session.go b/session.go index 01b0860c..564ce6f5 100644 --- a/session.go +++ b/session.go @@ -328,7 +328,7 @@ runLoop: s.close(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity.")) } if !s.handshakeComplete && now.Sub(s.sessionCreationTime) >= s.config.HandshakeTimeout { - s.close(qerr.Error(qerr.NetworkIdleTimeout, "Crypto handshake did not complete in time.")) + s.close(qerr.Error(qerr.HandshakeTimeout, "Crypto handshake did not complete in time.")) } s.garbageCollectStreams() } diff --git a/session_test.go b/session_test.go index 8f523a42..01aa02cc 100644 --- a/session_test.go +++ b/session_test.go @@ -1396,7 +1396,8 @@ var _ = Describe("Session", func() { Context("timeouts", func() { It("times out due to no network activity", func(done Done) { sess.lastNetworkActivityTime = time.Now().Add(-time.Hour) - sess.run() // Would normally not return + err := sess.run() // Would normally not return + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.NetworkIdleTimeout)) Expect(mconn.written[0]).To(ContainSubstring("No recent network activity.")) Expect(sess.runClosed).To(BeClosed()) close(done) @@ -1404,7 +1405,8 @@ var _ = Describe("Session", func() { It("times out due to non-completed crypto handshake", func(done Done) { sess.sessionCreationTime = time.Now().Add(-protocol.DefaultHandshakeTimeout).Add(-time.Second) - sess.run() // Would normally not return + err := sess.run() // Would normally not return + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.HandshakeTimeout)) Expect(mconn.written[0]).To(ContainSubstring("Crypto handshake did not complete in time.")) Expect(sess.runClosed).To(BeClosed()) close(done) @@ -1414,7 +1416,8 @@ var _ = Describe("Session", func() { sess.lastNetworkActivityTime = time.Now().Add(-time.Minute) cpm.idleTime = 99999 * time.Second sess.packer.connectionParameters = sess.connectionParameters - sess.run() // Would normally not return + err := sess.run() // Would normally not return + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.NetworkIdleTimeout)) Expect(mconn.written[0]).To(ContainSubstring("No recent network activity.")) Expect(sess.runClosed).To(BeClosed()) close(done) @@ -1424,7 +1427,8 @@ var _ = Describe("Session", func() { close(aeadChanged) cpm.idleTime = 0 * time.Millisecond sess.packer.connectionParameters = sess.connectionParameters - sess.run() // Would normally not return + err := sess.run() // Would normally not return + Expect(err.(*qerr.QuicError).ErrorCode).To(Equal(qerr.NetworkIdleTimeout)) Expect(mconn.written[0]).To(ContainSubstring("No recent network activity.")) Expect(sess.runClosed).To(BeClosed()) close(done)