|
|
|
@ -29,17 +29,19 @@ defmodule EXW3Test do |
|
|
|
|
assert context[:simple_storage_abi] |> is_map |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "mines a block" do |
|
|
|
|
block_number = ExW3.block_number() |
|
|
|
|
ExW3.mine() |
|
|
|
|
assert ExW3.block_number() == block_number + 1 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "mines multiple blocks" do |
|
|
|
|
block_number = ExW3.block_number() |
|
|
|
|
ExW3.mine(5) |
|
|
|
|
assert ExW3.block_number() == block_number + 5 |
|
|
|
|
end |
|
|
|
|
# Only works with ganache-cli |
|
|
|
|
|
|
|
|
|
# test "mines a block" do |
|
|
|
|
# block_number = ExW3.block_number() |
|
|
|
|
# ExW3.mine() |
|
|
|
|
# assert ExW3.block_number() == block_number + 1 |
|
|
|
|
# end |
|
|
|
|
|
|
|
|
|
# test "mines multiple blocks" do |
|
|
|
|
# block_number = ExW3.block_number() |
|
|
|
|
# ExW3.mine(5) |
|
|
|
|
# assert ExW3.block_number() == block_number + 5 |
|
|
|
|
# end |
|
|
|
|
|
|
|
|
|
test "keccak256 hash some data" do |
|
|
|
|
hash = ExW3.keccak256("foo") |
|
|
|
@ -77,7 +79,7 @@ defmodule EXW3Test do |
|
|
|
|
|
|
|
|
|
assert data == 0 |
|
|
|
|
|
|
|
|
|
ExW3.Contract.send(SimpleStorage, :set, [1], %{from: Enum.at(context[:accounts], 0)}) |
|
|
|
|
ExW3.Contract.send(SimpleStorage, :set, [1], %{from: Enum.at(context[:accounts], 0), gas: 50_000}) |
|
|
|
|
|
|
|
|
|
{:ok, data} = ExW3.Contract.call(SimpleStorage, :get) |
|
|
|
|
|
|
|
|
@ -131,7 +133,8 @@ defmodule EXW3Test do |
|
|
|
|
|
|
|
|
|
{:ok, tx_hash} = |
|
|
|
|
ExW3.Contract.send(EventTester, :simple, ["Hello, World!"], %{ |
|
|
|
|
from: Enum.at(context[:accounts], 0) |
|
|
|
|
from: Enum.at(context[:accounts], 0), |
|
|
|
|
gas: 30_000 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
{:ok, {receipt, logs}} = ExW3.Contract.tx_receipt(EventTester, tx_hash) |
|
|
|
@ -173,7 +176,7 @@ defmodule EXW3Test do |
|
|
|
|
EventTester, |
|
|
|
|
:simple, |
|
|
|
|
["Hello, World!"], |
|
|
|
|
%{from: Enum.at(context[:accounts], 0)} |
|
|
|
|
%{from: Enum.at(context[:accounts], 0), gas: 30_000} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
receive do |
|
|
|
|