|
|
|
@ -366,6 +366,41 @@ defmodule Explorer.SmartContract.ReaderTest do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "get_abi_with_method_id" do |
|
|
|
|
test "add method_id to the ABI method" do |
|
|
|
|
method = %{ |
|
|
|
|
"constant" => true, |
|
|
|
|
"inputs" => [%{"name" => "_message", "type" => "bytes32"}], |
|
|
|
|
"name" => "numMessagesSigned", |
|
|
|
|
"outputs" => [%{"name" => "", "type" => "uint256"}], |
|
|
|
|
"payable" => false, |
|
|
|
|
"stateMutability" => "view", |
|
|
|
|
"type" => "function" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
abi = [method] |
|
|
|
|
method_with_id = Map.put(method, "method_id", "0cbf0601") |
|
|
|
|
assert [method_with_id] = Reader.get_abi_with_method_id(abi) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "do not crash in some corner cases" do |
|
|
|
|
abi = [ |
|
|
|
|
%{"payable" => true, "stateMutability" => "payable", "type" => "fallback"}, |
|
|
|
|
%{ |
|
|
|
|
"anonymous" => false, |
|
|
|
|
"inputs" => [ |
|
|
|
|
%{"indexed" => false, "name" => "recipient", "type" => "address"}, |
|
|
|
|
%{"indexed" => false, "name" => "value", "type" => "uint256"} |
|
|
|
|
], |
|
|
|
|
"name" => "UserRequestForSignature", |
|
|
|
|
"type" => "event" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
assert abi = Reader.get_abi_with_method_id(abi) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp blockchain_get_function_mock do |
|
|
|
|
expect( |
|
|
|
|
EthereumJSONRPC.Mox, |
|
|
|
|