|
|
@ -5,6 +5,8 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
import EthereumJSONRPC, only: [integer_to_quantity: 1] |
|
|
|
import EthereumJSONRPC, only: [integer_to_quantity: 1] |
|
|
|
import Mox |
|
|
|
import Mox |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias EthereumJSONRPC.FetchedBeneficiaries |
|
|
|
|
|
|
|
|
|
|
|
setup :verify_on_exit! |
|
|
|
setup :verify_on_exit! |
|
|
|
|
|
|
|
|
|
|
|
doctest EthereumJSONRPC.Parity |
|
|
|
doctest EthereumJSONRPC.Parity |
|
|
@ -245,53 +247,54 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
|
|
|
|
|
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn %{params: [^block_quantity]}, _options -> |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn [%{id: id, params: [^block_quantity]}], _options -> |
|
|
|
{:ok, |
|
|
|
{:ok, |
|
|
|
[ |
|
|
|
[ |
|
|
|
%{ |
|
|
|
%{ |
|
|
|
"action" => %{ |
|
|
|
id: id, |
|
|
|
"author" => hash1, |
|
|
|
result: [ |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash1, |
|
|
|
"blockHash" => "0x52a8d2185282506ce681364d2aa0c085ba45fdeb5d6c0ddec1131617a71ee2ca", |
|
|
|
"rewardType" => "block", |
|
|
|
"blockNumber" => block_number, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0x52a8d2185282506ce681364d2aa0c085ba45fdeb5d6c0ddec1131617a71ee2ca", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
}, |
|
|
|
"transactionHash" => nil, |
|
|
|
%{ |
|
|
|
"transactionPosition" => nil, |
|
|
|
"action" => %{ |
|
|
|
"type" => "reward" |
|
|
|
"author" => hash2, |
|
|
|
}, |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash2, |
|
|
|
"blockHash" => "0x52a8d2185282506ce681364d2aa0c085ba45fdeb5d6c0ddec1131617a71ee2ca", |
|
|
|
"rewardType" => "block", |
|
|
|
"blockNumber" => block_number, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0x52a8d2185282506ce681364d2aa0c085ba45fdeb5d6c0ddec1131617a71ee2ca", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
|
|
|
|
"transactionHash" => nil, |
|
|
|
|
|
|
|
"transactionPosition" => nil, |
|
|
|
|
|
|
|
"type" => "reward" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
]} |
|
|
|
]} |
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expected_beneficiaries = |
|
|
|
assert {:ok, %FetchedBeneficiaries{params_set: params_set}} = |
|
|
|
MapSet.new([ |
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
%{block_number: block_number, address_hash: hash2}, |
|
|
|
|
|
|
|
%{block_number: block_number, address_hash: hash1} |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, fetched_beneficiaries} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert fetched_beneficiaries == expected_beneficiaries |
|
|
|
assert Enum.count(params_set) == 2 |
|
|
|
|
|
|
|
assert %{block_number: block_number, address_hash: hash2} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number, address_hash: hash1} in params_set |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with 'external' 'rewardType'", %{ |
|
|
|
test "with 'external' 'rewardType'", %{ |
|
|
@ -303,81 +306,69 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
|
|
|
|
|
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn %{params: [^block_quantity]}, _options -> |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn [%{id: id, params: [^block_quantity]}], _options -> |
|
|
|
{:ok, |
|
|
|
{:ok, |
|
|
|
[ |
|
|
|
[ |
|
|
|
%{ |
|
|
|
%{ |
|
|
|
"action" => %{ |
|
|
|
id: id, |
|
|
|
"author" => hash1, |
|
|
|
result: [ |
|
|
|
"rewardType" => "external", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash1, |
|
|
|
"blockHash" => "0xf19a4ea2bb4f2d8839f4c3ec11e0e86c29d57799d7073713958fe1990e197cf5", |
|
|
|
"rewardType" => "external", |
|
|
|
"blockNumber" => 5_609_295, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0xf19a4ea2bb4f2d8839f4c3ec11e0e86c29d57799d7073713958fe1990e197cf5", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => 5_609_295, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
}, |
|
|
|
"transactionHash" => nil, |
|
|
|
%{ |
|
|
|
"transactionPosition" => nil, |
|
|
|
"action" => %{ |
|
|
|
"type" => "reward" |
|
|
|
"author" => hash2, |
|
|
|
}, |
|
|
|
"rewardType" => "external", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash2, |
|
|
|
"blockHash" => "0xf19a4ea2bb4f2d8839f4c3ec11e0e86c29d57799d7073713958fe1990e197cf5", |
|
|
|
"rewardType" => "external", |
|
|
|
"blockNumber" => 5_609_295, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0xf19a4ea2bb4f2d8839f4c3ec11e0e86c29d57799d7073713958fe1990e197cf5", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => 5_609_295, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
|
|
|
|
"transactionHash" => nil, |
|
|
|
|
|
|
|
"transactionPosition" => nil, |
|
|
|
|
|
|
|
"type" => "reward" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
]} |
|
|
|
]} |
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expected_beneficiaries = |
|
|
|
assert {:ok, %FetchedBeneficiaries{params_set: params_set, errors: []}} = |
|
|
|
MapSet.new([ |
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_609_295..5_609_295, json_rpc_named_arguments) |
|
|
|
%{block_number: block_number, address_hash: hash2}, |
|
|
|
|
|
|
|
%{block_number: block_number, address_hash: hash1} |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, fetched_beneficiaries} = |
|
|
|
assert Enum.count(params_set) == 2 |
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_609_295..5_609_295, json_rpc_named_arguments) |
|
|
|
assert %{block_number: block_number, address_hash: hash1} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number, address_hash: hash2} in params_set |
|
|
|
assert fetched_beneficiaries == expected_beneficiaries |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with no rewards, returns {:ok, []}", %{ |
|
|
|
test "with no rewards, returns {:ok, []}", %{ |
|
|
|
json_rpc_named_arguments: json_rpc_named_arguments |
|
|
|
json_rpc_named_arguments: json_rpc_named_arguments |
|
|
|
} do |
|
|
|
} do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options -> |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn requests, _options when is_list(requests) -> |
|
|
|
{:ok, []} |
|
|
|
responses = Enum.map(requests, fn %{id: id} -> %{id: id, result: []} end) |
|
|
|
end) |
|
|
|
{:ok, responses} |
|
|
|
|
|
|
|
|
|
|
|
{:ok, fetched_beneficiaries} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert fetched_beneficiaries == MapSet.new() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "with nil rewards, returns {:error, reason}", %{ |
|
|
|
|
|
|
|
json_rpc_named_arguments: json_rpc_named_arguments |
|
|
|
|
|
|
|
} do |
|
|
|
|
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
|
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options -> |
|
|
|
|
|
|
|
{:ok, nil} |
|
|
|
|
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
result = EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
assert {:ok, %FetchedBeneficiaries{params_set: params_set}} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
assert result == {:error, "Error fetching block reward contract beneficiaries"} |
|
|
|
assert Enum.empty?(params_set) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -390,71 +381,72 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
hash2 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
|
|
|
|
|
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn %{params: [^block_quantity]}, _options -> |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn [%{id: id, params: [^block_quantity]}], _options -> |
|
|
|
{:ok, |
|
|
|
{:ok, |
|
|
|
[ |
|
|
|
[ |
|
|
|
%{ |
|
|
|
%{ |
|
|
|
"action" => %{ |
|
|
|
id: id, |
|
|
|
"callType" => "call", |
|
|
|
result: [ |
|
|
|
"from" => "0x95426f2bc716022fcf1def006dbc4bb81f5b5164", |
|
|
|
%{ |
|
|
|
"gas" => "0x0", |
|
|
|
"action" => %{ |
|
|
|
"input" => "0x", |
|
|
|
"callType" => "call", |
|
|
|
"to" => "0xe797a1da01eb0f951e0e400f9343de9d17a06bac", |
|
|
|
"from" => "0x95426f2bc716022fcf1def006dbc4bb81f5b5164", |
|
|
|
"value" => "0x4a817c800" |
|
|
|
"gas" => "0x0", |
|
|
|
}, |
|
|
|
"input" => "0x", |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"to" => "0xe797a1da01eb0f951e0e400f9343de9d17a06bac", |
|
|
|
"blockNumber" => block_number, |
|
|
|
"value" => "0x4a817c800" |
|
|
|
"result" => %{"gasUsed" => "0x0", "output" => "0x"}, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number, |
|
|
|
"transactionHash" => "0x5acf90f846b8216bdbc309cf4eb24adc69d730bf29304dc0e740cf6df850666e", |
|
|
|
"result" => %{"gasUsed" => "0x0", "output" => "0x"}, |
|
|
|
"transactionPosition" => 0, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "call" |
|
|
|
"traceAddress" => [], |
|
|
|
}, |
|
|
|
"transactionHash" => "0x5acf90f846b8216bdbc309cf4eb24adc69d730bf29304dc0e740cf6df850666e", |
|
|
|
%{ |
|
|
|
"transactionPosition" => 0, |
|
|
|
"action" => %{ |
|
|
|
"type" => "call" |
|
|
|
"author" => hash1, |
|
|
|
}, |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash1, |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"rewardType" => "block", |
|
|
|
"blockNumber" => block_number, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
}, |
|
|
|
"transactionHash" => nil, |
|
|
|
%{ |
|
|
|
"transactionPosition" => nil, |
|
|
|
"action" => %{ |
|
|
|
"type" => "reward" |
|
|
|
"author" => hash2, |
|
|
|
}, |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash2, |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"rewardType" => "block", |
|
|
|
"blockNumber" => block_number, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
"blockHash" => "0x6659a4926d833a7eab74379fa647ec74c9f5e65f8029552a35264126560f300a", |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
|
|
|
|
"transactionHash" => nil, |
|
|
|
|
|
|
|
"transactionPosition" => nil, |
|
|
|
|
|
|
|
"type" => "reward" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
]} |
|
|
|
]} |
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expected_beneficiaries = |
|
|
|
assert {:ok, %FetchedBeneficiaries{params_set: params_set}} = |
|
|
|
MapSet.new([ |
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_077_429..5_077_429, json_rpc_named_arguments) |
|
|
|
%{block_number: block_number, address_hash: hash2}, |
|
|
|
|
|
|
|
%{block_number: block_number, address_hash: hash1} |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, fetched_beneficiaries} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_077_429..5_077_429, json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert fetched_beneficiaries == expected_beneficiaries |
|
|
|
assert Enum.count(params_set) == 2 |
|
|
|
|
|
|
|
assert %{block_number: block_number, address_hash: hash2} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number, address_hash: hash1} in params_set |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with multiple blocks with repeat beneficiaries", %{ |
|
|
|
test "with multiple blocks with repeat beneficiaries", %{ |
|
|
@ -469,87 +461,92 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
hash3 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
hash3 = "0x523b6539ff08d72a6c8bb598af95bf50c1ea839c" |
|
|
|
|
|
|
|
|
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, 2, fn |
|
|
|
expect(EthereumJSONRPC.Mox, :json_rpc, fn requests, _options when is_list(requests) -> |
|
|
|
%{params: [^block_quantity1]} = _json, _options -> |
|
|
|
responses = |
|
|
|
{:ok, |
|
|
|
Enum.map(requests, fn |
|
|
|
[ |
|
|
|
%{id: id, params: [^block_quantity1]} -> |
|
|
|
%{ |
|
|
|
%{ |
|
|
|
"action" => %{ |
|
|
|
id: id, |
|
|
|
"author" => hash1, |
|
|
|
result: [ |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash1, |
|
|
|
"blockNumber" => block_number1, |
|
|
|
"rewardType" => "block", |
|
|
|
"result" => nil, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"subtraces" => 0, |
|
|
|
}, |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number1, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
}, |
|
|
|
"transactionHash" => nil, |
|
|
|
%{ |
|
|
|
"transactionPosition" => nil, |
|
|
|
"action" => %{ |
|
|
|
"type" => "reward" |
|
|
|
"author" => hash3, |
|
|
|
}, |
|
|
|
"rewardType" => "block", |
|
|
|
%{ |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"action" => %{ |
|
|
|
}, |
|
|
|
"author" => hash3, |
|
|
|
"blockNumber" => block_number1, |
|
|
|
"rewardType" => "block", |
|
|
|
"result" => nil, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"subtraces" => 0, |
|
|
|
}, |
|
|
|
"traceAddress" => [], |
|
|
|
"blockNumber" => block_number1, |
|
|
|
"transactionHash" => nil, |
|
|
|
"result" => nil, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"subtraces" => 0, |
|
|
|
"type" => "reward" |
|
|
|
"traceAddress" => [], |
|
|
|
} |
|
|
|
"transactionHash" => nil, |
|
|
|
]} |
|
|
|
"transactionPosition" => nil, |
|
|
|
|
|
|
|
"type" => "reward" |
|
|
|
%{params: [^block_quantity2]} = _json, _options -> |
|
|
|
} |
|
|
|
{:ok, |
|
|
|
] |
|
|
|
[ |
|
|
|
} |
|
|
|
%{ |
|
|
|
|
|
|
|
"action" => %{ |
|
|
|
%{id: id, params: [^block_quantity2]} -> |
|
|
|
"author" => hash2, |
|
|
|
%{ |
|
|
|
"rewardType" => "block", |
|
|
|
id: id, |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
result: [ |
|
|
|
}, |
|
|
|
%{ |
|
|
|
"blockNumber" => block_number2, |
|
|
|
"action" => %{ |
|
|
|
"result" => nil, |
|
|
|
"author" => hash2, |
|
|
|
"subtraces" => 0, |
|
|
|
"rewardType" => "block", |
|
|
|
"traceAddress" => [], |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"transactionHash" => nil, |
|
|
|
}, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"blockNumber" => block_number2, |
|
|
|
"type" => "reward" |
|
|
|
"result" => nil, |
|
|
|
}, |
|
|
|
"subtraces" => 0, |
|
|
|
%{ |
|
|
|
"traceAddress" => [], |
|
|
|
"action" => %{ |
|
|
|
"transactionHash" => nil, |
|
|
|
"author" => hash3, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"rewardType" => "block", |
|
|
|
"type" => "reward" |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
}, |
|
|
|
}, |
|
|
|
%{ |
|
|
|
"blockNumber" => block_number2, |
|
|
|
"action" => %{ |
|
|
|
"result" => nil, |
|
|
|
"author" => hash3, |
|
|
|
"subtraces" => 0, |
|
|
|
"rewardType" => "block", |
|
|
|
"traceAddress" => [], |
|
|
|
"value" => "0xde0b6b3a7640000" |
|
|
|
"transactionHash" => nil, |
|
|
|
}, |
|
|
|
"transactionPosition" => nil, |
|
|
|
"blockNumber" => block_number2, |
|
|
|
"type" => "reward" |
|
|
|
"result" => nil, |
|
|
|
} |
|
|
|
"subtraces" => 0, |
|
|
|
]} |
|
|
|
"traceAddress" => [], |
|
|
|
|
|
|
|
"transactionHash" => nil, |
|
|
|
|
|
|
|
"transactionPosition" => nil, |
|
|
|
|
|
|
|
"type" => "reward" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, responses} |
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expected_beneficiaries = |
|
|
|
assert {:ok, %FetchedBeneficiaries{params_set: params_set}} = |
|
|
|
MapSet.new([ |
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_886..5_080_887, json_rpc_named_arguments) |
|
|
|
%{block_number: block_number1, address_hash: hash3}, |
|
|
|
|
|
|
|
%{block_number: block_number2, address_hash: hash3}, |
|
|
|
|
|
|
|
%{block_number: block_number2, address_hash: hash2}, |
|
|
|
|
|
|
|
%{block_number: block_number1, address_hash: hash1} |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:ok, fetched_beneficiaries} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_886..5_080_887, json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert fetched_beneficiaries == expected_beneficiaries |
|
|
|
assert Enum.count(params_set) == 4 |
|
|
|
|
|
|
|
assert %{block_number: block_number1, address_hash: hash3} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number2, address_hash: hash3} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number2, address_hash: hash2} in params_set |
|
|
|
|
|
|
|
assert %{block_number: block_number1, address_hash: hash1} in params_set |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "with error, returns {:error, reason}", %{ |
|
|
|
test "with error, returns {:error, reason}", %{ |
|
|
@ -560,9 +557,8 @@ defmodule EthereumJSONRPC.ParityTest do |
|
|
|
{:error, "oops"} |
|
|
|
{:error, "oops"} |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
result = EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
assert {:error, "oops"} = |
|
|
|
|
|
|
|
EthereumJSONRPC.Parity.fetch_beneficiaries(5_080_887..5_080_887, json_rpc_named_arguments) |
|
|
|
assert result == {:error, "Error fetching block reward contract beneficiaries"} |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|