mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Don't stutter
This commit is contained in:
parent
7adeaae12d
commit
e266fb07ef
@ -26,7 +26,7 @@ pub struct Swap {
|
|||||||
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
|
pub bitcoin_wallet: Arc<bitcoin::Wallet>,
|
||||||
pub monero_wallet: Arc<monero::Wallet>,
|
pub monero_wallet: Arc<monero::Wallet>,
|
||||||
pub env_config: env::Config,
|
pub env_config: env::Config,
|
||||||
pub swap_id: Uuid,
|
pub id: Uuid,
|
||||||
pub receive_monero_address: monero::Address,
|
pub receive_monero_address: monero::Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ impl Builder {
|
|||||||
db: self.db,
|
db: self.db,
|
||||||
bitcoin_wallet: self.bitcoin_wallet.clone(),
|
bitcoin_wallet: self.bitcoin_wallet.clone(),
|
||||||
monero_wallet: self.monero_wallet.clone(),
|
monero_wallet: self.monero_wallet.clone(),
|
||||||
swap_id: self.swap_id,
|
id: self.swap_id,
|
||||||
env_config: self.env_config,
|
env_config: self.env_config,
|
||||||
receive_monero_address: self.receive_monero_address,
|
receive_monero_address: self.receive_monero_address,
|
||||||
})
|
})
|
||||||
|
@ -33,7 +33,7 @@ pub async fn run_until(
|
|||||||
|
|
||||||
while !is_target_state(¤t_state) {
|
while !is_target_state(¤t_state) {
|
||||||
current_state = next_state(
|
current_state = next_state(
|
||||||
swap.swap_id,
|
swap.id,
|
||||||
current_state,
|
current_state,
|
||||||
&mut swap.event_loop_handle,
|
&mut swap.event_loop_handle,
|
||||||
swap.bitcoin_wallet.as_ref(),
|
swap.bitcoin_wallet.as_ref(),
|
||||||
@ -45,7 +45,7 @@ pub async fn run_until(
|
|||||||
|
|
||||||
let db_state = current_state.clone().into();
|
let db_state = current_state.clone().into();
|
||||||
swap.db
|
swap.db
|
||||||
.insert_latest_state(swap.swap_id, Swap::Bob(db_state))
|
.insert_latest_state(swap.id, Swap::Bob(db_state))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn alice_punishes_after_restart_if_punish_timelock_expired() {
|
async fn alice_punishes_after_restart_if_punish_timelock_expired() {
|
||||||
harness::setup_test(FastPunishConfig, |mut ctx| async move {
|
harness::setup_test(FastPunishConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
let alice_swap = ctx.alice_next_swap().await;
|
||||||
|
@ -9,7 +9,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() {
|
async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() {
|
||||||
harness::setup_test(FastCancelConfig, |mut ctx| async move {
|
harness::setup_test(FastCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
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 manually cancels
|
||||||
bob_join_handle.abort();
|
bob_join_handle.abort();
|
||||||
let (_, state) = bob::cancel(
|
let (_, state) = bob::cancel(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
bob_swap.db,
|
||||||
@ -54,7 +54,7 @@ async fn given_bob_manually_refunds_after_btc_locked_bob_refunds() {
|
|||||||
// Bob manually refunds
|
// Bob manually refunds
|
||||||
bob_join_handle.abort();
|
bob_join_handle.abort();
|
||||||
let bob_state = bob::refund(
|
let bob_state = bob::refund(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
bob_swap.db,
|
||||||
|
@ -10,7 +10,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn given_bob_manually_cancels_when_timelock_not_expired_errors() {
|
async fn given_bob_manually_cancels_when_timelock_not_expired_errors() {
|
||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
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
|
// Bob tries but fails to manually cancel
|
||||||
let result = bob::cancel(
|
let result = bob::cancel(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
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 tries but fails to manually refund
|
||||||
bob::refund(
|
bob::refund(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
bob_swap.db,
|
||||||
|
@ -9,7 +9,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() {
|
async fn given_bob_manually_forces_cancel_when_timelock_not_expired_errors() {
|
||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
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
|
// Bob forces a cancel that will fail
|
||||||
let is_error = bob::cancel(
|
let is_error = bob::cancel(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
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
|
// Bob forces a refund that will fail
|
||||||
let is_error = bob::refund(
|
let is_error = bob::refund(
|
||||||
bob_swap.swap_id,
|
bob_swap.id,
|
||||||
bob_swap.state,
|
bob_swap.state,
|
||||||
bob_swap.bitcoin_wallet,
|
bob_swap.bitcoin_wallet,
|
||||||
bob_swap.db,
|
bob_swap.db,
|
||||||
|
@ -11,7 +11,7 @@ async fn concurrent_bobs_after_xmr_lock_proof_sent() {
|
|||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap_1, bob_join_handle_1) = ctx.bob_swap().await;
|
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));
|
let bob_swap_1 = tokio::spawn(bob::run_until(bob_swap_1, is_xmr_locked));
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() {
|
|||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap_1, bob_join_handle_1) = ctx.bob_swap().await;
|
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));
|
let bob_swap_1 = tokio::spawn(bob::run_until(bob_swap_1, is_btc_locked));
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use swap::protocol::bob;
|
|||||||
async fn ensure_same_swap_id_for_alice_and_bob() {
|
async fn ensure_same_swap_id_for_alice_and_bob() {
|
||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, _) = ctx.bob_swap().await;
|
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));
|
let _ = tokio::spawn(bob::run(bob_swap));
|
||||||
|
|
||||||
// once Bob's swap is spawned we can retrieve Alice's swap and assert on the
|
// once Bob's swap is spawned we can retrieve Alice's swap and assert on the
|
||||||
|
@ -9,7 +9,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_xmr_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
let alice_swap = ctx.alice_next_swap().await;
|
||||||
|
@ -9,7 +9,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
||||||
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
harness::setup_test(SlowCancelConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_xmr_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
let alice_swap = ctx.alice_next_swap().await;
|
||||||
|
@ -11,7 +11,7 @@ use swap::protocol::{alice, bob};
|
|||||||
async fn alice_punishes_if_bob_never_acts_after_fund() {
|
async fn alice_punishes_if_bob_never_acts_after_fund() {
|
||||||
harness::setup_test(FastPunishConfig, |mut ctx| async move {
|
harness::setup_test(FastPunishConfig, |mut ctx| async move {
|
||||||
let (bob_swap, bob_join_handle) = ctx.bob_swap().await;
|
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 bob_swap = tokio::spawn(bob::run_until(bob_swap, is_btc_locked));
|
||||||
|
|
||||||
let alice_swap = ctx.alice_next_swap().await;
|
let alice_swap = ctx.alice_next_swap().await;
|
||||||
|
Loading…
Reference in New Issue
Block a user