Commit Graph

902 Commits (2041f367c6c0d0fd80ccd37f2496d119c1df8b54)
 

Author SHA1 Message Date
bors[bot] d6bf66c1f4
Merge #150
150: Few improvements r=D4nte a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
4 years ago
Franck Royer 94045b9a69
Use builder in tests 4 years ago
Franck Royer c44b867d01
Delay the wrapping in Arc 4 years ago
Franck Royer 83b72c0a45
Make `make_init_state` and `init_loop` associated to `alice::SwapFactory` 4 years ago
Franck Royer c11042ff0d
Use `builder` terminology instead of `factory`
This is not really a factory as a factory design pattern is about
producing several instances.

In the current usage, we are only interested in one swap instance. Once
the swap instance is created, the factory becomes useless. Hence, it is
more of a builder pattern.
4 years ago
Franck Royer 9148af2dbe
`bob::SwapFactory` should be consumed once a swap is returned 4 years ago
Franck Royer 652bfa14a9
Remove unnecessary `pub` qualifiers 4 years ago
Franck Royer b21dc03ed0
`alice::SwapFactory` should be consumed once a swap is returned 4 years ago
Franck Royer 9b32409b8d
Remove unnecessary `allow(clippy)` 4 years ago
Franck Royer 9e3ef7ea24
Remove `StartingBalances` from release code 4 years ago
Franck Royer 181999e04f
Remove unnecessary `alice` qualifiers in `alice::SwapFactor` 4 years ago
Franck Royer 3bc76a91c6
Make `init_state` associated to `bob::SwapFactory` 4 years ago
Franck Royer f0e6e45d56
Remove unecessary `bob` qualifier 4 years ago
Franck Royer dbc633ea06
Remove unecessary `connect` qualifier 4 years ago
Franck Royer e26629b593
Remove unecessary fields from `bob::SwapFactory` 4 years ago
Franck Royer 3c68026cfe
Move init event loop in `bob::SwapFactory` 4 years ago
Franck Royer 96b1b18037
Keep terminology consistent
Also avoid redundant qualifiers.
4 years ago
bors[bot] 05669c749c
Merge #147
147: Refactor prod code after test refactoring r=da-kami a=da-kami

Follow up of https://github.com/comit-network/xmr-btc-swap/pull/144

Took a bit more than expected, but this is really neat now!
The commits should be well-contained for reviewing, but 00835baa15 is quite big. 

I changed the abstraction on the way - out methods are finally named `run` and `run_until` which both take a swap - which makes way more sense I think :)

Also had to change the abstraction layers in `testutils` and introduced `Test` which specifies the swap amounts (that would usually come from the commandline and should not live in the factory as they are irrelevant for resumed swaps).

Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel 28429fa9fe Revert log statement 4 years ago
Daniel Karzel 37f619dbfc Move StartingBalances into protocol module 4 years ago
Daniel Karzel 41e335fc2d Error messages instead of unreachable
Currently this code is actually not reachable, but that is semantically applied by the program's flow (the resume command includes the swap direction).
It is still preferred to have an error message rather than an unreachable statement.
4 years ago
Daniel Karzel 2dceab28a4 Derive Default 4 years ago
Daniel Karzel acfd43ee79 Rename Test to TestContext and argument to ctx 4 years ago
Daniel Karzel e91987e23f Fix rand import 4 years ago
Daniel Karzel 170e90ffed Rename do_run_until to _run_until_internal 4 years ago
Daniel Karzel 82974412b2 Remove roles from SwapFactory name as implied by module and cleanup 4 years ago
Daniel Karzel 75f89f3b25 Use Bob swap factory in production 4 years ago
Daniel Karzel e56c48ee23 Remove unused type 4 years ago
Daniel Karzel 3398ef8236 Use Alice swap factory in production 4 years ago
Daniel Karzel 67e925fe1f Refactor Bob's peer-id and identity to be handled on the outside
Doing this in the behaviour is a weird indirection that is not needed.
4 years ago
Daniel Karzel 0c19af9090 Refactor Alice's peer-id and identity to be handled on the outside
Doing this in the behaviour is a weird indirection that is not needed.
4 years ago
Daniel Karzel 8bf467b550 Make the factory code usable in production
- Introduce Test abstraction instead of tow harnesses, move test specific data into Test
- Change the abstraction from actors to swap, because we are creating swaps, not actors
- rename actor::swap  to run, because we are running a swap
4 years ago
Daniel Karzel e4795fa4ee Fix recursive call to swap by using run_until
We should call run_until instead of swap.
4 years ago
bors[bot] 35c42263df
Merge #145
145: Make lock-tx id available in redeem/punish state to be able to assert exact fees r=da-kami a=da-kami

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. 

Co-authored-by: Daniel Karzel <daniel@comit.network>
Co-authored-by: Franck Royer <franck@coblox.tech>
Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
4 years ago
bors[bot] f2c14c10c0
Merge #146
146: Do not introduced State6 r=da-kami a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
4 years ago
bors[bot] a7f68e4aa1
Merge #144
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] https://github.com/comit-network/xmr-btc-swap/pull/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>
4 years ago
Franck Royer 9a823dca4c
Do not introduced State6 4 years ago
bors[bot] 974b6ebf6f
Merge #136
136: Testnet resume fixes r=da-kami a=da-kami

Add a few log statements on Bob's side to make the user experience better.
Update / remove ToDos.

I set the log level to `Info` in main again, `Debug` heavily clutters the output. In order to make `Debug` more usable we might want to review printing all those `rpc` messages. But this goes beyond the scope of this PR.


Co-authored-by: Daniel Karzel <daniel@comit.network>
4 years ago
Daniel Karzel d4316f0cfe Print each monero confirmation for Bob
This is to provide more context to the user.
4 years ago
Daniel Karzel 8615aaed6e Make lock-tx id available in redeem/punish state to be able to assert exact fees 4 years ago
Daniel Karzel 317b251302 Re-arrange order of structs/functions in testutils
move important things to the top and harmonize structure for alice and bob.
4 years ago
Daniel Karzel 7832ee94f3 Remove unused code and only expose necessary functionality 4 years ago
Daniel Karzel 8ef8240771 Refactor refund test 4 years ago
Daniel Karzel 55024572ae Refactor punish test and punish assertions 4 years ago
Daniel Karzel 73a2841ec5 Refactor happy path bob restart tests 4 years ago
Daniel Karzel 8a2eb07928 Harmonize names and structure
Simple renames and structure changes, no logical changes.
4 years ago
Daniel Karzel bede1c13dd Refactor Bob's side (happy path + alice restart)
Refactor Bob's test setup in the same way as Alice's.
Introduce BobHarness that allows creating and restarting as well as asserting redeemed for Bob.
4 years ago
Daniel Karzel 59f9a1c286 Fix usage of StartingBalance in Alice and Bob 4 years ago
Daniel Karzel 87edec0d50 Rename Alice's factory to harness and include redeem assertions
This makes the redeem assertion reusable for all tests with a redeem scenario.
Since the factory was not a clean factory before and is now doing even more it was renamed to harness.
4 years ago
Daniel Karzel 152c8d7eba Refactor Alice restart test by introducing factory for creating Alices
The factory keeps all static state of Alice to be able to simulate a restart.
4 years ago