-
Notifications
You must be signed in to change notification settings - Fork 59
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
test: payment v2 with standard exit #1589
test: payment v2 with standard exit #1589
Conversation
* feat: start multiple exit processors * chore: use snapshot support payment v2 ... and run mix format * fix: setup exit_games for test fixture * fix: dispatch return in the format of {:ok, []} * fix: make watcher integ test to work * fix: unit test for EthEventAggregator 1. fix the unit tests, add address to log result 2. change how we bind contract address to log, use the pre-decoded address data * fix: patch payment_exit_game back into contract_addr * fix: wrong filter_events mapping * fix: linter, dializer, remove tmp logging * fix: use snapwhot with payment v2 Previous snapshot was wrong. Using this one: omisego-images/docker-elixir-omg#43 (comment) * refactor: restrain from using ++ Use [a|b] as best practice * chore: use Task.async_stream instad of sync looping * refactor: move private functions to the end * fix: map after Task.async_stream Co-authored-by: Thibault Denizet <thibault@omisego.co>
Tested by hacking the watcher info /transaction.create to generate payment v2 tx instead. And then the tx would be signed and send normally. Tested with the cabbage transaction tests. This commit instead of providing new module for payment, it reuses most of the part instead of the function that generate the payment struct. This commit introduces Payment.Builder to build different payment tx. Probably not the most clean way of handling things but the least change required to allow cabbage test to work.
add tx_type as a param of 'order'. If not passed, default to 1 for backward competibility.
linter, dialyzer, remove branching on tx type when building payment tx.
Simplify the test code and make it easier to read
e109999
to
f3658e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🎉
@@ -50,7 +51,10 @@ defmodule PaymentV2Test do | |||
balance = Client.get_exact_balance(alice.account, expecting_amount) | |||
balance = balance["amount"] | |||
|
|||
assert_equal(expecting_amount, balance, "For #{alice.account}") | |||
case expecting_amount do | |||
0 -> assert(balance == nil, "Alice ETH amount is not 0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
balance == nil
is not obvious and misleading.
Can we set it to zero, kind of (line above): balance = Map.get(balance, "amount", 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, TIL in elixir you can try to access a value from nil and would return nil instead of crashing.
the Client.get_exact_balance
would actually return nil
instead of empty map.
I will change to code to the following instead:
Client.get_exact_balance(bob.account, expecting_amount)["amount"] || 0
balance = Client.get_exact_balance(bob.account, expecting_amount)["amount"] | ||
|
||
assert_equal(expecting_amount, balance, "For Bob: #{bob.account}") | ||
case expecting_amount do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
{:ok, state} | ||
end | ||
|
||
defthen ~r/^Alice should have "(?<amount>[^"]+)" ETH on the child chain after finality margin$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we parametrize Alice - looks like it will work for any entity
. Thank you 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, add the step Given Alice has an ethereum account
that generates the user account and put it into state instead!
* feat: multiple exit processors (#1573) * feat: start multiple exit processors * chore: use snapshot support payment v2 ... and run mix format * fix: setup exit_games for test fixture * fix: dispatch return in the format of {:ok, []} * fix: make watcher integ test to work * fix: unit test for EthEventAggregator 1. fix the unit tests, add address to log result 2. change how we bind contract address to log, use the pre-decoded address data * fix: patch payment_exit_game back into contract_addr * fix: wrong filter_events mapping * fix: linter, dializer, remove tmp logging * fix: use snapwhot with payment v2 Previous snapshot was wrong. Using this one: omisego-images/docker-elixir-omg#43 (comment) * refactor: restrain from using ++ Use [a|b] as best practice * chore: use Task.async_stream instad of sync looping * refactor: move private functions to the end * fix: map after Task.async_stream Co-authored-by: Thibault Denizet <thibault@omisego.co> * feat: test with payment v2 transfer Tested by hacking the watcher info /transaction.create to generate payment v2 tx instead. And then the tx would be signed and send normally. Tested with the cabbage transaction tests. This commit instead of providing new module for payment, it reuses most of the part instead of the function that generate the payment struct. This commit introduces Payment.Builder to build different payment tx. Probably not the most clean way of handling things but the least change required to allow cabbage test to work. * feat: allow /transaction.create to pass in tx_type add tx_type as a param of 'order'. If not passed, default to 1 for backward competibility. * test: cabbage test for payment v2 transfer * fix: cleanup linter, dialyzer, remove branching on tx type when building payment tx. * refactor: use Alice and Bob instead Simplify the test code and make it easier to read * fix: credo complain single pipe * test: payment v2 with standard exit * fix: compiler warning me :( * refactor: remove commented codes * fix: linter * style: simpler code * refactor: parameterize users Co-authored-by: Thibault Denizet <thibault@omisego.co>
📋 https://github.com/omgnetwork/new-tx-type-poc/issues/5
Overview
test to ensure payment v2 exit event is handled
Changes
Add cabbage test. Currently is has shown that child chain and watcher-info somehow can handle 2 payment exit events.
warning, watcher is not tested!
Currently, child chain works and watcher can recognize the event and then pass it to watcher info. Since payment v1 and v2 has the same tx and output format, so it works to push the data to DB with different
type
info.Testing
CI