diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex index 4e18a34b3a..64fdb00538 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/block_controller.ex @@ -14,19 +14,13 @@ defmodule BlockScoutWeb.API.RPC.BlockController do render(conn, :block_reward, block: block, reward: reward) else {:block_param, :error} -> - conn - |> put_status(400) - |> render(:error, error: "Query parameter 'blockno' is required") + render(conn, :error, error: "Query parameter 'blockno' is required") {:error, :invalid} -> - conn - |> put_status(400) - |> render(:error, error: "Invalid block number") + render(conn, :error, error: "Invalid block number") {:error, :not_found} -> - conn - |> put_status(404) - |> render(:error, error: "Block does not exist") + render(conn, :error, error: "Block does not exist") end end end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs index 7722f2cf14..cf4027f54d 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/block_controller_test.exs @@ -5,10 +5,10 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do describe "getblockreward" do test "with missing block number", %{conn: conn} do - assert response = - conn - |> get("/api", %{"module" => "block", "action" => "getblockreward"}) - |> json_response(400) + response = + conn + |> get("/api", %{"module" => "block", "action" => "getblockreward"}) + |> json_response(200) assert response["message"] =~ "'blockno' is required" assert response["status"] == "0" @@ -17,10 +17,10 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do end test "with an invalid block number", %{conn: conn} do - assert response = - conn - |> get("/api", %{"module" => "block", "action" => "getblockreward", "blockno" => "badnumber"}) - |> json_response(400) + response = + conn + |> get("/api", %{"module" => "block", "action" => "getblockreward", "blockno" => "badnumber"}) + |> json_response(200) assert response["message"] =~ "Invalid block number" assert response["status"] == "0" @@ -29,10 +29,10 @@ defmodule BlockScoutWeb.API.RPC.BlockControllerTest do end test "with a block that doesn't exist", %{conn: conn} do - assert response = - conn - |> get("/api", %{"module" => "block", "action" => "getblockreward", "blockno" => "42"}) - |> json_response(404) + response = + conn + |> get("/api", %{"module" => "block", "action" => "getblockreward", "blockno" => "42"}) + |> json_response(200) assert response["message"] =~ "Block does not exist" assert response["status"] == "0"