Commit Graph

307 Commits

Author SHA1 Message Date
Daniel Karzel
3398ef8236 Use Alice swap factory in production 2021-01-19 09:16:05 +11:00
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.
2021-01-19 09:16:04 +11:00
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.
2021-01-19 09:16:04 +11:00
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
2021-01-19 09:16:04 +11:00
Daniel Karzel
e4795fa4ee Fix recursive call to swap by using run_until
We should call run_until instead of swap.
2021-01-19 09:06:44 +11:00
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>
2021-01-18 11:07:36 +00:00
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>
2021-01-18 04:49:52 +00:00
Franck Royer
9a823dca4c
Do not introduced State6 2021-01-18 15:27:38 +11:00
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>
2021-01-18 03:51:45 +00:00
Daniel Karzel
d4316f0cfe Print each monero confirmation for Bob
This is to provide more context to the user.
2021-01-18 14:50:59 +11:00
Daniel Karzel
8615aaed6e Make lock-tx id available in redeem/punish state to be able to assert exact fees 2021-01-18 14:45:47 +11:00
Daniel Karzel
317b251302 Re-arrange order of structs/functions in testutils
move important things to the top and harmonize structure for alice and bob.
2021-01-18 14:10:17 +11:00
Daniel Karzel
7832ee94f3 Remove unused code and only expose necessary functionality 2021-01-18 14:10:17 +11:00
Daniel Karzel
8ef8240771 Refactor refund test 2021-01-18 14:10:16 +11:00
Daniel Karzel
55024572ae Refactor punish test and punish assertions 2021-01-18 14:10:16 +11:00
Daniel Karzel
73a2841ec5 Refactor happy path bob restart tests 2021-01-18 14:10:00 +11:00
Daniel Karzel
8a2eb07928 Harmonize names and structure
Simple renames and structure changes, no logical changes.
2021-01-15 19:34:51 +11:00
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.
2021-01-15 19:29:26 +11:00
Daniel Karzel
59f9a1c286 Fix usage of StartingBalance in Alice and Bob 2021-01-15 19:03:11 +11:00
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.
2021-01-15 18:46:14 +11:00
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.
2021-01-15 18:14:19 +11:00
Daniel Karzel
b031bc5e42 Re-export run_until 2021-01-15 11:49:47 +11:00
rishflab
537d05e01e Add reusable test function
We introduce a reusable test function to make it easier to add new tests and make our existing tests more readable.
2021-01-15 11:26:32 +11:00
rishflab
9cbf6e9774 Re-export event loop handles 2021-01-15 10:42:49 +11:00
rishflab
6040f2ae63 Re-export event loops 2021-01-15 10:31:25 +11:00
rishflab
e8fdf62623 Re-export swap function 2021-01-15 10:20:18 +11:00
rishflab
f5cfe014be Fix imports 2021-01-15 10:13:39 +11:00
Franck Royer
31c63f0c4d
Remove dead code 2021-01-14 11:40:34 +11:00
Franck Royer
0852f90473
Remove unused variant 2021-01-14 11:36:38 +11:00
Daniel Karzel
f8848aca55 Describe additional state for ToDo that might cause trouble
If we wait for lock transaction confirmations immediately after sending the transaction without saving this state to the DB this might cause locking the money twice.
An additional state is needed for such a scenario.
2021-01-12 14:39:17 +11:00
Daniel Karzel
59f01ad680 Remove Todo that was already actioned
This ToDo does not add any value, I would not know what to do here.
2021-01-12 14:39:17 +11:00
Daniel Karzel
60f3923a63 Set tracing level to Info in production code
Trace / Debug should be used when there is a problem. They print way too much in production.
2021-01-12 14:39:17 +11:00
Daniel Karzel
00b4f3110f Remove ToDo that is already actioned
We already have a second watcher for the cancel timelock, so refund is already actioned.
2021-01-12 14:39:17 +11:00
Daniel Karzel
ab9117aa4c Log Alice's lock tx proof receive on Bob's side 2021-01-12 14:39:17 +11:00
Daniel Karzel
af45206fde Remember the block-height before XMR lock for generated monero wallet restore height
Speeds up wallet creation, because only the blocks after the recorded height will be scanned.
2021-01-12 13:18:49 +11:00
bors[bot]
ca6ba78862
Merge #123
123: Small fixes after testnet usage r=da-kami a=D4nte



Co-authored-by: Franck Royer <franck@coblox.tech>
2021-01-11 04:25:26 +00:00
Daniel Karzel
664958939d Create network::Seed from swap::Seed instead of abstracting over byte array 2021-01-11 12:03:29 +11:00
Daniel Karzel
f18d01dfaf Deterministic peer id from seed for bob 2021-01-11 12:03:29 +11:00
Daniel Karzel
0a21040e08 Deterministic peer id from seed for alice
This includes the introduction of the --data-dir parameter instead of the --database.
Both the seed file and the database are stored in the data-dir, the database in sub-folder `database`.
2021-01-11 12:00:48 +11:00
Franck Royer
6ffc66867c
Typo
Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
2021-01-11 11:39:21 +11:00
Franck Royer
047f990d05
Improve error reporting on signature verification 2021-01-11 11:39:18 +11:00
Franck Royer
ef906876a0
Increase timelocks on testnet
To allow time for stagenet Monero transaction to be mined.
2021-01-11 11:35:52 +11:00
Franck Royer
17356eaff9
Do not guard waiting for encrypted signature with arbitrary timeout
We already select waiting for this message with the cancellation expiry,
 we do not need add another guard that tries to guess how long it would
 for the Monero transaction to be finalised.
2021-01-11 11:35:52 +11:00
Franck Royer
95ecb02e7a
Small changes to make debugging easier and tests 2021-01-11 11:35:51 +11:00
Franck Royer
9d8f8b0a1f
P2p socket should be listening for external connections 2021-01-11 11:35:51 +11:00
rishflab
1c644cb377 Rename message behaviours 2021-01-09 11:47:23 +11:00
rishflab
5d7d72c826 Remove unused import 2021-01-09 10:10:48 +11:00
rishflab
387a4da2f6 Make modules private 2021-01-08 12:34:36 +11:00
rishflab
dcea54dbf1 Move protocol parent states into appropriate module 2021-01-08 12:34:36 +11:00
rishflab
f64eede5d8 Move monero ser/deser to monero module 2021-01-08 12:34:36 +11:00