Bob refunds swap after restart that requires communication

As Bob is dialing Alice, we now ensure that we are connected to Alice
at each step that needs communication.
If we are not connected, we proceed with dialing.

In an attempt to improve libp2p usage, we also add known address of
Alice first and only use peer_id to dial.
This ensures that we use the expected peer id.
This commit is contained in:
Franck Royer 2020-12-18 17:39:04 +11:00
parent d9ea7ab605
commit 1a4bd0e2b4
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
14 changed files with 347 additions and 72 deletions

View file

@ -63,7 +63,8 @@ async fn happy_path() {
let (bob_state, bob_event_loop, bob_event_loop_handle, bob_btc_wallet, bob_xmr_wallet, bob_db) =
init_bob(
alice_multiaddr,
alice_multiaddr.clone(),
alice_event_loop.peer_id(),
&bitcoind,
&monero,
btc_to_swap,
@ -83,6 +84,8 @@ async fn happy_path() {
alice_db,
);
let alice_peer_id = alice_event_loop.peer_id();
let _alice_swarm_fut = tokio::spawn(async move { alice_event_loop.run().await });
let bob_swap_fut = bob::swap::swap(
@ -93,6 +96,8 @@ async fn happy_path() {
bob_xmr_wallet.clone(),
OsRng,
Uuid::new_v4(),
alice_peer_id,
alice_multiaddr,
);
let _bob_swarm_fut = tokio::spawn(async move { bob_event_loop.run().await });