-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathconnection_test.exs
More file actions
30 lines (22 loc) · 914 Bytes
/
connection_test.exs
File metadata and controls
30 lines (22 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defmodule Kadabra.ConnectionTest do
use ExUnit.Case
test "closes active streams on socket close" do
uri = 'https://http2.codedge.dev'
{:ok, pid} = Kadabra.open(uri)
ref = Process.monitor(pid)
# Open two streams that send the time every second
Kadabra.get(pid, "/clockstream", on_response: & &1)
Kadabra.get(pid, "/clockstream", on_response: & &1)
conn_pid = :sys.get_state(pid).connection
socket_pid = :sys.get_state(conn_pid).config.socket
# Wait to collect some data on the streams
Process.sleep(500)
state = :sys.get_state(conn_pid)
assert Enum.count(state.flow_control.stream_set.active_streams) == 2
# frame = Kadabra.Frame.Goaway.new(1)
# GenServer.cast(conn_pid, {:recv, frame})
send(socket_pid, {:ssl_closed, nil})
assert_receive {:closed, ^pid}, 5_000
assert_receive {:DOWN, ^ref, :process, ^pid, :shutdown}, 5_000
end
end