diff --git a/swap/tests/happy_path_restart_alice.rs b/swap/tests/happy_path_restart_alice.rs index bb40c5be..cfd5fa32 100644 --- a/swap/tests/happy_path_restart_alice.rs +++ b/swap/tests/happy_path_restart_alice.rs @@ -90,7 +90,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() { let alice_db = Database::open(alice_db_datadir.path()).unwrap(); tokio::spawn(async move { alice_event_loop.run().await }); - tokio::spawn(bob_fut); + let bob_swap_handle = tokio::spawn(bob_fut); tokio::spawn(bob_event_loop.run()); let alice_swap_id = Uuid::new_v4(); @@ -136,6 +136,9 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() { .await .unwrap(); + // Wait for Bob to finish + bob_swap_handle.await.unwrap().unwrap(); + assert!(matches!(alice_state, AliceState::BtcRedeemed {..})); let btc_alice_final = alice_btc_wallet.as_ref().balance().await.unwrap(); diff --git a/swap/tests/happy_path_restart_bob_after_comm.rs b/swap/tests/happy_path_restart_bob_after_comm.rs index 20421f0f..49e67638 100644 --- a/swap/tests/happy_path_restart_bob_after_comm.rs +++ b/swap/tests/happy_path_restart_bob_after_comm.rs @@ -80,7 +80,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() { let bob_btc_wallet_clone = bob_btc_wallet.clone(); let bob_xmr_wallet_clone = bob_xmr_wallet.clone(); - let _ = tokio::spawn(async move { + let alice_swap_handle = tokio::spawn(async move { alice::swap::swap( alice_state, alice_event_loop_handle, @@ -93,9 +93,9 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() { .await }); - let _alice_swarm_fut = tokio::spawn(async move { alice_event_loop.run().await }); + tokio::spawn(async move { alice_event_loop.run().await }); - let _bob_swarm_fut = tokio::spawn(async move { bob_event_loop.run().await }); + tokio::spawn(async move { bob_event_loop.run().await }); let bob_swap_id = Uuid::new_v4(); let bob_db_datadir = tempdir().unwrap(); @@ -142,6 +142,9 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() { .await .unwrap(); + // Wait for Alice to finish too + alice_swap_handle.await.unwrap().unwrap(); + assert!(matches!(bob_state, BobState::XmrRedeemed {..})); let btc_alice_final = alice_btc_wallet_clone.as_ref().balance().await.unwrap();