Commit Graph

201 Commits (91460a29cd4cafcec422c6f465d64766af1988b4)

Author SHA1 Message Date
Franck Royer 5a5a1c05f7
Set appropriate name to codec 3 years ago
Franck Royer a11e894b31
Prepend all libp2p protocols with "comit" 3 years ago
Franck Royer cfc5cb5206
Remove dead code and combine swap request & one shot codecs 3 years ago
Franck Royer fc2d8d3861
Rename alice::Message0 to Message0
There is now only one message0
3 years ago
Franck Royer 88bf080dc0
rename alice::Message0 to Message1 3 years ago
Franck Royer 18f326ddd1
Rename bob::Message1 to Message2
As per sequence diagram.
3 years ago
Franck Royer 0d1be52966
Rename alice::Message1 to Message3
As per sequence diagram.
3 years ago
Franck Royer e74efd38b5
Rename bob::Message2 to Message4
As per sequence diagram.
3 years ago
Franck Royer 081237bb6f
Remove unused behaviours 3 years ago
Franck Royer 3fa4ffa82c
Implement new behaviour for execution setup 3 years ago
Franck Royer 9ae050abf8
Use correct variable name 3 years ago
Franck Royer e82383bcf6
Avoid carrying rng 3 years ago
Daniel Karzel 89b3775e05 Rename config to execution_params 3 years ago
Daniel Karzel 802dc61e7e Configuration for RPC urls and Bitcoin wallet name 3 years ago
Franck Royer c25d5ff07e
Improve network logging 3 years ago
Franck Royer cc76b201b5
Do not consider encrypted signature sent until it's ack'd 3 years ago
Franck Royer 704a8e7b01
Add swap id to tracing context 3 years ago
rishflab 77fc5743a2
Upgrade tokio to 1.0
Upgrade bitcoin harness dependency to latest commit

Upgrade backoff to fix failing tests. The previous version of backoff had a broken version of the retry function. Upgraded to a newer comit which fixes this problem.

Upgrade hyper to 0.14 as the 0.13 was bringing in tokio 0.2.24

Upgraded bitcoin harness to version that uses tokio 1.0 and reqwest 0.11

Upgrade reqwest to 0.11. Reqwest 0.11 uses tokio 1.0

Upgrade libp2p to 0.34 in preparation for tokio 1.0 upgrade
3 years ago
Franck Royer 2929a8f101
Use the correct protocol support 3 years ago
Franck Royer b62ef9c2d9
Harmonizing naming 3 years ago
Franck Royer 8fd2620b83
Improve names for messages 4 and 5 3 years ago
Franck Royer a910bc2046
Box all messages in enum
The messages are very different, best to box them and save size on the
stack as an enum takes as much space on the stack than its bigger
variant.
3 years ago
Franck Royer d2a1937f51
Use `Message4` 3 years ago
Franck Royer 124d6f1ebb
Introduced Message 4 sent by Alice to replace message 2 response 3 years ago
Franck Royer edb93624f3
Introduce one shot code
To allow alice to be the requester for message 4.
3 years ago
Franck Royer 9a5e35c1bd
Rename `bob::Message2` to `Message5`
As per the proposed changed in the sequence diagram.
The aim is to have a unique terminology per message instead of having
the same name for 2 consequent messages that share the same behaviour.

Note that the aim is to remove the shared `RequestResponse` behaviours.
3 years ago
Franck Royer 10eeecfe54
Remove dependency of main.rs on lib.rs 3 years ago
Franck Royer f2a25ee49b
Move definitions out of lib.rs 3 years ago
Daniel Karzel 33a9057b1f Move run_until is_target_state comparison functions into testutils 3 years ago
Daniel Karzel 3593f5323a Bob saves lock proof after received so he can resume swap 3 years ago
Daniel Karzel 44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
3 years ago
Franck Royer ae8134f04e
Replace amounts messages with swap res/req 3 years ago
Daniel Karzel 8a7d746e96 Wait for Bob's refund finality
For Alice we ensure to wait for redeem/punish finality, so it should be the same for Bob.
3 years ago
Daniel Karzel e91987e23f Fix rand import 3 years ago
Daniel Karzel 170e90ffed Rename do_run_until to _run_until_internal 3 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.
3 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
3 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>
3 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>
3 years ago
Franck Royer 9a823dca4c
Do not introduced State6 3 years ago
Daniel Karzel 8615aaed6e Make lock-tx id available in redeem/punish state to be able to assert exact fees 3 years ago
rishflab f5cfe014be Fix imports 4 years ago
Daniel Karzel 00b4f3110f Remove ToDo that is already actioned
We already have a second watcher for the cancel timelock, so refund is already actioned.
4 years ago
Daniel Karzel ab9117aa4c Log Alice's lock tx proof receive on Bob's side 4 years ago
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.
4 years ago
rishflab 1c644cb377 Rename message behaviours 4 years ago
rishflab 5d7d72c826 Remove unused import 4 years ago
rishflab dcea54dbf1 Move protocol parent states into appropriate module 4 years ago
rishflab f64eede5d8 Move monero ser/deser to monero module 4 years ago
rishflab e7c00d742e Re-export bitcoin and monero types 4 years ago
rishflab c900d12593 Merge xmr_btc crate
Created network, storage and protocol modules. Organised
files into the modules where the belong.

xmr_btc crate moved into isolated modulein swap crate.

Remove the xmr_btc module and integrate into swap crate.

Consolidate message related code

Reorganise imports

Remove unused parent Message enum

Remove unused parent State enum

Remove unused dependencies from Cargo.toml
4 years ago