4
0
Fork 0

Changed get_changes to get_filter_changes, filter now returns ok

new-events
hswick 6 years ago
parent 0aad3bcecd
commit 477e566649
  1. 10
      lib/exw3.ex
  2. 16
      test/exw3_test.exs

@ -461,11 +461,11 @@ defmodule ExW3 do
)
end
@spec get_changes(binary(), integer()) :: {:ok, []}
def get_changes(filter_id, seconds \\ 0) do
@spec get_filter_changes(binary(), integer()) :: {:ok, []}
def get_filter_changes(filter_id, seconds \\ 0) do
GenServer.call(
ContractManager,
{:get_changes, {filter_id, seconds}}
{:get_filter_changes, {filter_id, seconds}}
)
end
@ -788,10 +788,10 @@ defmodule ExW3 do
filter_id = ExW3.new_filter(payload)
{:reply, filter_id, Map.put(state, :filters, Map.put(state[:filters], filter_id, %{contract_name: contract_name, event_name: event_name}))}
{:reply, {:ok, filter_id}, Map.put(state, :filters, Map.put(state[:filters], filter_id, %{contract_name: contract_name, event_name: event_name}))}
end
def handle_call({:get_changes, {filter_id, seconds}}, _from, state) do
def handle_call({:get_filter_changes, {filter_id, seconds}}, _from, state) do
:timer.sleep(1000 * seconds)

@ -202,7 +202,7 @@ defmodule EXW3Test do
# Test non indexed events
filter_id = ExW3.Contract.filter(:EventTester, "Simple")
{:ok, filter_id} = ExW3.Contract.filter(:EventTester, "Simple")
{:ok, _tx_hash} =
ExW3.Contract.send(
@ -212,7 +212,7 @@ defmodule EXW3Test do
%{from: Enum.at(context[:accounts], 0), gas: 30_000}
)
{:ok, change_logs} = ExW3.Contract.get_changes(filter_id)
{:ok, change_logs} = ExW3.Contract.get_filter_changes(filter_id)
event_log = Enum.at(change_logs, 0)
@ -227,7 +227,7 @@ defmodule EXW3Test do
# Test indexed events
indexed_filter_id = ExW3.Contract.filter(:EventTester, "SimpleIndex")
{:ok, indexed_filter_id} = ExW3.Contract.filter(:EventTester, "SimpleIndex")
{:ok, _tx_hash} =
ExW3.Contract.send(
@ -237,7 +237,7 @@ defmodule EXW3Test do
%{from: Enum.at(context[:accounts], 0), gas: 30_000}
)
{:ok, change_logs} = ExW3.Contract.get_changes(indexed_filter_id)
{:ok, change_logs} = ExW3.Contract.get_filter_changes(indexed_filter_id)
event_log = Enum.at(change_logs, 0)
@ -251,7 +251,7 @@ defmodule EXW3Test do
# Test Indexing Indexed Events
indexed_filter_id =
{:ok, indexed_filter_id} =
ExW3.Contract.filter(
:EventTester,
"SimpleIndex",
@ -270,7 +270,7 @@ defmodule EXW3Test do
%{from: Enum.at(context[:accounts], 0), gas: 30_000}
)
{:ok, change_logs} = ExW3.Contract.get_changes(indexed_filter_id)
{:ok, change_logs} = ExW3.Contract.get_filter_changes(indexed_filter_id)
event_log = Enum.at(change_logs, 0)
assert event_log |> is_map
@ -284,7 +284,7 @@ defmodule EXW3Test do
# Tests filter with map params
indexed_filter_id =
{:ok, indexed_filter_id} =
ExW3.Contract.filter(
:EventTester,
"SimpleIndex",
@ -302,7 +302,7 @@ defmodule EXW3Test do
)
# Demonstrating the delay capability
{:ok, change_logs} = ExW3.Contract.get_changes(indexed_filter_id, 1)
{:ok, change_logs} = ExW3.Contract.get_filter_changes(indexed_filter_id, 1)
event_log = Enum.at(change_logs, 0)
assert event_log |> is_map

Loading…
Cancel
Save