Merge pull request #508 from poanetwork/sa-api-add-post-test-coverage

Improves API test coverage
pull/512/head
Luke Imhoff 6 years ago committed by GitHub
commit b96a9c058e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 78
      apps/explorer_web/test/explorer_web/controllers/api/rpc/address_controller_test.exs

@ -117,6 +117,28 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
assert response["status"] == "1"
assert response["message"] == "OK"
end
test "supports GET and POST requests", %{conn: conn} do
address = insert(:address, fetched_balance: 100)
params = %{
"module" => "account",
"action" => "balance",
"address" => "#{address.hash}"
}
assert get_response =
conn
|> get("/api", params)
|> json_response(200)
assert post_response =
conn
|> post("/api", params)
|> json_response(200)
assert get_response == post_response
end
end
describe "balancemulti" do
@ -284,6 +306,36 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
assert response["status"] == "1"
assert response["message"] == "OK"
end
test "supports GET and POST requests", %{conn: conn} do
addresses =
for _ <- 1..4 do
insert(:address, fetched_balance: Enum.random(1..1_000))
end
address_param =
addresses
|> Enum.map(&"#{&1.hash}")
|> Enum.join(",")
params = %{
"module" => "account",
"action" => "balancemulti",
"address" => address_param
}
assert get_response =
conn
|> get("/api", params)
|> json_response(200)
assert post_response =
conn
|> post("/api", params)
|> json_response(200)
assert get_response == post_response
end
end
describe "txlist" do
@ -956,5 +1008,31 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
assert response["status"] == "1"
assert response["message"] == "OK"
end
test "supports GET and POST requests", %{conn: conn} do
address = insert(:address)
:transaction
|> insert(from_address: address)
|> with_block()
params = %{
"module" => "account",
"action" => "txlist",
"address" => "#{address.hash}"
}
assert get_response =
conn
|> get("/api", params)
|> json_response(200)
assert post_response =
conn
|> post("/api", params)
|> json_response(200)
assert get_response == post_response
end
end
end

Loading…
Cancel
Save