Don't stutter

This commit is contained in:
Thomas Eizinger 2021-04-16 11:48:15 +10:00
parent 7adeaae12d
commit e266fb07ef
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
12 changed files with 20 additions and 20 deletions

View File

@ -26,7 +26,7 @@ pub struct Swap {
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
pub monero_wallet: Arc<monero::Wallet>,
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,
})

View File

@ -33,7 +33,7 @@ pub async fn run_until(
while !is_target_state(&current_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?;
}

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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));

View File

@ -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));

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;