aboutsummaryrefslogtreecommitdiffstats
path: root/test/plum
diff options
context:
space:
mode:
Diffstat (limited to 'test/plum')
-rw-r--r--test/plum/connection/test_handle_frame.rb14
-rw-r--r--test/plum/server/test_connection.rb2
-rw-r--r--test/plum/server/test_http_connection.rb2
-rw-r--r--test/plum/stream/test_handle_frame.rb54
-rw-r--r--test/plum/test_binary_string.rb2
-rw-r--r--test/plum/test_connection.rb16
-rw-r--r--test/plum/test_connection_utils.rb6
-rw-r--r--test/plum/test_event_emitter.rb6
-rw-r--r--test/plum/test_flow_control.rb30
-rw-r--r--test/plum/test_stream.rb4
-rw-r--r--test/plum/test_stream_utils.rb2
11 files changed, 69 insertions, 69 deletions
diff --git a/test/plum/connection/test_handle_frame.rb b/test/plum/connection/test_handle_frame.rb
index d1cc54e..704c128 100644
--- a/test/plum/connection/test_handle_frame.rb
+++ b/test/plum/connection/test_handle_frame.rb
@@ -5,7 +5,7 @@ using Plum::BinaryString
class ServerConnectionHandleFrameTest < Minitest::Test
## SETTINGS
def test_server_handle_settings
- open_server_connection {|con|
+ open_server_connection { |con|
assert_equal(4096, con.remote_settings[:header_table_size])
con << Frame.new(type: :settings, stream_id: 0, payload: "\x00\x01\x00\x00\x10\x10").assemble
assert_equal(0x1010, con.remote_settings[:header_table_size])
@@ -13,7 +13,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
end
def test_server_handle_settings
- open_server_connection {|con|
+ open_server_connection { |con|
assert_no_error {
con << Frame.new(type: :settings, stream_id: 0, flags: [:ack], payload: "").assemble
}
@@ -24,7 +24,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
end
def test_server_handle_settings_invalid
- open_server_connection {|con|
+ open_server_connection { |con|
assert_no_error {
con << Frame.new(type: :settings, stream_id: 0, payload: "\xff\x01\x00\x00\x10\x10").assemble
}
@@ -33,7 +33,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
## PING
def test_server_handle_ping
- open_server_connection {|con|
+ open_server_connection { |con|
con << Frame.new(type: :ping, flags: [], stream_id: 0, payload: "AAAAAAAA").assemble
last = sent_frames.last
assert_equal(:ping, last.type)
@@ -43,7 +43,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
end
def test_server_handle_ping_error
- open_server_connection {|con|
+ open_server_connection { |con|
assert_connection_error(:frame_size_error) {
con << Frame.new(type: :ping, stream_id: 0, payload: "A" * 7).assemble
}
@@ -51,7 +51,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
end
def test_server_handle_ping_ack
- open_server_connection {|con|
+ open_server_connection { |con|
con << Frame.new(type: :ping, flags: [:ack], stream_id: 0, payload: "A" * 8).assemble
last = sent_frames.last
refute_equal(:ping, last.type) if last
@@ -60,7 +60,7 @@ class ServerConnectionHandleFrameTest < Minitest::Test
## GOAWAY
def test_server_handle_goaway_reply
- open_server_connection {|con|
+ open_server_connection { |con|
assert_no_error {
begin
con << Frame.goaway(1, :stream_closed).assemble
diff --git a/test/plum/server/test_connection.rb b/test/plum/server/test_connection.rb
index 4a45eaa..87e1893 100644
--- a/test/plum/server/test_connection.rb
+++ b/test/plum/server/test_connection.rb
@@ -68,7 +68,7 @@ class HTTPSConnectionNegotiationTest < Minitest::Test
client_thread = Thread.new {
sock = TCPSocket.new("127.0.0.1", LISTEN_PORT)
begin
- ctx = OpenSSL::SSL::SSLContext.new.tap {|ctx|
+ ctx = OpenSSL::SSL::SSLContext.new.tap { |ctx|
ctx.alpn_protocols = ["h2"]
ctx.ciphers = "AES256-GCM-SHA384"
}
diff --git a/test/plum/server/test_http_connection.rb b/test/plum/server/test_http_connection.rb
index 3093d5b..1326deb 100644
--- a/test/plum/server/test_http_connection.rb
+++ b/test/plum/server/test_http_connection.rb
@@ -29,7 +29,7 @@ class HTTPConnectionNegotiationTest < Minitest::Test
io = StringIO.new
con = HTTPServerConnection.new(io.method(:write))
heads = nil
- con.on(:headers) {|_, _h| heads = _h.to_h }
+ con.on(:headers) { |_, _h| heads = _h.to_h }
req = "GET / HTTP/1.1\r\n" <<
"Host: rhe.jp\r\n" <<
"User-Agent: nya\r\n" <<
diff --git a/test/plum/stream/test_handle_frame.rb b/test/plum/stream/test_handle_frame.rb
index b4b4a4c..2c14c26 100644
--- a/test/plum/stream/test_handle_frame.rb
+++ b/test/plum/stream/test_handle_frame.rb
@@ -6,9 +6,9 @@ class StreamHandleFrameTest < Minitest::Test
## DATA
def test_stream_handle_data
payload = "ABC" * 5
- open_new_stream(state: :open) {|stream|
+ open_new_stream(state: :open) { |stream|
data = nil
- stream.connection.on(:data) {|_, _data| data = _data }
+ stream.connection.on(:data) { |_, _data| data = _data }
stream.receive_frame(Frame.new(type: :data, stream_id: stream.id,
flags: [], payload: payload))
assert_equal(payload, data)
@@ -17,9 +17,9 @@ class StreamHandleFrameTest < Minitest::Test
def test_stream_handle_data_padded
payload = "ABC" * 5
- open_new_stream(state: :open) {|stream|
+ open_new_stream(state: :open) { |stream|
data = nil
- stream.connection.on(:data) {|_, _data| data = _data }
+ stream.connection.on(:data) { |_, _data| data = _data }
stream.receive_frame(Frame.new(type: :data, stream_id: stream.id,
flags: [:padded], payload: "".push_uint8(6).push(payload).push("\x00"*6)))
assert_equal(payload, data)
@@ -28,7 +28,7 @@ class StreamHandleFrameTest < Minitest::Test
def test_stream_handle_data_too_long_padding
payload = "ABC" * 5
- open_new_stream(state: :open) {|stream|
+ open_new_stream(state: :open) { |stream|
assert_connection_error(:protocol_error) {
stream.receive_frame(Frame.new(type: :data, stream_id: stream.id,
flags: [:padded], payload: "".push_uint8(100).push(payload).push("\x00"*6)))
@@ -38,7 +38,7 @@ class StreamHandleFrameTest < Minitest::Test
def test_stream_handle_data_end_stream
payload = "ABC" * 5
- open_new_stream(state: :open) {|stream|
+ open_new_stream(state: :open) { |stream|
stream.receive_frame(Frame.new(type: :data, stream_id: stream.id,
flags: [:end_stream], payload: payload))
assert_equal(:half_closed_remote, stream.state)
@@ -47,7 +47,7 @@ class StreamHandleFrameTest < Minitest::Test
def test_stream_handle_data_invalid_state
payload = "ABC" * 5
- open_new_stream(state: :half_closed_remote) {|stream|
+ open_new_stream(state: :half_closed_remote) { |stream|
assert_stream_error(:stream_closed) {
stream.receive_frame(Frame.new(type: :data, stream_id: stream.id,
flags: [:end_stream], payload: payload))
@@ -57,9 +57,9 @@ class StreamHandleFrameTest < Minitest::Test
## HEADERS
def test_stream_handle_headers_single
- open_new_stream {|stream|
+ open_new_stream { |stream|
headers = nil
- stream.connection.on(:headers) {|_, _headers|
+ stream.connection.on(:headers) { |_, _headers|
headers = _headers
}
stream.receive_frame(Frame.new(type: :headers,
@@ -72,10 +72,10 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_headers_continuation
- open_new_stream {|stream|
+ open_new_stream { |stream|
payload = HPACK::Encoder.new(0).encode([[":path", "/"]])
headers = nil
- stream.connection.on(:headers) {|_, _headers|
+ stream.connection.on(:headers) { |_, _headers|
headers = _headers
}
stream.receive_frame(Frame.new(type: :headers,
@@ -93,10 +93,10 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_headers_padded
- open_new_stream {|stream|
+ open_new_stream { |stream|
payload = HPACK::Encoder.new(0).encode([[":path", "/"]])
headers = nil
- stream.connection.on(:headers) {|_, _headers|
+ stream.connection.on(:headers) { |_, _headers|
headers = _headers
}
stream.receive_frame(Frame.new(type: :headers,
@@ -108,7 +108,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_headers_too_long_padding
- open_new_stream {|stream|
+ open_new_stream { |stream|
payload = HPACK::Encoder.new(0).encode([[":path", "/"]])
assert_connection_error(:protocol_error) {
stream.receive_frame(Frame.new(type: :headers,
@@ -120,7 +120,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_headers_broken
- open_new_stream {|stream|
+ open_new_stream { |stream|
payload = "\x00\x01\x02"
assert_connection_error(:compression_error) {
stream.receive_frame(Frame.new(type: :headers,
@@ -133,17 +133,17 @@ class StreamHandleFrameTest < Minitest::Test
def test_stream_handle_headers_state
_payload = HPACK::Encoder.new(0).encode([[":path", "/"]])
- open_new_stream(state: :reserved_local) {|stream|
+ open_new_stream(state: :reserved_local) { |stream|
assert_connection_error(:protocol_error) {
stream.receive_frame(Frame.new(type: :headers, stream_id: stream.id, flags: [:end_headers, :end_stream], payload: _payload))
}
}
- open_new_stream(state: :closed) {|stream|
+ open_new_stream(state: :closed) { |stream|
assert_connection_error(:stream_closed) {
stream.receive_frame(Frame.new(type: :headers, stream_id: stream.id, flags: [:end_headers, :end_stream], payload: _payload))
}
}
- open_new_stream(state: :half_closed_remote) {|stream|
+ open_new_stream(state: :half_closed_remote) { |stream|
assert_stream_error(:stream_closed) {
stream.receive_frame(Frame.new(type: :headers, stream_id: stream.id, flags: [:end_headers, :end_stream], payload: _payload))
}
@@ -151,12 +151,12 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_headers_priority
- open_server_connection {|con|
+ open_server_connection { |con|
parent = open_new_stream(con)
stream = open_new_stream(con)
headers = nil
- stream.connection.on(:headers) {|_, _headers| headers = _headers }
+ stream.connection.on(:headers) { |_, _headers| headers = _headers }
header_block = HPACK::Encoder.new(0).encode([[":path", "/"]])
payload = "".push_uint32((1 << 31) | parent.id)
.push_uint8(50)
@@ -174,7 +174,7 @@ class StreamHandleFrameTest < Minitest::Test
## PRIORITY
def test_stream_handle_priority
- open_server_connection {|con|
+ open_server_connection { |con|
parent = open_new_stream(con)
stream = open_new_stream(con)
@@ -190,7 +190,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_priority_self_depend
- open_server_connection {|con|
+ open_server_connection { |con|
stream = open_new_stream(con)
payload = "".push_uint32((0 << 31) | stream.id).push_uint8(6)
stream.receive_frame(Frame.new(type: :priority,
@@ -203,7 +203,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_priority_exclusive
- open_server_connection {|con|
+ open_server_connection { |con|
parent = open_new_stream(con)
stream0 = open_new_stream(con, parent: parent)
stream1 = open_new_stream(con, parent: parent)
@@ -220,7 +220,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_frame_size_error
- open_new_stream {|stream|
+ open_new_stream { |stream|
assert_stream_error(:frame_size_error) {
stream.receive_frame(Frame.new(type: :priority,
stream_id: stream.id,
@@ -231,7 +231,7 @@ class StreamHandleFrameTest < Minitest::Test
## RST_STREAM
def test_stream_handle_rst_stream
- open_new_stream(state: :reserved_local) {|stream|
+ open_new_stream(state: :reserved_local) { |stream|
stream.receive_frame(Frame.new(type: :rst_stream,
stream_id: stream.id,
payload: "\x00\x00\x00\x00"))
@@ -240,7 +240,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_rst_stream_idle
- open_new_stream(state: :idle) {|stream|
+ open_new_stream(state: :idle) { |stream|
assert_connection_error(:protocol_error) {
stream.receive_frame(Frame.new(type: :rst_stream,
stream_id: stream.id,
@@ -250,7 +250,7 @@ class StreamHandleFrameTest < Minitest::Test
end
def test_stream_handle_rst_stream_frame_size
- open_new_stream(state: :reserved_local) {|stream|
+ open_new_stream(state: :reserved_local) { |stream|
assert_connection_error(:frame_size_error) {
stream.receive_frame(Frame.new(type: :rst_stream,
stream_id: stream.id,
diff --git a/test/plum/test_binary_string.rb b/test/plum/test_binary_string.rb
index 266b548..e14123d 100644
--- a/test/plum/test_binary_string.rb
+++ b/test/plum/test_binary_string.rb
@@ -52,7 +52,7 @@ class BinaryStringTest < Minitest::Test
def test_each_byteslice_block
ret = []
string = "12345678"
- string.each_byteslice(3) {|part| ret << part }
+ string.each_byteslice(3) { |part| ret << part }
assert_equal(["123", "456", "78"], ret)
end
diff --git a/test/plum/test_connection.rb b/test/plum/test_connection.rb
index 799c3d0..fad70b4 100644
--- a/test/plum/test_connection.rb
+++ b/test/plum/test_connection.rb
@@ -13,22 +13,22 @@ class ConnectionTest < Minitest::Test
blk.call c
}
- new_con.call {|con|
+ new_con.call { |con|
assert_no_error {
con << Frame.new(type: :settings, stream_id: 0, payload: _settings * (limit / 6)).assemble
}
}
- new_con.call {|con|
+ new_con.call { |con|
assert_connection_error(:frame_size_error) {
con << Frame.new(type: :settings, stream_id: 0, payload: _settings * (limit / 6 + 1)).assemble
}
}
- new_con.call {|con|
+ new_con.call { |con|
assert_connection_error(:frame_size_error) {
con << Frame.new(type: :headers, stream_id: 3, payload: "\x00" * (limit + 1)).assemble
}
}
- new_con.call {|con|
+ new_con.call { |con|
assert_stream_error(:frame_size_error) {
con << Frame.new(type: :headers, stream_id: 3, flags: [:end_headers], payload: "").assemble
con << Frame.new(type: :data, stream_id: 3, payload: "\x00" * (limit + 1)).assemble
@@ -46,7 +46,7 @@ class ConnectionTest < Minitest::Test
end
def test_server_ignore_unknown_frame_type
- open_server_connection {|con|
+ open_server_connection { |con|
assert_no_error {
con << "\x00\x00\x00\x0f\x00\x00\x00\x00\x00" # type: 0x0f, no flags, no payload, stream 0
}
@@ -76,17 +76,17 @@ class ConnectionTest < Minitest::Test
blk.call(con)
}
- prepare.call {|con|
+ prepare.call { |con|
assert_connection_error(:protocol_error) {
con << Frame.new(type: :data, stream_id: 1, payload: "hello").assemble
}
}
- prepare.call {|con|
+ prepare.call { |con|
assert_connection_error(:protocol_error) {
con << Frame.new(type: :data, stream_id: 3, payload: "hello").assemble
}
}
- prepare.call {|con|
+ prepare.call { |con|
assert_equal(:waiting_continuation, con.state)
con << Frame.new(type: :continuation, flags: [:end_headers], stream_id: 3, payload: "").assemble
assert_equal(:open, con.state)
diff --git a/test/plum/test_connection_utils.rb b/test/plum/test_connection_utils.rb
index 35ab7b8..1147dd3 100644
--- a/test/plum/test_connection_utils.rb
+++ b/test/plum/test_connection_utils.rb
@@ -4,7 +4,7 @@ using BinaryString
class ServerConnectionUtilsTest < Minitest::Test
def test_server_ping
- open_server_connection {|con|
+ open_server_connection { |con|
con.ping("ABCABCAB")
last = sent_frames.last
@@ -15,7 +15,7 @@ class ServerConnectionUtilsTest < Minitest::Test
end
def test_server_goaway
- open_server_connection {|con|
+ open_server_connection { |con|
con << Frame.headers(3, "", end_stream: true, end_headers: true).assemble
con.goaway(:stream_closed)
@@ -28,7 +28,7 @@ class ServerConnectionUtilsTest < Minitest::Test
end
def test_push_enabled
- open_server_connection {|con|
+ open_server_connection { |con|
con << Frame.settings(enable_push: 0).assemble
assert_equal(false, con.push_enabled?)
con << Frame.settings(enable_push: 1).assemble
diff --git a/test/plum/test_event_emitter.rb b/test/plum/test_event_emitter.rb
index 01d6001..7efae16 100644
--- a/test/plum/test_event_emitter.rb
+++ b/test/plum/test_event_emitter.rb
@@ -5,7 +5,7 @@ class EventEmitterTest < Minitest::Test
def test_simple
ret = nil
emitter = new_emitter
- emitter.on(:event) {|arg| ret = arg }
+ emitter.on(:event) { |arg| ret = arg }
emitter.callback(:event, 123)
assert_equal(123, ret)
end
@@ -13,8 +13,8 @@ class EventEmitterTest < Minitest::Test
def test_multiple
ret1 = nil; ret2 = nil
emitter = new_emitter
- emitter.on(:event) {|arg| ret1 = arg }
- emitter.on(:event) {|arg| ret2 = arg }
+ emitter.on(:event) { |arg| ret1 = arg }
+ emitter.on(:event) { |arg| ret2 = arg }
emitter.callback(:event, 123)
assert_equal(123, ret1)
assert_equal(123, ret2)
diff --git a/test/plum/test_flow_control.rb b/test/plum/test_flow_control.rb
index 8133e0e..316361c 100644
--- a/test/plum/test_flow_control.rb
+++ b/test/plum/test_flow_control.rb
@@ -4,7 +4,7 @@ using BinaryString
class FlowControlTest < Minitest::Test
def test_flow_control_window_update_server
- open_server_connection {|con|
+ open_server_connection { |con|
before_ws = con.recv_remaining_window
con.window_update(500)
@@ -17,7 +17,7 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_window_update_stream
- open_new_stream {|stream|
+ open_new_stream { |stream|
before_ws = stream.recv_remaining_window
stream.window_update(500)
@@ -30,7 +30,7 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_window_update_zero
- open_new_stream {|stream|
+ open_new_stream { |stream|
assert_stream_error(:protocol_error) {
stream.receive_frame Frame.new(type: :window_update,
stream_id: stream.id,
@@ -40,7 +40,7 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_window_update_frame_size
- open_new_stream {|stream|
+ open_new_stream { |stream|
assert_connection_error(:frame_size_error) {
stream.receive_frame Frame.new(type: :window_update,
stream_id: stream.id,
@@ -50,7 +50,7 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_dont_send_data_exceeding_send_window
- open_new_stream {|stream|
+ open_new_stream { |stream|
con = stream.connection
con << Frame.new(type: :settings,
stream_id: 0,
@@ -60,7 +60,7 @@ class FlowControlTest < Minitest::Test
con << Frame.new(type: :window_update,
stream_id: stream.id,
payload: "".push_uint32(100)).assemble
- 10.times {|i|
+ 10.times { |i|
stream.send Frame.new(type: :data,
stream_id: stream.id,
payload: "".push_uint32(i))
@@ -72,13 +72,13 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_dont_send_data_upto_updated_send_window
- open_new_stream {|stream|
+ open_new_stream { |stream|
con = stream.connection
con << Frame.new(type: :settings,
stream_id: 0,
payload: "".push_uint16(Frame::SETTINGS_TYPE[:initial_window_size])
.push_uint32(4*2+1)).assemble
- 10.times {|i|
+ 10.times { |i|
stream.send Frame.new(type: :data,
stream_id: stream.id,
payload: "".push_uint32(i))
@@ -98,13 +98,13 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_update_send_initial_window_size
- open_new_stream {|stream|
+ open_new_stream { |stream|
con = stream.connection
con << Frame.new(type: :settings,
stream_id: 0,
payload: "".push_uint16(Frame::SETTINGS_TYPE[:initial_window_size])
.push_uint32(4*2+1)).assemble
- 10.times {|i|
+ 10.times { |i|
stream.send Frame.new(type: :data,
stream_id: stream.id,
payload: "".push_uint32(i))
@@ -119,21 +119,21 @@ class FlowControlTest < Minitest::Test
payload: "".push_uint16(Frame::SETTINGS_TYPE[:initial_window_size])
.push_uint32(4*4+1)).assemble
- last = sent_frames.reverse.find {|f| f.type == :data }
+ last = sent_frames.reverse.find { |f| f.type == :data }
assert_equal(3, last.payload.uint32)
}
end
def test_flow_control_recv_window_exceeded
prepare = ->(&blk) {
- open_new_stream {|stream|
+ open_new_stream { |stream|
con = stream.connection
con.settings(initial_window_size: 24)
blk.call(con, stream)
}
}
- prepare.call {|con, stream|
+ prepare.call { |con, stream|
con.window_update(500) # extend only connection
con << Frame.headers(stream.id, "", end_headers: true).assemble
assert_stream_error(:flow_control_error) {
@@ -141,7 +141,7 @@ class FlowControlTest < Minitest::Test
}
}
- prepare.call {|con, stream|
+ prepare.call { |con, stream|
stream.window_update(500) # extend only stream
con << Frame.headers(stream.id, "", end_headers: true).assemble
assert_connection_error(:flow_control_error) {
@@ -151,7 +151,7 @@ class FlowControlTest < Minitest::Test
end
def test_flow_control_update_recv_initial_window_size
- open_new_stream {|stream|
+ open_new_stream { |stream|
con = stream.connection
con.settings(initial_window_size: 24)
stream.window_update(1)
diff --git a/test/plum/test_stream.rb b/test/plum/test_stream.rb
index 2ed3ac9..fc1e94b 100644
--- a/test/plum/test_stream.rb
+++ b/test/plum/test_stream.rb
@@ -4,7 +4,7 @@ using Plum::BinaryString
class StreamTest < Minitest::Test
def test_stream_illegal_frame_type
- open_new_stream {|stream|
+ open_new_stream { |stream|
assert_connection_error(:protocol_error) {
stream.receive_frame(Frame.new(type: :goaway, stream_id: stream.id, payload: "\x00\x00\x00\x00"))
}
@@ -12,7 +12,7 @@ class StreamTest < Minitest::Test
end
def test_stream_unknown_frame_type
- open_new_stream {|stream|
+ open_new_stream { |stream|
assert_no_error {
stream.receive_frame(Frame.new(type_value: 0x0f, stream_id: stream.id, payload: "\x00\x00\x00\x00"))
}
diff --git a/test/plum/test_stream_utils.rb b/test/plum/test_stream_utils.rb
index 363fcf8..933c510 100644
--- a/test/plum/test_stream_utils.rb
+++ b/test/plum/test_stream_utils.rb
@@ -3,7 +3,7 @@ require "test_helper"
using BinaryString
class StreamUtilsTest < Minitest::Test
def test_stream_promise
- open_new_stream {|stream|
+ open_new_stream { |stream|
push_stream = stream.promise([])
assert(push_stream.id % 2 == 0)