Fix assert in test

Unused variable warning was an indication that the `assert` was
rebinding the variable and `^` was missing.  Rewritten to inline the
expected value for better error message from `assert`.
pull/1302/head
Luke Imhoff 6 years ago
parent 1c915bdb3a
commit ee76f6ee18
  1. 33
      apps/indexer/test/indexer/block/uncataloged_rewards/importer_test.exs

@ -16,7 +16,10 @@ defmodule Indexer.Block.UncatalogedRewards.ImporterTest do
@tag :no_geth @tag :no_geth
test "return `{:ok, [transactions executed]}`" do test "return `{:ok, [transactions executed]}`" do
address = insert(:address) address = insert(:address)
address_hash = address.hash
block = insert(:block, number: 1234, miner: address) block = insert(:block, number: 1234, miner: address)
block_hash = block.hash
expect(EthereumJSONRPC.Mox, :json_rpc, fn [%{id: id, method: "trace_block", params: _params}], _options -> expect(EthereumJSONRPC.Mox, :json_rpc, fn [%{id: id, method: "trace_block", params: _params}], _options ->
{:ok, {:ok,
@ -26,12 +29,12 @@ defmodule Indexer.Block.UncatalogedRewards.ImporterTest do
result: [ result: [
%{ %{
"action" => %{ "action" => %{
"author" => to_string(address.hash), "author" => to_string(address_hash),
"rewardType" => "external", "rewardType" => "external",
"value" => "0xde0b6b3a7640000" "value" => "0xde0b6b3a7640000"
}, },
"blockHash" => to_string(block.hash), "blockHash" => to_string(block_hash),
"blockNumber" => 1234, "blockNumber" => block.number,
"result" => nil, "result" => nil,
"subtraces" => 0, "subtraces" => 0,
"traceAddress" => [], "traceAddress" => [],
@ -44,20 +47,16 @@ defmodule Indexer.Block.UncatalogedRewards.ImporterTest do
]} ]}
end) end)
expected = assert {:ok,
{:ok, [
[ ok: %{
ok: %{ "insert_0" => %Reward{
"insert_0" => %Reward{ address_hash: ^address_hash,
address_hash: address.hash, block_hash: ^block_hash,
block_hash: block.hash, address_type: :validator
address_type: :validator }
} }
} ]} = Importer.fetch_and_import_rewards([block])
]}
result = Importer.fetch_and_import_rewards([block])
assert result = expected
end end
@tag :no_geth @tag :no_geth

Loading…
Cancel
Save