diff --git a/.github/workflows/elixir_ci.yml b/.github/workflows/elixir_ci.yml index 4ab0a9c..aae9569 100644 --- a/.github/workflows/elixir_ci.yml +++ b/.github/workflows/elixir_ci.yml @@ -69,8 +69,7 @@ jobs: ETH_USER_PK: ${{ secrets.ETH_USER_PK }} run: | cd eth_client/ - mix test - + mix test --seed 0 - name: Code Coverage env: ETH_API_KEY: ${{ secrets.ETH_API_KEY }} diff --git a/eth_client/test/abi_test.exs b/eth_client/test/abi_test.exs new file mode 100644 index 0000000..5ce6113 --- /dev/null +++ b/eth_client/test/abi_test.exs @@ -0,0 +1,67 @@ +defmodule EthClientTest.ABI do + use ExUnit.Case + doctest EthClient + alias EthClient.ABI + alias EthClient.Context + + @bin "../contracts/src/bin/Storage.bin" + @abi "../contracts/src/bin/Storage.abi" + + setup_all do + # Context.set_chain_id(4) + # Context.set_rpc_host("") + contract = EthClient.deploy(@bin, @abi) + :ok + end + + describe "get/1" do + test "[SUCCESS] Get an ABI by an abi path", %{} do + result = ABI.get(@abi) + + assert {:ok, + [ + %{ + "inputs" => [], + "name" => "retrieve", + "outputs" => [ + %{"internalType" => "uint256", "name" => "", "type" => "uint256"} + ], + "stateMutability" => "view", + "type" => "function" + }, + %{ + "inputs" => [ + %{"internalType" => "uint256", "name" => "num", "type" => "uint256"} + ], + "name" => "store", + "outputs" => [], + "stateMutability" => "nonpayable", + "type" => "function" + }, + %{ + "inputs" => [], + "name" => "test_function", + "outputs" => [ + %{"internalType" => "uint256", "name" => "", "type" => "uint256"} + ], + "stateMutability" => "pure", + "type" => "function" + } + ]} == result + end + + test "[SUCCESS] Get an ABI by an ABI address" do + address = Context.user_account().address + + assert {:ok, _response} = ABI.get(address) + end + + test "[FAILURE] Get an ABI by an invalid ABI address" do + address = '0x0' + + assert_raise MatchError, fn -> + ABI.get(address) + end + end + end +end