@ -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