diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-10-25 18:32:16 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-10-25 18:40:18 +0900 |
commit | 28a3a72007b2592ff5ea6bbd6984340133636065 (patch) | |
tree | d1cb9bb55f203a728bbc6adbb3646db5f8ae89cb /test | |
parent | 68412f1d63ac1336210ee357b573f8308e2f5b97 (diff) | |
download | plum-28a3a72007b2592ff5ea6bbd6984340133636065.tar.gz |
!stream: set callbacks to Connection, not Stream (for performance)
Diffstat (limited to 'test')
-rw-r--r-- | test/plum/stream/test_handle_frame.rb | 12 | ||||
-rw-r--r-- | test/plum/test_http_connection.rb | 4 | ||||
-rw-r--r-- | test/plum/test_https_connection.rb | 21 |
3 files changed, 16 insertions, 21 deletions
diff --git a/test/plum/stream/test_handle_frame.rb b/test/plum/stream/test_handle_frame.rb index ee9a394..6a062cf 100644 --- a/test/plum/stream/test_handle_frame.rb +++ b/test/plum/stream/test_handle_frame.rb @@ -8,7 +8,7 @@ class StreamHandleFrameTest < Minitest::Test payload = "ABC" * 5 open_new_stream(state: :open) {|stream| data = nil - stream.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) @@ -19,7 +19,7 @@ class StreamHandleFrameTest < Minitest::Test payload = "ABC" * 5 open_new_stream(state: :open) {|stream| data = nil - stream.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) @@ -59,7 +59,7 @@ class StreamHandleFrameTest < Minitest::Test def test_stream_handle_headers_single open_new_stream {|stream| headers = nil - stream.on(:headers) {|_headers| + stream.connection.on(:headers) {|_, _headers| headers = _headers } stream.receive_frame(Frame.new(type: :headers, @@ -75,7 +75,7 @@ class StreamHandleFrameTest < Minitest::Test open_new_stream {|stream| payload = HPACK::Encoder.new(0).encode([[":path", "/"]]) headers = nil - stream.on(:headers) {|_headers| + stream.connection.on(:headers) {|_, _headers| headers = _headers } stream.receive_frame(Frame.new(type: :headers, @@ -96,7 +96,7 @@ class StreamHandleFrameTest < Minitest::Test open_new_stream {|stream| payload = HPACK::Encoder.new(0).encode([[":path", "/"]]) headers = nil - stream.on(:headers) {|_headers| + stream.connection.on(:headers) {|_, _headers| headers = _headers } stream.receive_frame(Frame.new(type: :headers, @@ -156,7 +156,7 @@ class StreamHandleFrameTest < Minitest::Test stream = open_new_stream(con) headers = nil - stream.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) diff --git a/test/plum/test_http_connection.rb b/test/plum/test_http_connection.rb index fc451d0..ea72a55 100644 --- a/test/plum/test_http_connection.rb +++ b/test/plum/test_http_connection.rb @@ -27,9 +27,7 @@ class HTTPConnectionNegotiationTest < Minitest::Test io = StringIO.new con = HTTPConnection.new(io) heads = nil - con.on(:stream) {|stream| - stream.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/test_https_connection.rb b/test/plum/test_https_connection.rb index 34679bc..b08f7be 100644 --- a/test/plum/test_https_connection.rb +++ b/test/plum/test_https_connection.rb @@ -64,24 +64,21 @@ class HTTPSConnectionNegotiationTest < Minitest::Test client_thread = Thread.new { sock = TCPSocket.new("127.0.0.1", LISTEN_PORT) begin - Timeout.timeout(3) { - ctx = OpenSSL::SSL::SSLContext.new.tap {|ctx| - ctx.alpn_protocols = ["h2"] - ctx.ciphers = "AES256-GCM-SHA384" - } - ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) - ssl.connect - ssl.write Connection::CLIENT_CONNECTION_PREFACE - ssl.write Frame.settings.assemble + ctx = OpenSSL::SSL::SSLContext.new.tap {|ctx| + ctx.alpn_protocols = ["h2"] + ctx.ciphers = "AES256-GCM-SHA384" } - rescue Timeout::Error - flunk "client timeout" + ssl = OpenSSL::SSL::SSLSocket.new(sock, ctx) + ssl.connect + ssl.write Connection::CLIENT_CONNECTION_PREFACE + ssl.write Frame.settings.assemble + sleep ensure sock.close end } - client_thread.join server_thread.join + client_thread.kill flunk "test not run" unless run end |