From 79ce6b99bdc9c809a690b952e066f6e5ab5857ee Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Mon, 6 Jun 2022 09:01:19 -0500 Subject: [PATCH 01/16] tests rpc v1 --- eth_client/lib/eth_client.ex | 8 +-- eth_client/test/eth_rpc_test.exs | 92 ++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 eth_client/test/eth_rpc_test.exs diff --git a/eth_client/lib/eth_client.ex b/eth_client/lib/eth_client.ex index f990199..910853a 100644 --- a/eth_client/lib/eth_client.ex +++ b/eth_client/lib/eth_client.ex @@ -164,7 +164,7 @@ defmodule EthClient do Logger.info("#{chain_name} is not a supported chain.") end - defp nonce(address) do + def nonce(address) do {nonce, ""} = Rpc.get_transaction_count(address) |> remove_leading_0x() @@ -173,7 +173,7 @@ defmodule EthClient do nonce end - defp gas_limit(data, caller_address, recipient_address \\ nil) do + def gas_limit(data, caller_address, recipient_address \\ nil) do {gas, ""} = %{ from: caller_address, @@ -187,7 +187,7 @@ defmodule EthClient do gas end - defp gas_price do + def gas_price do {gas_price, ""} = Rpc.gas_price() |> remove_leading_0x() @@ -201,7 +201,7 @@ defmodule EthClient do defp wei_to_ether(amount), do: amount / 1.0e19 - defp build_raw_tx(amount, nonce, gas_limit, gas_price, opts) do + def build_raw_tx(amount, nonce, gas_limit, gas_price, opts) do recipient = opts[:recipient] data = opts[:data] chain_id = Context.chain_id() diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs new file mode 100644 index 0000000..d507a07 --- /dev/null +++ b/eth_client/test/eth_rpc_test.exs @@ -0,0 +1,92 @@ +defmodule EthClientTest.Rpc do + use ExUnit.Case + alias EthClient.Context + alias EthClient.Rpc + alias EthClient + @bin_path "../contracts/src/bin/Storage.bin" + + defp add_0x(data), do: "0x" <> data + + def transaction_deploy() do + :ok = EthClient.set_chain("local") + {:ok, data} = File.read(@bin_path) + data = add_0x(data) + + caller = Context.user_account() + caller_address = String.downcase(caller.address) + contract_address = Context.contract().address + + nonce = EthClient.nonce(caller.address) + gas_limit = EthClient.gas_limit(data, caller_address) + + raw_tx = + EthClient.build_raw_tx( + 0, + nonce, + gas_limit, + EthClient.gas_price(), + data: data + ) + + tx_hash = EthClient.sign_transaction(raw_tx, caller.private_key) |> IO.inspect(label: "TX HAAAAAAAAAAASH") + + %{ + data: data, + caller: caller, + caller_address: caller_address, + contract_address: contract_address, + nonce: nonce, + gas_limit: gas_limit, + raw_tx: raw_tx, + tx_hash: tx_hash + } + end + + setup_all do + transaction_deploy() + end + + describe "Rpc Module" do + test "[SUCCESS] Send raw transaction", state do + assert {:ok, tx_hash} = Rpc.send_raw_transaction(state[:tx_hash]) + end + + test "[SUCCESS] Estimate Gas", state do + transaction_map = %{data: state[:data], from: state[:caller_address], to: nil} + assert {:ok, gas} = Rpc.estimate_gas(transaction_map) + end + + test "[SUCCESS] Get Transaction Count", state do + assert {:ok, count} = Rpc.get_transaction_count(state[:caller_address]) + end + + test "[SUCCESS] Gas Price" do + assert {:ok, price} = Rpc.gas_price() + end + + test "[SUCCESS] Get Transaction by Hash" do + assert {:ok, %{}} = Rpc.get_transaction_by_hash("0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019") + end + + test "[SUCCESS] Get Transaction Receipt" do + assert {:ok, %{}} = Rpc.get_transaction_receipt("0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019") + end + + test "[SUCCESS] Get Code", state do + assert {:ok, "0x"} = Rpc.get_code(state[:caller_address]) + end + + test "[SUCCESS] Get Call", state do + call_map = %{} + assert {:ok, "0x"} = Rpc.call(call_map) + end + + test "[SUCCESS] Get Logs" do + assert {:ok, []} = Rpc.get_logs(%{}) + end + + test "[SUCCESS] Get Balance", state do + assert {:ok, balance} = Rpc.get_balance(state[:caller_address]) + end + end +end From d0531e76ece5401e5b3b8fde19cb4bc729a24f60 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Mon, 6 Jun 2022 09:17:38 -0500 Subject: [PATCH 02/16] format --- eth_client/test/eth_rpc_test.exs | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index d507a07..92f1442 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -28,18 +28,18 @@ defmodule EthClientTest.Rpc do data: data ) - tx_hash = EthClient.sign_transaction(raw_tx, caller.private_key) |> IO.inspect(label: "TX HAAAAAAAAAAASH") - - %{ - data: data, - caller: caller, - caller_address: caller_address, - contract_address: contract_address, - nonce: nonce, - gas_limit: gas_limit, - raw_tx: raw_tx, - tx_hash: tx_hash - } + tx_hash = EthClient.sign_transaction(raw_tx, caller.private_key) + + %{ + data: data, + caller: caller, + caller_address: caller_address, + contract_address: contract_address, + nonce: nonce, + gas_limit: gas_limit, + raw_tx: raw_tx, + tx_hash: tx_hash + } end setup_all do @@ -65,11 +65,17 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Transaction by Hash" do - assert {:ok, %{}} = Rpc.get_transaction_by_hash("0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019") + assert {:ok, %{}} = + Rpc.get_transaction_by_hash( + "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + ) end test "[SUCCESS] Get Transaction Receipt" do - assert {:ok, %{}} = Rpc.get_transaction_receipt("0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019") + assert {:ok, %{}} = + Rpc.get_transaction_receipt( + "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + ) end test "[SUCCESS] Get Code", state do From 932e7781786ccbe655a9341e38f0dfcc0b5aec16 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Mon, 6 Jun 2022 09:40:34 -0500 Subject: [PATCH 03/16] format --- eth_client/test/eth_rpc_test.exs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 92f1442..e80e5da 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -1,13 +1,14 @@ defmodule EthClientTest.Rpc do use ExUnit.Case + alias EthClient alias EthClient.Context alias EthClient.Rpc - alias EthClient + @bin_path "../contracts/src/bin/Storage.bin" defp add_0x(data), do: "0x" <> data - def transaction_deploy() do + def transaction_deploy do :ok = EthClient.set_chain("local") {:ok, data} = File.read(@bin_path) data = add_0x(data) From f66bbb72862097c737b5b2567e215b1e878af44d Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Mon, 6 Jun 2022 16:32:58 -0500 Subject: [PATCH 04/16] asserts improved --- eth_client/test/eth_rpc_test.exs | 73 ++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index e80e5da..e8917f1 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -3,12 +3,11 @@ defmodule EthClientTest.Rpc do alias EthClient alias EthClient.Context alias EthClient.Rpc - @bin_path "../contracts/src/bin/Storage.bin" defp add_0x(data), do: "0x" <> data - def transaction_deploy do + def transaction_deploy() do :ok = EthClient.set_chain("local") {:ok, data} = File.read(@bin_path) data = add_0x(data) @@ -49,43 +48,82 @@ defmodule EthClientTest.Rpc do describe "Rpc Module" do test "[SUCCESS] Send raw transaction", state do - assert {:ok, tx_hash} = Rpc.send_raw_transaction(state[:tx_hash]) + {:ok, tx_hash} = Rpc.send_raw_transaction(state[:tx_hash]) + assert tx_hash =~ "0x" end test "[SUCCESS] Estimate Gas", state do transaction_map = %{data: state[:data], from: state[:caller_address], to: nil} - assert {:ok, gas} = Rpc.estimate_gas(transaction_map) + {:ok, gas} = Rpc.estimate_gas(transaction_map) + assert gas =~ "0x" end test "[SUCCESS] Get Transaction Count", state do - assert {:ok, count} = Rpc.get_transaction_count(state[:caller_address]) + {:ok, count} = Rpc.get_transaction_count(state[:caller_address]) + assert count =~ "0x" end test "[SUCCESS] Gas Price" do - assert {:ok, price} = Rpc.gas_price() + {:ok, gas_price} = Rpc.gas_price() + assert gas_price =~ "0x" end test "[SUCCESS] Get Transaction by Hash" do - assert {:ok, %{}} = - Rpc.get_transaction_by_hash( - "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" - ) + {:ok, transaction_map} = + Rpc.get_transaction_by_hash( + "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + ) + + assert %{ + "blockHash" => _, + "blockNumber" => _, + "from" => _, + "gas" => _, + "gasPrice" => _, + "hash" => _, + "input" => _, + "nonce" => _, + "r" => _, + "s" => _, + "to" => nil, + "transactionIndex" => _, + "type" => _, + "v" => _, + "value" => _ + } = transaction_map end test "[SUCCESS] Get Transaction Receipt" do - assert {:ok, %{}} = - Rpc.get_transaction_receipt( - "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" - ) + {:ok, receipt_map} = + Rpc.get_transaction_receipt( + "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + ) + + assert %{ + "blockHash" => _blockhash, + "blockNumber" => _blocknumber, + "contractAddress" => _contactAdress, + "cumulativeGasUsed" => _cumulativeGasUsed, + "effectiveGasPrice" => _effectiveGasPrice, + "from" => _from, + "gasUsed" => _gasUser, + "logs" => [], + "logsBloom" => _logsBloom, + "status" => _status, + "to" => nil, + "transactionHash" => _transactionHash, + "transactionIndex" => _transactionIndex, + "type" => _type + } = receipt_map end test "[SUCCESS] Get Code", state do - assert {:ok, "0x"} = Rpc.get_code(state[:caller_address]) + assert {:ok, "0x"} == Rpc.get_code(state[:caller_address]) end test "[SUCCESS] Get Call", state do call_map = %{} - assert {:ok, "0x"} = Rpc.call(call_map) + assert {:ok, "0x"} == Rpc.call(call_map) end test "[SUCCESS] Get Logs" do @@ -93,7 +131,8 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Balance", state do - assert {:ok, balance} = Rpc.get_balance(state[:caller_address]) + {:ok, balance} = Rpc.get_balance(state[:caller_address]) + assert balance =~ "0x" end end end From 3fbdefe9094aebf566482a12b6c0b223b0a47e49 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Tue, 7 Jun 2022 14:12:49 -0500 Subject: [PATCH 05/16] refactor --- eth_client/test/eth_rpc_test.exs | 43 +++++++++++++------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index e8917f1..da594e9 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -3,42 +3,20 @@ defmodule EthClientTest.Rpc do alias EthClient alias EthClient.Context alias EthClient.Rpc - @bin_path "../contracts/src/bin/Storage.bin" - defp add_0x(data), do: "0x" <> data + @bin_path "../contracts/src/bin/Storage.bin" def transaction_deploy() do :ok = EthClient.set_chain("local") {:ok, data} = File.read(@bin_path) - data = add_0x(data) + data = "0x" <> data caller = Context.user_account() caller_address = String.downcase(caller.address) - contract_address = Context.contract().address - - nonce = EthClient.nonce(caller.address) - gas_limit = EthClient.gas_limit(data, caller_address) - - raw_tx = - EthClient.build_raw_tx( - 0, - nonce, - gas_limit, - EthClient.gas_price(), - data: data - ) - - tx_hash = EthClient.sign_transaction(raw_tx, caller.private_key) %{ data: data, - caller: caller, - caller_address: caller_address, - contract_address: contract_address, - nonce: nonce, - gas_limit: gas_limit, - raw_tx: raw_tx, - tx_hash: tx_hash + caller_address: caller_address } end @@ -48,7 +26,20 @@ defmodule EthClientTest.Rpc do describe "Rpc Module" do test "[SUCCESS] Send raw transaction", state do - {:ok, tx_hash} = Rpc.send_raw_transaction(state[:tx_hash]) + caller = Context.user_account() + + raw_tx = + EthClient.build_raw_tx( + 0, + EthClient.nonce(caller.address), + EthClient.gas_limit(state[:data], caller.address), + EthClient.gas_price(), + data: state[:data] + ) + + tx_hash = EthClient.sign_transaction(raw_tx, Context.user_account().private_key) + + {:ok, tx_hash} = Rpc.send_raw_transaction(tx_hash) assert tx_hash =~ "0x" end From 0c732e8aec25e929cc3d4d3555b7796e8bbae5da Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 8 Jun 2022 14:49:33 -0500 Subject: [PATCH 06/16] prenthesis removed --- eth_client/test/eth_rpc_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index da594e9..8f550af 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -6,7 +6,7 @@ defmodule EthClientTest.Rpc do @bin_path "../contracts/src/bin/Storage.bin" - def transaction_deploy() do + def transaction_deploy do :ok = EthClient.set_chain("local") {:ok, data} = File.read(@bin_path) data = "0x" <> data From 16d8faca08d18e0e2a7f59abc2c4b7dc5ca67f84 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Tue, 14 Jun 2022 16:10:14 -0500 Subject: [PATCH 07/16] fixes --- eth_client/test/eth_client_test.exs | 2 +- eth_client/test/eth_contract_opcodes_test.exs | 2 +- eth_client/test/eth_rpc_test.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eth_client/test/eth_client_test.exs b/eth_client/test/eth_client_test.exs index 743cf8b..99f33b6 100644 --- a/eth_client/test/eth_client_test.exs +++ b/eth_client/test/eth_client_test.exs @@ -1,4 +1,4 @@ defmodule EthClientTest do use ExUnit.Case - doctest EthClient + #doctest EthClient end diff --git a/eth_client/test/eth_contract_opcodes_test.exs b/eth_client/test/eth_contract_opcodes_test.exs index fb117eb..a41ff82 100644 --- a/eth_client/test/eth_contract_opcodes_test.exs +++ b/eth_client/test/eth_contract_opcodes_test.exs @@ -1,6 +1,6 @@ defmodule EthClientTest.Contract.Opcodes do use ExUnit.Case - doctest EthClient + #doctest EthClient alias EthClient.Contract.Opcodes import ExUnit.CaptureIO diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 8f550af..a40dfd0 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -112,7 +112,7 @@ defmodule EthClientTest.Rpc do assert {:ok, "0x"} == Rpc.get_code(state[:caller_address]) end - test "[SUCCESS] Get Call", state do + test "[SUCCESS] Get Call" do call_map = %{} assert {:ok, "0x"} == Rpc.call(call_map) end From 075a965a9711d3f74d10c1e9296c28797778d368 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Tue, 14 Jun 2022 16:24:12 -0500 Subject: [PATCH 08/16] credo --- eth_client/test/eth_rpc_test.exs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index a40dfd0..3fdf4d2 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -93,17 +93,10 @@ defmodule EthClientTest.Rpc do assert %{ "blockHash" => _blockhash, "blockNumber" => _blocknumber, - "contractAddress" => _contactAdress, - "cumulativeGasUsed" => _cumulativeGasUsed, - "effectiveGasPrice" => _effectiveGasPrice, "from" => _from, - "gasUsed" => _gasUser, "logs" => [], - "logsBloom" => _logsBloom, "status" => _status, "to" => nil, - "transactionHash" => _transactionHash, - "transactionIndex" => _transactionIndex, "type" => _type } = receipt_map end From 47f87579ff01622f203befb6ed815a7458e6d706 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Tue, 14 Jun 2022 16:54:58 -0500 Subject: [PATCH 09/16] format --- eth_client/test/eth_contract_opcodes_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_contract_opcodes_test.exs b/eth_client/test/eth_contract_opcodes_test.exs index a41ff82..28b1695 100644 --- a/eth_client/test/eth_contract_opcodes_test.exs +++ b/eth_client/test/eth_contract_opcodes_test.exs @@ -1,6 +1,6 @@ defmodule EthClientTest.Contract.Opcodes do use ExUnit.Case - #doctest EthClient + # doctest EthClient alias EthClient.Contract.Opcodes import ExUnit.CaptureIO From 6e2d615376c85cd49458eef3dc2450c619ee6e6c Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Tue, 21 Jun 2022 14:37:06 -0500 Subject: [PATCH 10/16] rinkeby --- eth_client/test/eth_rpc_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 3fdf4d2..9598389 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -7,7 +7,7 @@ defmodule EthClientTest.Rpc do @bin_path "../contracts/src/bin/Storage.bin" def transaction_deploy do - :ok = EthClient.set_chain("local") + :ok = EthClient.set_chain("rinkeby") {:ok, data} = File.read(@bin_path) data = "0x" <> data From d3b095c991534b83daa82eaf7db6f94090fac16c Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 09:07:51 -0500 Subject: [PATCH 11/16] infura --- eth_client/test/eth_rpc_test.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 9598389..a27cf9d 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -8,6 +8,7 @@ defmodule EthClientTest.Rpc do def transaction_deploy do :ok = EthClient.set_chain("rinkeby") + Context.set_rpc_host("https://rinkeby.infura.io/v3/56725ef0a57448cdb2c5dc36c277460b") {:ok, data} = File.read(@bin_path) data = "0x" <> data From 83dde57e9cc7ced37f119c0548668dd1c94cdd23 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 17:09:29 -0500 Subject: [PATCH 12/16] test fix --- eth_client/test/eth_rpc_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index a27cf9d..0ea4f7f 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -112,7 +112,7 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Logs" do - assert {:ok, []} = Rpc.get_logs(%{}) + assert {:ok, []} == Rpc.get_logs(%{}) end test "[SUCCESS] Get Balance", state do From d1ff8e55a992c4770b8b38c9229e3eff5b396bf1 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 17:26:54 -0500 Subject: [PATCH 13/16] f --- eth_client/test/eth_rpc_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 0ea4f7f..4965079 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -112,7 +112,7 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Logs" do - assert {:ok, []} == Rpc.get_logs(%{}) + assert {:ok, list} == Rpc.get_logs(%{}) end test "[SUCCESS] Get Balance", state do From 488309a858e322e33c1edcd6dd13ea09fbdd3e8f Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 17:56:53 -0500 Subject: [PATCH 14/16] format % fix --- eth_client/test/eth_rpc_test.exs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 4965079..665e271 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -63,7 +63,7 @@ defmodule EthClientTest.Rpc do test "[SUCCESS] Get Transaction by Hash" do {:ok, transaction_map} = Rpc.get_transaction_by_hash( - "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + "0x3c249fcbb9ac3095cbe8196e6dba5d0aa0d868f2ebc7c857c8a22144fcbad07c" ) assert %{ @@ -77,7 +77,7 @@ defmodule EthClientTest.Rpc do "nonce" => _, "r" => _, "s" => _, - "to" => nil, + "to" => _to, "transactionIndex" => _, "type" => _, "v" => _, @@ -88,16 +88,23 @@ defmodule EthClientTest.Rpc do test "[SUCCESS] Get Transaction Receipt" do {:ok, receipt_map} = Rpc.get_transaction_receipt( - "0xf6bebadd44e6d5e1446f6456ae4c4fcb8309631747714199e505aa4cec1c2019" + "0x3c249fcbb9ac3095cbe8196e6dba5d0aa0d868f2ebc7c857c8a22144fcbad07c" ) assert %{ "blockHash" => _blockhash, "blockNumber" => _blocknumber, + "contractAddress" => _contactAdress, + "cumulativeGasUsed" => _cumulativeGasUsed, + "effectiveGasPrice" => _effectiveGasPrice, "from" => _from, + "gasUsed" => _gasUser, "logs" => [], + "logsBloom" => _logsBloom, "status" => _status, - "to" => nil, + "to" => _to, + "transactionHash" => _transactionHash, + "transactionIndex" => _transactionIndex, "type" => _type } = receipt_map end @@ -112,7 +119,7 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Logs" do - assert {:ok, list} == Rpc.get_logs(%{}) + assert {:ok, _log_list} == Rpc.get_logs(%{}) end test "[SUCCESS] Get Balance", state do From 5feae522e12423442dcc4d0b4074dcd1c6b04e4a Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 18:00:29 -0500 Subject: [PATCH 15/16] credo --- eth_client/test/eth_rpc_test.exs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index 665e271..d3f3d1d 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -94,17 +94,10 @@ defmodule EthClientTest.Rpc do assert %{ "blockHash" => _blockhash, "blockNumber" => _blocknumber, - "contractAddress" => _contactAdress, - "cumulativeGasUsed" => _cumulativeGasUsed, - "effectiveGasPrice" => _effectiveGasPrice, "from" => _from, - "gasUsed" => _gasUser, "logs" => [], - "logsBloom" => _logsBloom, "status" => _status, "to" => _to, - "transactionHash" => _transactionHash, - "transactionIndex" => _transactionIndex, "type" => _type } = receipt_map end From 3c153624cf6d9a47ed1425eb6033769635e986f3 Mon Sep 17 00:00:00 2001 From: Cristhian Cotes Date: Wed, 22 Jun 2022 18:05:02 -0500 Subject: [PATCH 16/16] fix --- eth_client/test/eth_rpc_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth_client/test/eth_rpc_test.exs b/eth_client/test/eth_rpc_test.exs index d3f3d1d..126bc44 100644 --- a/eth_client/test/eth_rpc_test.exs +++ b/eth_client/test/eth_rpc_test.exs @@ -112,7 +112,7 @@ defmodule EthClientTest.Rpc do end test "[SUCCESS] Get Logs" do - assert {:ok, _log_list} == Rpc.get_logs(%{}) + assert {:ok, _log_list} = Rpc.get_logs(%{}) end test "[SUCCESS] Get Balance", state do