From 297b15e3ced78e7fec296a9d0062519021820538 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 21 Dec 2020 14:53:35 +1100 Subject: [PATCH] Remove async block when it is not needed --- swap/src/bin/swap.rs | 2 +- swap/tests/happy_path_restart_alice.rs | 2 +- .../happy_path_restart_bob_after_comm.rs | 25 ++++++++----------- swap/tests/refund_restart_alice.rs | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index e60bbb9b..6ac063e5 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -320,6 +320,6 @@ async fn bob_swap( swap_id, ); - tokio::spawn(async move { event_loop.run().await }); + tokio::spawn(event_loop.run()); swap.await } diff --git a/swap/tests/happy_path_restart_alice.rs b/swap/tests/happy_path_restart_alice.rs index cfd5fa32..db21ba67 100644 --- a/swap/tests/happy_path_restart_alice.rs +++ b/swap/tests/happy_path_restart_alice.rs @@ -119,7 +119,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() { let (mut event_loop_after_restart, event_loop_handle_after_restart) = testutils::init_alice_event_loop(alice_multiaddr); - let _alice_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await }); + tokio::spawn(async move { event_loop_after_restart.run().await }); let db_swap = alice_db.get_state(alice_swap_id).unwrap(); let resume_state = AliceState::try_from(db_swap).unwrap(); diff --git a/swap/tests/happy_path_restart_bob_after_comm.rs b/swap/tests/happy_path_restart_bob_after_comm.rs index 49e67638..173a2c4e 100644 --- a/swap/tests/happy_path_restart_bob_after_comm.rs +++ b/swap/tests/happy_path_restart_bob_after_comm.rs @@ -80,22 +80,19 @@ 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 alice_swap_handle = tokio::spawn(async move { - alice::swap::swap( - alice_state, - alice_event_loop_handle, - alice_btc_wallet.clone(), - alice_xmr_wallet.clone(), - config, - Uuid::new_v4(), - alice_db, - ) - .await - }); + let alice_swap_handle = tokio::spawn(alice::swap::swap( + alice_state, + alice_event_loop_handle, + alice_btc_wallet.clone(), + alice_xmr_wallet.clone(), + config, + Uuid::new_v4(), + alice_db, + )); tokio::spawn(async move { alice_event_loop.run().await }); - tokio::spawn(async move { bob_event_loop.run().await }); + tokio::spawn(bob_event_loop.run()); let bob_swap_id = Uuid::new_v4(); let bob_db_datadir = tempdir().unwrap(); @@ -125,7 +122,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() { let (event_loop_after_restart, event_loop_handle_after_restart) = testutils::init_bob_event_loop(alice_peer_id, alice_multiaddr); - let _bob_swarm_fut = tokio::spawn(async move { event_loop_after_restart.run().await }); + tokio::spawn(event_loop_after_restart.run()); let db_swap = bob_db.get_state(bob_swap_id).unwrap(); let resume_state = BobState::try_from(db_swap).unwrap(); diff --git a/swap/tests/refund_restart_alice.rs b/swap/tests/refund_restart_alice.rs index f2d8e20b..4ebcd2fe 100644 --- a/swap/tests/refund_restart_alice.rs +++ b/swap/tests/refund_restart_alice.rs @@ -100,7 +100,7 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() { ) }; - tokio::spawn(async move { bob_event_loop.run().await }); + tokio::spawn(bob_event_loop.run()); // We are selecting with alice_event_loop_1 so that we stop polling on it once // the try_join is finished.