From 8fed45b345ef8b8eba406fcd72412a517255bfd0 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 10 Apr 2019 14:32:32 +0300 Subject: [PATCH] fix paging params --- .../block_scout_web/lib/block_scout_web/chain.ex | 6 +++++- .../api/rpc/transaction_controller_test.exs | 16 ++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index 56f573f85f..ebe196739c 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -115,7 +115,7 @@ defmodule BlockScoutWeb.Chain do end end - def paging_options(%{"index" => index_string}) do + def paging_options(%{"index" => index_string}) when is_binary(index_string) do with {index, ""} <- Integer.parse(index_string) do [paging_options: %{@default_paging_options | key: {index}}] else @@ -124,6 +124,10 @@ defmodule BlockScoutWeb.Chain do end end + def paging_options(%{"index" => index}) when is_integer(index) do + [paging_options: %{@default_paging_options | key: {index}}] + end + def paging_options(%{"inserted_at" => inserted_at_string, "hash" => hash_string}) do with {:ok, inserted_at, _} <- DateTime.from_iso8601(inserted_at_string), {:ok, hash} <- string_to_transaction_hash(hash_string) do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs index 708cd7e0f4..aa2f265c51 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/transaction_controller_test.exs @@ -405,15 +405,10 @@ defmodule BlockScoutWeb.API.RPC.TransactionControllerTest do "action" => "gettxinfo", "index" => 49, "module" => "transaction", - "txhash" => "0x0000000000000000000000000000000000000000000000000000000000000000" + "txhash" => "#{transaction.hash}" } - params2 = %{ - "module" => "transaction", - "action" => "gettxinfo", - "txhash" => "#{transaction.hash}", - "next_page_params" => response1["result"]["next_page_params"] - } + params2 = response1["result"]["next_page_params"] assert response2 = conn @@ -423,8 +418,8 @@ defmodule BlockScoutWeb.API.RPC.TransactionControllerTest do assert response2["status"] == "1" assert response2["message"] == "OK" assert Enum.count(response2["result"]["logs"]) == 50 - IO.inspect("here") - assert response2["result"]["next_page_params"] |> IO.inspect() + assert is_nil(response2["result"]["next_page_params"]) + assert response1["result"]["logs"] != response2["result"]["logs"] end test "with a txhash with ok status", %{conn: conn} do @@ -469,7 +464,8 @@ defmodule BlockScoutWeb.API.RPC.TransactionControllerTest do "data" => "#{log.data}", "topics" => ["first topic", "second topic", nil, nil] } - ] + ], + "next_page_params" => nil } assert response =