From df06ee5e37d7a9b45ec4da8a7373a2087994b14e Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 14 May 2020 17:12:07 +0700 Subject: [PATCH] use the correct error code for crypto stream errors --- crypto_stream.go | 3 +-- crypto_stream_test.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crypto_stream.go b/crypto_stream.go index cb536108..292dca44 100644 --- a/crypto_stream.go +++ b/crypto_stream.go @@ -1,7 +1,6 @@ package quic import ( - "errors" "fmt" "io" @@ -81,7 +80,7 @@ func (s *cryptoStreamImpl) GetCryptoData() []byte { func (s *cryptoStreamImpl) Finish() error { if s.queue.HasMoreData() { - return errors.New("encryption level changed, but crypto stream has more data to read") + return qerr.NewError(qerr.ProtocolViolation, "encryption level changed, but crypto stream has more data to read") } s.finished = true return nil diff --git a/crypto_stream_test.go b/crypto_stream_test.go index c962587b..a4d39014 100644 --- a/crypto_stream_test.go +++ b/crypto_stream_test.go @@ -97,7 +97,7 @@ var _ = Describe("Crypto Stream", func() { Offset: 10, })).To(Succeed()) err := str.Finish() - Expect(err).To(MatchError("encryption level changed, but crypto stream has more data to read")) + Expect(err).To(MatchError("PROTOCOL_VIOLATION: encryption level changed, but crypto stream has more data to read")) }) It("works with reordered data", func() {