Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test case for server sending GOAWAY before opening a stream #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions spec/h2_stream_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe("http.h2_stream", function()
local cqueues = require "cqueues"
local ca = require "cqueues.auxlib"
local cs = require "cqueues.socket"
local cc = require "cqueues.condition"
local function new_pair()
local s, c = ca.assert(cs.pair())
s = assert(h2_connection.new(s, "server"))
Expand Down Expand Up @@ -265,4 +266,27 @@ describe("http.h2_stream", function()
assert.truthy(cq:empty())
end)
end)
it("errors when a server sends goaway before a stream is opened", function()
local s, c = new_pair()
local cq = cqueues.new()
local cond = cc.new()
local req_headers = new_headers()
req_headers:append(":method", "GET")
req_headers:append(":scheme", "http")
req_headers:append(":path", "/")
cq:wrap(function()
assert(cond:wait())
local stream = c:new_stream()
assert.falsy(stream)
Comment on lines +279 to +280
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should assert the particular error you get

end)
cq:wrap(function()
-- ensure client coroutine runs first
cqueues.sleep(0.1)
assert(s:write_goaway_frame(nil,h2_error.errors.INTERNAL_ERROR.code))
cond:signal(1)
end)
assert_loop(cq, TEST_TIMEOUT)
s:close()
c:close()
end)
end)