correctly handle errors when creating a new gQUIC key exchange

This commit is contained in:
Marten Seemann
2018-03-28 05:33:26 +07:00
parent 1f9ab3b65f
commit 48731221c0
4 changed files with 22 additions and 16 deletions

View File

@@ -3,7 +3,6 @@ package handshake
import (
"time"
"github.com/lucas-clemente/quic-go/internal/crypto"
"github.com/lucas-clemente/quic-go/internal/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -11,9 +10,11 @@ import (
var _ = Describe("Ephermal KEX", func() {
It("has a consistent KEX", func() {
kex1 := getEphermalKEX()
kex1, err := getEphermalKEX()
Expect(err).ToNot(HaveOccurred())
Expect(kex1).ToNot(BeNil())
kex2 := getEphermalKEX()
kex2, err := getEphermalKEX()
Expect(err).ToNot(HaveOccurred())
Expect(kex2).ToNot(BeNil())
Expect(kex1).To(Equal(kex2))
})
@@ -23,8 +24,12 @@ var _ = Describe("Ephermal KEX", func() {
defer func() {
kexLifetime = protocol.EphermalKeyLifetime
}()
kex := getEphermalKEX()
kex, err := getEphermalKEX()
Expect(err).ToNot(HaveOccurred())
Expect(kex).ToNot(BeNil())
Eventually(func() crypto.KeyExchange { return getEphermalKEX() }).ShouldNot(Equal(kex))
time.Sleep(kexLifetime)
kex2, err := getEphermalKEX()
Expect(err).ToNot(HaveOccurred())
Expect(kex2).ToNot(Equal(kex))
})
})