diff --git a/apps/ethereum_jsonrpc/test/etheream_jsonrpc_test.exs b/apps/ethereum_jsonrpc/test/etheream_jsonrpc_test.exs index f9586cb78b..25c7333dba 100644 --- a/apps/ethereum_jsonrpc/test/etheream_jsonrpc_test.exs +++ b/apps/ethereum_jsonrpc/test/etheream_jsonrpc_test.exs @@ -131,66 +131,4 @@ defmodule EthereumJSONRPCTest do ) end end - - describe "json_rpc/2" do - # regression test for https://github.com/poanetwork/poa-explorer/issues/254 - test "transparently splits batch payloads that would trigger a 413 Request Entity Too Large", %{variant: variant} do - block_numbers = 0..13000 - - payload = - block_numbers - |> Stream.with_index() - |> Enum.map(&get_block_by_number_request/1) - - assert_payload_too_large(payload, variant) - - url = EthereumJSONRPC.config(:url) - - log_bad_gateway( - fn -> EthereumJSONRPC.json_rpc(payload, url) end, - fn result -> - assert {:ok, responses} = result - assert Enum.count(responses) == Enum.count(block_numbers) - - block_number_set = MapSet.new(block_numbers) - - response_block_number_set = - Enum.into(responses, MapSet.new(), fn %{"result" => %{"number" => quantity}} -> - EthereumJSONRPC.quantity_to_integer(quantity) - end) - - assert MapSet.equal?(response_block_number_set, block_number_set) - end - ) - end - end - - defp assert_payload_too_large(payload, variant) do - json = Jason.encode_to_iodata!(payload) - headers = [{"Content-Type", "application/json"}] - url = EthereumJSONRPC.config(:url) - - assert {:ok, %HTTPoison.Response{body: body, status_code: 413}} = - HTTPoison.post(url, json, headers, EthereumJSONRPC.config(:http)) - - case variant do - EthereumJSONRPC.Geth -> - assert body =~ "content length too large" - - EthereumJSONRPC.Parity -> - assert body =~ "413 Request Entity Too Large" - - _ -> - raise ArgumentError, "Unsupported variant (#{variant})" - end - end - - defp get_block_by_number_request({block_number, id}) do - %{ - "id" => id, - "jsonrpc" => "2.0", - "method" => "eth_getBlockByNumber", - "params" => [EthereumJSONRPC.integer_to_quantity(block_number), true] - } - end end