Provide default 2nd arg for executing contract functions on Geth (#970)

pull/977/head
Alex Garibay 6 years ago committed by GitHub
parent 3a077592ed
commit 1f021a7e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs
  2. 2
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
  3. 2
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc_test.exs
  4. 16
      apps/explorer/test/explorer/smart_contract/reader_test.exs

@ -147,11 +147,11 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
end end
end end
defp blockchain_get_function_mock() do defp blockchain_get_function_mock do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: id, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000000"}]} {:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000000"}]}
end end
) )

@ -147,7 +147,7 @@ defmodule EthereumJSONRPC do
%{contract_address: address, data: data, id: id}, %{contract_address: address, data: data, id: id},
nil = _block_number nil = _block_number
) do ) do
params = [%{to: address, data: data}] params = [%{to: address, data: data}, "latest"]
request(%{id: id, method: "eth_call", params: params}) request(%{id: id, method: "eth_call", params: params})
end end

@ -792,7 +792,7 @@ defmodule EthereumJSONRPCTest do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: id, method: _, params: [%{data: _, to: _}, "latest"]}], _options ->
{:ok, {:ok,
[ [
%{ %{

@ -2,12 +2,12 @@ defmodule Explorer.SmartContract.ReaderTest do
use EthereumJSONRPC.Case use EthereumJSONRPC.Case
use Explorer.DataCase use Explorer.DataCase
doctest Explorer.SmartContract.Reader import Mox
alias Explorer.SmartContract.Reader alias Explorer.SmartContract.Reader
alias Explorer.Chain.Hash alias Explorer.Chain.Hash
import Mox doctest Explorer.SmartContract.Reader
setup :verify_on_exit! setup :verify_on_exit!
@ -55,7 +55,7 @@ defmodule Explorer.SmartContract.ReaderTest do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: id, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:ok, [%{id: id, jsonrpc: "2.0", error: %{code: "12345", message: "Error message"}}]} {:ok, [%{id: id, jsonrpc: "2.0", error: %{code: "12345", message: "Error message"}}]}
end end
) )
@ -73,7 +73,7 @@ defmodule Explorer.SmartContract.ReaderTest do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: _, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: _, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:error, {:bad_gateway, "request_url"}} {:error, {:bad_gateway, "request_url"}}
end end
) )
@ -91,7 +91,7 @@ defmodule Explorer.SmartContract.ReaderTest do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: _, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: _, method: _, params: [%{data: _, to: _}, _]}], _options ->
raise FunctionClauseError raise FunctionClauseError
end end
) )
@ -137,7 +137,7 @@ defmodule Explorer.SmartContract.ReaderTest do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: id, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000012"}]} {:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000012"}]}
end end
) )
@ -319,11 +319,11 @@ defmodule Explorer.SmartContract.ReaderTest do
end end
end end
defp blockchain_get_function_mock() do defp blockchain_get_function_mock do
expect( expect(
EthereumJSONRPC.Mox, EthereumJSONRPC.Mox,
:json_rpc, :json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}]}], _options -> fn [%{id: id, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000000"}]} {:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000000"}]}
end end
) )

Loading…
Cancel
Save