handle stream opening errors in h2quic client

This commit is contained in:
Marten Seemann
2017-02-22 15:29:18 +07:00
parent 8fd2ddf81c
commit 6f27b7f70d
3 changed files with 25 additions and 4 deletions

View File

@@ -64,8 +64,7 @@ var _ = Describe("Client", func() {
})
It("opens the header stream only after the version has been negotiated", func() {
// delete the headerStream openend in the BeforeEach
client.headerStream = nil
client.headerStream = nil // unset the headerStream openend in the BeforeEach
session.streamToOpen = headerStream
Expect(client.headerStream).To(BeNil()) // header stream not yet opened
// now start the actual test
@@ -74,6 +73,22 @@ var _ = Describe("Client", func() {
Expect(client.headerStream.StreamID()).To(Equal(protocol.StreamID(3)))
})
It("errors if it can't open the header stream", func() {
testErr := errors.New("test error")
client.headerStream = nil // unset the headerStream openend in the BeforeEach
session.streamOpenErr = testErr
client.config.ConnState(session, quic.ConnStateVersionNegotiated)
Expect(session.closed).To(BeTrue())
Expect(session.closedWithError).To(MatchError(testErr))
})
It("errors if the header stream has the wrong StreamID", func() {
session.streamToOpen = &mockStream{id: 1337}
client.config.ConnState(session, quic.ConnStateVersionNegotiated)
Expect(session.closed).To(BeTrue())
Expect(session.closedWithError).To(MatchError("h2quic Client BUG: StreamID of Header Stream is not 3"))
})
It("sets the correct crypto level", func() {
Expect(client.encryptionLevel).To(Equal(protocol.Unencrypted))
client.config.ConnState(session, quic.ConnStateSecure)