-
Notifications
You must be signed in to change notification settings - Fork 79
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
Make lock-tx id available in redeem/punish state to be able to assert exact fees #145
Conversation
swap/src/protocol/bob/state.rs
Outdated
@@ -35,8 +35,8 @@ pub enum BobState { | |||
CancelTimelockExpired(State4), | |||
BtcCancelled(State4), | |||
BtcRefunded(State4), | |||
XmrRedeemed, | |||
BtcPunished, | |||
XmrRedeemed(State6), |
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.
I don't think we should define a State6
. Let me try something locally see if it looks better.
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.
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.
Looks good but I think State6
is an unnecessary abstraction #146
144: Test refactor r=da-kami a=da-kami This PR is pure refactoring, keeping the logic of the tests we had before. No production code is touched besides re-exports in early commits (no logic changes). In the follow ups improvements will be introduced, that touch the production code as well. All remaining tasks actioned since Friday: - [x] `happy_path_bob _restart` (trivial) - [x] add refund assertions to harnesses (trivial) - [x] convert all refund scenarios currently being tested (trivial) - [x] remove dead test init code once all old tests are converted - [ ] ~~(optional) move alice and bob harness code into separate files~~ -> might action this once re-using test code in production. Out of scope, follow up: - [x] #145 - We can do exact assertions for Bob's redeem as well, but have to store Bob's `tx_lock` id in the respective final state. Make `tx_lock` available in `BtcRedeemed` and `BtcPunished` to have better assertions / harmonize test behaviour. - [ ] update the production code to use the `Alice` and `Bob` structs to bundle the params - update tests to use the production struct. - [ ] Re-use test swap setup in production (i.e. `Alice-/BobHarness::new`) to setup the swap. - [ ] add additional tests - [ ] re-try moving the tests from `test` to `src` (if the peer_id was the only problem this should be trivial now - but should be done after the refactor is finished) - [ ] creating new wallets upon restart - [ ] aborting the old event loop after restart Co-authored-by: rishflab <rishflab@hotmail.com> Co-authored-by: Daniel Karzel <daniel@comit.network>
bors r+ |
144: Test refactor r=da-kami a=da-kami This PR is pure refactoring, keeping the logic of the tests we had before. No production code is touched besides re-exports in early commits (no logic changes). In the follow ups improvements will be introduced, that touch the production code as well. All remaining tasks actioned since Friday: - [x] `happy_path_bob _restart` (trivial) - [x] add refund assertions to harnesses (trivial) - [x] convert all refund scenarios currently being tested (trivial) - [x] remove dead test init code once all old tests are converted - [ ] ~~(optional) move alice and bob harness code into separate files~~ -> might action this once re-using test code in production. Out of scope, follow up: - [x] comit-network/xmr-btc-swap#145 - We can do exact assertions for Bob's redeem as well, but have to store Bob's `tx_lock` id in the respective final state. Make `tx_lock` available in `BtcRedeemed` and `BtcPunished` to have better assertions / harmonize test behaviour. - [ ] update the production code to use the `Alice` and `Bob` structs to bundle the params - update tests to use the production struct. - [ ] Re-use test swap setup in production (i.e. `Alice-/BobHarness::new`) to setup the swap. - [ ] add additional tests - [ ] re-try moving the tests from `test` to `src` (if the peer_id was the only problem this should be trivial now - but should be done after the refactor is finished) - [ ] creating new wallets upon restart - [ ] aborting the old event loop after restart Co-authored-by: rishflab <rishflab@hotmail.com> Co-authored-by: Daniel Karzel <daniel@comit.network>
We can do exact assertions for Bob's redeem as well, but have to store Bob's tx_lock id in the respective final state. Make tx_lock available in BtcRedeemed and BtcPunished to have better assertions / harmonize test behaviour.
Storing this information is strictly speaking not needed for the production environment. But it is static information that can be seen as additional information that can be handy for a user. We could potentially extract it inside the tests as well (for redeem without restart would be a bit tricky), but I think this solution is more elegant.