From e266fb07ef31cc98e02e90fcd3dce1fabeb2b9c3 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 16 Apr 2021 11:48:15 +1000 Subject: [PATCH] Don't stutter --- swap/src/protocol/bob.rs | 4 ++-- swap/src/protocol/bob/swap.rs | 4 ++-- .../alice_punishes_after_restart_punish_timelock_expired.rs | 2 +- swap/tests/bob_refunds_using_cancel_and_refund_command.rs | 6 +++--- ..._using_cancel_and_refund_command_timelock_not_expired.rs | 6 +++--- ..._cancel_and_refund_command_timelock_not_expired_force.rs | 6 +++--- swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs | 2 +- swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs | 2 +- swap/tests/ensure_same_swap_id.rs | 2 +- swap/tests/happy_path_restart_bob_after_xmr_locked.rs | 2 +- swap/tests/happy_path_restart_bob_before_xmr_locked.rs | 2 +- swap/tests/punish.rs | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/swap/src/protocol/bob.rs b/swap/src/protocol/bob.rs index 36e4d0d0..aeae1f00 100644 --- a/swap/src/protocol/bob.rs +++ b/swap/src/protocol/bob.rs @@ -26,7 +26,7 @@ pub struct Swap { pub bitcoin_wallet: Arc, pub monero_wallet: Arc, pub env_config: env::Config, - pub swap_id: Uuid, + pub id: Uuid, pub receive_monero_address: monero::Address, } @@ -92,7 +92,7 @@ impl Builder { db: self.db, bitcoin_wallet: self.bitcoin_wallet.clone(), monero_wallet: self.monero_wallet.clone(), - swap_id: self.swap_id, + id: self.swap_id, env_config: self.env_config, receive_monero_address: self.receive_monero_address, }) diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index 0702f76e..88ad040d 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -33,7 +33,7 @@ pub async fn run_until( while !is_target_state(¤t_state) { current_state = next_state( - swap.swap_id, + swap.id, current_state, &mut swap.event_loop_handle, swap.bitcoin_wallet.as_ref(), @@ -45,7 +45,7 @@ pub async fn run_until( let db_state = current_state.clone().into(); swap.db - .insert_latest_state(swap.swap_id, Swap::Bob(db_state)) + .insert_latest_state(swap.id, Swap::Bob(db_state)) .await?; } diff --git a/swap/tests/alice_punishes_after_restart_punish_timelock_expired.rs b/swap/tests/alice_punishes_after_restart_punish_timelock_expired.rs index 0173b1d0..9157a19c 100644 --- a/swap/tests/alice_punishes_after_restart_punish_timelock_expired.rs +++ b/swap/tests/alice_punishes_after_restart_punish_timelock_expired.rs @@ -13,7 +13,7 @@ use swap::protocol::{alice, bob}; async fn alice_punishes_after_restart_if_punish_timelock_expired() { harness::setup_test(FastPunishConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); let alice_swap = ctx.alice_next_swap().await; diff --git a/swap/tests/bob_refunds_using_cancel_and_refund_command.rs b/swap/tests/bob_refunds_using_cancel_and_refund_command.rs index 71a902a8..d218341e 100644 --- a/swap/tests/bob_refunds_using_cancel_and_refund_command.rs +++ b/swap/tests/bob_refunds_using_cancel_and_refund_command.rs @@ -9,7 +9,7 @@ use swap::protocol::{alice, bob}; async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() { harness::setup_test(FastCancelConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); let alice_swap = ctx.alice_next_swap().await; @@ -37,7 +37,7 @@ async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() { // Bob manually cancels bob_join_handle.abort(); let (_, state) = bob::cancel( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, @@ -54,7 +54,7 @@ async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() { // Bob manually refunds bob_join_handle.abort(); let bob_state = bob::refund( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, diff --git a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs index 49d73a58..5c8e0f20 100644 --- a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs +++ b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs @@ -10,7 +10,7 @@ use swap::protocol::{alice, bob}; async fn given_bob_manually_cancels_when_timelock_not_expired_errors() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); let alice_swap = ctx.alice_next_swap().await; @@ -26,7 +26,7 @@ async fn given_bob_manually_cancels_when_timelock_not_expired_errors() { // Bob tries but fails to manually cancel let result = bob::cancel( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, @@ -45,7 +45,7 @@ async fn given_bob_manually_cancels_when_timelock_not_expired_errors() { // Bob tries but fails to manually refund bob::refund( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, diff --git a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force.rs b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force.rs index 057db955..df06416d 100644 --- a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force.rs +++ b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired_force.rs @@ -9,7 +9,7 @@ use swap::protocol::{alice, bob}; async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); let alice_swap = ctx.alice_next_swap().await; @@ -25,7 +25,7 @@ async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() { // Bob forces a cancel that will fail let is_error = bob::cancel( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, @@ -43,7 +43,7 @@ async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() { // Bob forces a refund that will fail let is_error = bob::refund( - bob_swap.swap_id, + bob_swap.id, bob_swap.state, bob_swap.bitcoin_wallet, bob_swap.db, diff --git a/swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs b/swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs index 11ae81b9..a580a6be 100644 --- a/swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs +++ b/swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs @@ -11,7 +11,7 @@ async fn concurrent_bobs_after_xmr_lock_proof_sent() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap_1, bob_join_handle_1) = ctx.bob_swap().await; - let swap_id = bob_swap_1.swap_id; + let swap_id = bob_swap_1.id; let bob_swap_1 = tokio::spawn(bob::run_until(bob_swap_1, is_xmr_locked)); diff --git a/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs b/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs index ed3efafe..a15d6cae 100644 --- a/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs +++ b/swap/tests/concurrent_bobs_before_xmr_lock_proof_sent.rs @@ -11,7 +11,7 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap_1, bob_join_handle_1) = ctx.bob_swap().await; - let swap_id = bob_swap_1.swap_id; + let swap_id = bob_swap_1.id; let bob_swap_1 = tokio::spawn(bob::run_until(bob_swap_1, is_btc_locked)); diff --git a/swap/tests/ensure_same_swap_id.rs b/swap/tests/ensure_same_swap_id.rs index 1dbc7046..48758ecd 100644 --- a/swap/tests/ensure_same_swap_id.rs +++ b/swap/tests/ensure_same_swap_id.rs @@ -7,7 +7,7 @@ use swap::protocol::bob; async fn ensure_same_swap_id_for_alice_and_bob() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap, _) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let _ = tokio::spawn(bob::run(bob_swap)); // once Bob's swap is spawned we can retrieve Alice's swap and assert on the diff --git a/swap/tests/happy_path_restart_bob_after_xmr_locked.rs b/swap/tests/happy_path_restart_bob_after_xmr_locked.rs index 8e18f5ed..a07fb2f2 100644 --- a/swap/tests/happy_path_restart_bob_after_xmr_locked.rs +++ b/swap/tests/happy_path_restart_bob_after_xmr_locked.rs @@ -9,7 +9,7 @@ use swap::protocol::{alice, bob}; async fn given_bob_restarts_after_xmr_is_locked_resume_swap() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_xmr_locked)); let alice_swap = ctx.alice_next_swap().await; diff --git a/swap/tests/happy_path_restart_bob_before_xmr_locked.rs b/swap/tests/happy_path_restart_bob_before_xmr_locked.rs index 8e18f5ed..a07fb2f2 100644 --- a/swap/tests/happy_path_restart_bob_before_xmr_locked.rs +++ b/swap/tests/happy_path_restart_bob_before_xmr_locked.rs @@ -9,7 +9,7 @@ use swap::protocol::{alice, bob}; async fn given_bob_restarts_after_xmr_is_locked_resume_swap() { harness::setup_test(SlowCancelConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_xmr_locked)); let alice_swap = ctx.alice_next_swap().await; diff --git a/swap/tests/punish.rs b/swap/tests/punish.rs index bf053f5b..ef498d10 100644 --- a/swap/tests/punish.rs +++ b/swap/tests/punish.rs @@ -11,7 +11,7 @@ use swap::protocol::{alice, bob}; async fn alice_punishes_if_bob_never_acts_after_fund() { harness::setup_test(FastPunishConfig, |mut ctx| async move { let (bob_swap, bob_join_handle) = ctx.bob_swap().await; - let bob_swap_id = bob_swap.swap_id; + let bob_swap_id = bob_swap.id; let bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked)); let alice_swap = ctx.alice_next_swap().await;