Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2] Add root chain transaction hash to InvalidExit and UnchallengedExit events #1485

Merged
merged 22 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0c71526
feat: add root_chain_txhash to persistence layer
Apr 20, 2020
07ad3b8
[ADD]: rc txhash to se_event test helper
Apr 20, 2020
3724c7e
Merge branch 'master' of https://github.com/omisego/elixir-omg into 1…
Apr 20, 2020
563c735
add: root_chain_txhash to remaining methods
Apr 20, 2020
81797fe
fix: persistence test
Apr 20, 2020
1bdcda6
refactor: simply rc txhash creation
Apr 20, 2020
9bf5ab5
add: root_chain_txhash to InvalidExit event
Apr 21, 2020
bd4680a
add: root_chain_txhash to UnchallengedExit event
Apr 21, 2020
c6c0947
Merge branch 'master' of https://github.com/omisego/elixir-omg into 1…
Apr 21, 2020
6287e2b
refactor and add dialyzer specs
Apr 22, 2020
c35bec5
refactor: add method for txhash creation
Apr 22, 2020
3dff69e
Merge branch 'master' of https://github.com/omisego/elixir-omg into 1…
Apr 22, 2020
6ff3794
remove: pattern match for make_db_update
Apr 22, 2020
999b0d5
requested changes
Apr 22, 2020
48cc67b
add: random bytes helper
Apr 23, 2020
cf38ba0
fix: default recently added keys to nil for previously existing values
Apr 23, 2020
479d28a
refactor and move_tests
Apr 23, 2020
09472d3
Merge branch 'master' of https://github.com/omisego/elixir-omg into 1…
Apr 23, 2020
ee6fe08
requested changes [1]
Apr 24, 2020
7f8da07
Merge branch 'master' of https://github.com/omisego/elixir-omg into 1…
Apr 24, 2020
ed9b1fc
fix: InvalidExit and UnchallengedExit accept nil `root_chain_txhash`
Apr 24, 2020
d6d9158
change type to Transaction.tx_hash()
Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/omg_watcher/lib/omg_watcher/exit_processor/exit_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule OMG.Watcher.ExitProcessor.ExitInfo do
# this means the exit has been first seen active. If false, it won't be considered harmful
is_active: boolean(),
eth_height: pos_integer(),
root_chain_txhash: Crypto.hash_t()
root_chain_txhash: Crypto.hash_t() | nil
}

@spec new(map(), map()) :: t()
Expand Down Expand Up @@ -125,7 +125,8 @@ defmodule OMG.Watcher.ExitProcessor.ExitInfo do
exiting_txbytes: exit_info.exiting_txbytes,
is_active: exit_info.is_active,
eth_height: exit_info.eth_height,
root_chain_txhash: exit_info.root_chain_txhash
# defaults value to nil if non-existent in the DB.
root_chain_txhash: Map.get(exit_info, :root_chain_txhash, nil)
kalouo marked this conversation as resolved.
Show resolved Hide resolved
}

{Utxo.Position.from_db_key(db_utxo_pos), struct!(__MODULE__, value)}
Expand Down
29 changes: 29 additions & 0 deletions apps/omg_watcher/test/omg_watcher/exit_processor/core_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,35 @@ defmodule OMG.Watcher.ExitProcessor.CoreTest do
@utxo_pos2 Utxo.position(@late_blknum - 1_000, 0, 1)

describe "generic sanity checks" do
test "can initialise with standard exits that do not have recently introduced keys" do
recent_keys = [:root_chain_txhash]
utxo_position = {0, 0, 0}

exit_info = %{
amount: 1,
currency: random_bytes(20),
eth_height: 1,
exit_id: 1,
exiting_txbytes: random_bytes(32),
is_active: false,
owner: random_bytes(20)
}

{:ok, %{exits: exits}} =
Core.init(
[
kalouo marked this conversation as resolved.
Show resolved Hide resolved
{utxo_position, exit_info}
],
[],
[]
)

Enum.each(recent_keys, fn recent_key ->
value = Map.get(exits, recent_key)
assert value == nil
end)
end

test "can start new standard exits one by one or batched", %{processor_empty: empty, alice: alice, bob: bob} do
standard_exit_tx1 = TestHelper.create_recovered([{1, 0, 0, alice}], @eth, [{alice, 10}])
standard_exit_tx2 = TestHelper.create_recovered([{1, 0, 0, alice}], @eth, [{bob, 10}, {bob, 10}])
Expand Down