update test and add comments
MODIFY
apps/omg_eth/test/omg_eth/eth_test.exs
apps/omg_eth/test/omg_eth/eth_test.exs
@@ -23,6 +23,7 @@ defmodule OMG.EthTest do
"""
alias OMG.Eth
+ alias OMG.Eth.Encoding
use ExUnitFixtures
use ExUnit.Case, async: false
@@ -86,20 +87,28 @@ defmodule OMG.EthTest do
[List.duplicate(zero_in, 4), [[contract.authority_addr, @eth, 1]] ++ List.duplicate(zero_out, 3)]
|> ExRLP.encode()
- {:ok, _} =
+ {:ok, tx_hash} =
Eth.RootChainHelper.deposit(tx, 1, contract.authority_addr, contract.contract_addr)
|> Eth.DevHelpers.transact_sync!()
{:ok, height} = Eth.get_ethereum_height()
authority_addr = contract.authority_addr
- deposits = Eth.RootChain.get_deposits(1, height, contract.contract_addr)
-
- assert {:ok, [%{amount: 1, blknum: 1, owner: ^authority_addr, currency: @eth, eth_height: height, log_index: 0}]} =
- deposits
+ root_chain_txhash = Encoding.from_hex(tx_hash["transactionHash"])
- {:ok, [%{} = deposit]} = deposits
+ deposits = Eth.RootChain.get_deposits(1, height, contract.contract_addr)
- assert Map.has_key?(deposit, :root_chain_txhash)
+ assert {:ok,
+ [
+ %{
+ amount: 1,
+ blknum: 1,
+ owner: ^authority_addr,
+ currency: @eth,
+ eth_height: height,
+ log_index: 0,
+ root_chain_txhash: ^root_chain_txhash
+ }
+ ]} = deposits
end
end

MODIFY
apps/omg_watcher/lib/omg_watcher/db/txoutput.ex
apps/omg_watcher/lib/omg_watcher/db/txoutput.ex
@@ -94,9 +94,8 @@ defmodule OMG.Watcher.DB.TxOutput do
txoutput in __MODULE__,
preload: [:ethevents],
left_join: ethevent in assoc(txoutput, :ethevents),
- where:
- txoutput.owner == ^owner and
- is_nil(txoutput.spending_txhash) and (is_nil(ethevent) or fragment("
+ # select txoutputs by owner that have neither been spent nor have a corresponding ethevents exit events
+ where: txoutput.owner == ^owner and is_nil(txoutput.spending_txhash) and (is_nil(ethevent) or fragment("
NOT EXISTS (SELECT 1
FROM ethevents_txoutputs AS etfrag
JOIN ethevents AS efrag ON
@@ -115,6 +114,7 @@ defmodule OMG.Watcher.DB.TxOutput do
from(
txoutput in __MODULE__,
left_join: ethevent in assoc(txoutput, :ethevents),
+ # select txoutputs by owner that have neither been spent nor have a corresponding ethevents exit events
where: txoutput.owner == ^owner and is_nil(txoutput.spending_txhash) and (is_nil(ethevent) or fragment("
NOT EXISTS (SELECT 1
FROM ethevents_txoutputs AS etfrag

MODIFY
apps/omg_watcher/test/omg_watcher/db/eth_event_test.exs
apps/omg_watcher/test/omg_watcher/db/eth_event_test.exs
@@ -197,7 +197,6 @@ defmodule OMG.Watcher.DB.EthEventTest do
end)
end
- # @tag fixtures: [:initial_blocks]
@tag fixtures: [:phoenix_ecto_sandbox]
test "insert exits: creates exit event and marks utxo as spent" do
expected_owner = <<1::160>>

update test and add comments