diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-13 12:15:05 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-13 12:15:05 +0900 |
commit | b7ece53ef348333f2f495113c76daa1f5f2075a7 (patch) | |
tree | d06a323abb5c73d8877a92f3d6081b201e48a0a4 /test/plum | |
parent | c1e0672e58a621b16ef34c22b2f603dc5d193968 (diff) | |
download | plum-b7ece53ef348333f2f495113c76daa1f5f2075a7.tar.gz |
connection: respect recv window size
Diffstat (limited to 'test/plum')
-rw-r--r-- | test/plum/connection/test_handle_frame.rb | 3 | ||||
-rw-r--r-- | test/plum/test_flow_control.rb | 43 |
2 files changed, 45 insertions, 1 deletions
diff --git a/test/plum/connection/test_handle_frame.rb b/test/plum/connection/test_handle_frame.rb index eee44db..6aa7db7 100644 --- a/test/plum/connection/test_handle_frame.rb +++ b/test/plum/connection/test_handle_frame.rb @@ -14,6 +14,9 @@ class ServerConnectionHandleFrameTest < Minitest::Test def test_server_handle_settings open_server_connection {|con| + assert_no_error { + con << Frame.new(type: :settings, stream_id: 0, flags: [:ack], payload: "").assemble + } assert_connection_error(:frame_size_error) { con << Frame.new(type: :settings, stream_id: 0, flags: [:ack], payload: "\x00").assemble } diff --git a/test/plum/test_flow_control.rb b/test/plum/test_flow_control.rb index 5e299e0..758472d 100644 --- a/test/plum/test_flow_control.rb +++ b/test/plum/test_flow_control.rb @@ -97,7 +97,7 @@ class FlowControlTest < Minitest::Test } end - def test_flow_control_update_initial_window_size + def test_flow_control_update_send_initial_window_size open_new_stream {|stream| con = stream.connection con << Frame.new(type: :settings, @@ -123,4 +123,45 @@ class FlowControlTest < Minitest::Test assert_equal(3, last.payload.uint32) } end + + def test_flow_control_recv_window_exceeded + prepare = ->(&blk) { + open_new_stream {|stream| + con = stream.connection + con.settings(initial_window_size: 24) + blk.call(con, stream) + } + } + + prepare.call {|con, stream| + con.window_update(500) # extend only connection + con << Frame.headers(stream.id, "", :end_headers).assemble + assert_stream_error(:flow_control_error) { + con << Frame.data(stream.id, "\x00" * 30, :end_stream).assemble + } + } + + prepare.call {|con, stream| + stream.window_update(500) # extend only stream + con << Frame.headers(stream.id, "", :end_headers).assemble + assert_connection_error(:flow_control_error) { + con << Frame.data(stream.id, "\x00" * 30, :end_stream).assemble + } + } + end + + def test_flow_control_update_recv_initial_window_size + open_new_stream {|stream| + con = stream.connection + con.settings(initial_window_size: 24) + stream.window_update(1) + con << Frame.headers(stream.id, "", :end_headers).assemble + con << Frame.data(stream.id, "\x00" * 20, :end_stream).assemble + assert_equal(4, con.recv_remaining_window) + assert_equal(5, stream.recv_remaining_window) + con.settings(initial_window_size: 60) + assert_equal(40, con.recv_remaining_window) + assert_equal(41, stream.recv_remaining_window) + } + end end |