fix rpc/address_controller test

pull/2613/head
Ayrat Badykov 5 years ago
parent cc0146b147
commit 3d732bd4b4
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 35
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs

@ -2266,7 +2266,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end
test "returns all the required fields", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward)
%{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -2274,17 +2274,10 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 1)
|> with_block(block, gas_used: 1)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(1))
|> Wei.from(:wei)
expected_result = [
%{
"blockNumber" => to_string(block.number),
"timeStamp" => to_string(block.timestamp),
"blockReward" => to_string(expected_reward.value)
"timeStamp" => to_string(block.timestamp)
}
]
@ -2306,7 +2299,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end
test "with a block with one transaction", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward)
%{block_range: range} = insert(:emission_reward)
block = insert(:block, number: Enum.random(Range.new(range.from, range.to)))
@ -2314,12 +2307,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 1)
|> with_block(block, gas_used: 1)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(1))
|> Wei.from(:wei)
params = %{
"module" => "account",
"action" => "getminedblocks",
@ -2329,8 +2316,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
expected_result = [
%{
"blockNumber" => to_string(block.number),
"timeStamp" => to_string(block.timestamp),
"blockReward" => to_string(expected_reward.value)
"timeStamp" => to_string(block.timestamp)
}
]
@ -2346,7 +2332,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
end
test "with pagination options", %{conn: conn} do
%{block_range: range} = emission_reward = insert(:emission_reward)
%{block_range: range} = insert(:emission_reward)
block_numbers = Range.new(range.from, range.to)
@ -2361,12 +2347,6 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
|> insert(gas_price: 2)
|> with_block(block2, gas_used: 2)
expected_reward =
emission_reward.reward
|> Wei.to(:wei)
|> Decimal.add(Decimal.new(4))
|> Wei.from(:wei)
params = %{
"module" => "account",
"action" => "getminedblocks",
@ -2380,8 +2360,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
expected_result = [
%{
"blockNumber" => to_string(block2.number),
"timeStamp" => to_string(block2.timestamp),
"blockReward" => to_string(expected_reward.value)
"timeStamp" => to_string(block2.timestamp)
}
]
@ -2683,7 +2662,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
})
end
defp resolve_schema(result \\ %{}) do
defp resolve_schema(result) do
%{
"type" => "object",
"properties" => %{

Loading…
Cancel
Save