Skip to content

Commit ce3616e

Browse files
committed
Test scripts for ethclient.ex
1 parent 8988890 commit ce3616e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

eth_client/test/eth_client_test.exs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
defmodule EthClientTest do
22
use ExUnit.Case
33
doctest EthClient
4+
alias EthClient.Context
5+
alias EthClient.Account
6+
7+
@bin "../contracts/src/bin/Storage.bin"
8+
@abi "../contracts/src/bin/Storage.abi"
9+
10+
describe "Ethereum war tooling functions" do
11+
test "Deploy" do
12+
bin = @bin
13+
abi = @abi
14+
15+
contract = EthClient.deploy(bin, abi)
16+
assert contract == EthClient.Context.contract()
17+
end
18+
19+
test "Invoke" do
20+
bin = @bin
21+
abi = @abi
22+
23+
contract = EthClient.deploy(bin, abi)
24+
{:ok, tx_ans} = EthClient.invoke("store(uint256)", [3], 0)
25+
assert tx_ans != nil
26+
end
27+
28+
test "Call" do
29+
bin = @bin
30+
abi = @abi
31+
32+
contract = EthClient.deploy(bin, abi)
33+
{:ok, res} = EthClient.call("retrieve()", [])
34+
assert res == "0x0000000000000000000000000000000000000000000000000000000000000000"
35+
{:ok, res} = EthClient.call("test_function()", [])
36+
assert res == "0x0000000000000000000000000000000000000000000000000000000000000001"
37+
end
38+
39+
test "Balance" do
40+
bin = @bin
41+
abi = @abi
42+
43+
contract = EthClient.deploy(bin, abi)
44+
45+
assert 0.0 == EthClient.get_balance(contract.address)
46+
end
47+
end
448
end

0 commit comments

Comments
 (0)