Log exchange rate at each state.

This commit is contained in:
Philipp Hoenisch 2021-05-05 13:43:46 +10:00
parent 227c383d76
commit 1706b36800
No known key found for this signature in database
GPG Key ID: E5F8E74C672BC666
18 changed files with 97 additions and 29 deletions

View File

@ -140,7 +140,7 @@ async fn main() -> Result<()> {
Arc::new(bitcoin_wallet), Arc::new(bitcoin_wallet),
Arc::new(monero_wallet), Arc::new(monero_wallet),
Arc::new(db), Arc::new(db),
kraken_rate, kraken_rate.clone(),
config.maker.min_buy_btc, config.maker.min_buy_btc,
config.maker.max_buy_btc, config.maker.max_buy_btc,
) )
@ -148,9 +148,10 @@ async fn main() -> Result<()> {
tokio::spawn(async move { tokio::spawn(async move {
while let Some(swap) = swap_receiver.recv().await { while let Some(swap) = swap_receiver.recv().await {
let rate = kraken_rate.clone();
tokio::spawn(async move { tokio::spawn(async move {
let swap_id = swap.swap_id; let swap_id = swap.swap_id;
match run(swap).await { match run(swap, rate).await {
Ok(state) => { Ok(state) => {
tracing::debug!(%swap_id, "Swap finished with state {}", state) tracing::debug!(%swap_id, "Swap finished with state {}", state)
} }

View File

@ -2,7 +2,7 @@
//! Alice holds XMR and wishes receive BTC. //! Alice holds XMR and wishes receive BTC.
use crate::bitcoin::ExpiredTimelocks; use crate::bitcoin::ExpiredTimelocks;
use crate::env::Config; use crate::env::Config;
use crate::protocol::alice::event_loop::EventLoopHandle; use crate::protocol::alice::event_loop::{EventLoopHandle, LatestRate};
use crate::protocol::alice::{AliceState, Swap}; use crate::protocol::alice::{AliceState, Swap};
use crate::{bitcoin, database, monero}; use crate::{bitcoin, database, monero};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
@ -11,12 +11,22 @@ use tokio::time::timeout;
use tracing::{error, info}; use tracing::{error, info};
use uuid::Uuid; use uuid::Uuid;
pub async fn run(swap: Swap) -> Result<AliceState> { pub async fn run<LR>(swap: Swap, rate_service: LR) -> Result<AliceState>
run_until(swap, |_| false).await where
LR: LatestRate + Clone,
{
run_until(swap, |_| false, rate_service).await
} }
#[tracing::instrument(name = "swap", skip(swap,exit_early), fields(id = %swap.swap_id), err)] #[tracing::instrument(name = "swap", skip(swap,exit_early,rate_service), fields(id = %swap.swap_id), err)]
pub async fn run_until(mut swap: Swap, exit_early: fn(&AliceState) -> bool) -> Result<AliceState> { pub async fn run_until<LR>(
mut swap: Swap,
exit_early: fn(&AliceState) -> bool,
rate_service: LR,
) -> Result<AliceState>
where
LR: LatestRate + Clone,
{
let mut current_state = swap.state; let mut current_state = swap.state;
while !is_complete(&current_state) && !exit_early(&current_state) { while !is_complete(&current_state) && !exit_early(&current_state) {
@ -27,6 +37,7 @@ pub async fn run_until(mut swap: Swap, exit_early: fn(&AliceState) -> bool) -> R
swap.bitcoin_wallet.as_ref(), swap.bitcoin_wallet.as_ref(),
swap.monero_wallet.as_ref(), swap.monero_wallet.as_ref(),
&swap.env_config, &swap.env_config,
rate_service.clone(),
) )
.await?; .await?;
@ -39,15 +50,23 @@ pub async fn run_until(mut swap: Swap, exit_early: fn(&AliceState) -> bool) -> R
Ok(current_state) Ok(current_state)
} }
async fn next_state( async fn next_state<LR>(
swap_id: Uuid, swap_id: Uuid,
state: AliceState, state: AliceState,
event_loop_handle: &mut EventLoopHandle, event_loop_handle: &mut EventLoopHandle,
bitcoin_wallet: &bitcoin::Wallet, bitcoin_wallet: &bitcoin::Wallet,
monero_wallet: &monero::Wallet, monero_wallet: &monero::Wallet,
env_config: &Config, env_config: &Config,
) -> Result<AliceState> { mut rate_service: LR,
info!("Current state: {}", state); ) -> Result<AliceState>
where
LR: LatestRate,
{
let rate = rate_service
.latest_rate()
.map_or("NaN".to_string(), |rate| format!("{}", rate));
info!(%state, %rate, "Update");
Ok(match state { Ok(match state {
AliceState::Started { state3 } => { AliceState::Started { state3 } => {

View File

@ -3,6 +3,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::FastCancelConfig; use harness::FastCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -15,7 +16,11 @@ async fn given_alice_and_bob_manually_refund_after_funds_locked_both_refund() {
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;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));

View File

@ -3,6 +3,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -15,7 +16,11 @@ async fn given_alice_and_bob_manually_cancel_when_timelock_not_expired_errors()
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;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));

View File

@ -3,6 +3,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -15,7 +16,11 @@ async fn given_alice_and_bob_manually_force_cancel_when_timelock_not_expired_err
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;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));

View File

@ -3,6 +3,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::FastPunishConfig; use harness::FastPunishConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -20,7 +21,11 @@ async fn alice_manually_punishes_after_bob_dead() {
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_bitcoin_wallet = alice_swap.bitcoin_wallet.clone(); let alice_bitcoin_wallet = alice_swap.bitcoin_wallet.clone();
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::alice_run_until::is_encsig_learned; use harness::alice_run_until::is_encsig_learned;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::redeem::Finality; use swap::protocol::alice::redeem::Finality;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -15,7 +16,11 @@ async fn alice_manually_redeems_after_enc_sig_learned() {
let bob_swap = tokio::spawn(bob::run(bob_swap)); let bob_swap = tokio::spawn(bob::run(bob_swap));
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_encsig_learned)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_encsig_learned,
FixedRate::default(),
));
let alice_state = alice_swap.await??; let alice_state = alice_swap.await??;
assert!(matches!(alice_state, AliceState::EncSigLearned { .. })); assert!(matches!(alice_state, AliceState::EncSigLearned { .. }));

View File

@ -3,6 +3,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::FastPunishConfig; use harness::FastPunishConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -19,7 +20,11 @@ async fn alice_punishes_after_restart_if_bob_dead() {
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_bitcoin_wallet = alice_swap.bitcoin_wallet.clone(); let alice_bitcoin_wallet = alice_swap.bitcoin_wallet.clone();
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));
@ -40,7 +45,7 @@ async fn alice_punishes_after_restart_if_bob_dead() {
ctx.restart_alice().await; ctx.restart_alice().await;
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let alice_state = alice_swap.await??; let alice_state = alice_swap.await??;
ctx.assert_alice_punished(alice_state).await; ctx.assert_alice_punished(alice_state).await;

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::FastCancelConfig; use harness::FastCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -14,7 +15,11 @@ async fn alice_refunds_after_restart_if_bob_already_refunded() {
let bob_swap = tokio::spawn(bob::run(bob_swap)); let bob_swap = tokio::spawn(bob::run(bob_swap));
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
ctx.assert_bob_refunded(bob_state).await; ctx.assert_bob_refunded(bob_state).await;
@ -27,7 +32,7 @@ async fn alice_refunds_after_restart_if_bob_already_refunded() {
ctx.restart_alice().await; ctx.restart_alice().await;
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let alice_state = alice_swap.await??; let alice_state = alice_swap.await??;
ctx.assert_alice_refunded(alice_state).await; ctx.assert_alice_refunded(alice_state).await;

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::bob_run_until::is_xmr_locked; use harness::bob_run_until::is_xmr_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -16,7 +17,7 @@ async fn concurrent_bobs_after_xmr_lock_proof_sent() {
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));
let alice_swap_1 = ctx.alice_next_swap().await; let alice_swap_1 = ctx.alice_next_swap().await;
let alice_swap_1 = tokio::spawn(alice::run(alice_swap_1)); let alice_swap_1 = tokio::spawn(alice::run(alice_swap_1, FixedRate::default()));
let bob_state_1 = bob_swap_1.await??; let bob_state_1 = bob_swap_1.await??;
assert!(matches!(bob_state_1, BobState::XmrLocked { .. })); assert!(matches!(bob_state_1, BobState::XmrLocked { .. }));
@ -28,7 +29,7 @@ async fn concurrent_bobs_after_xmr_lock_proof_sent() {
let bob_swap_2 = tokio::spawn(bob::run(bob_swap_2)); let bob_swap_2 = tokio::spawn(bob::run(bob_swap_2));
let alice_swap_2 = ctx.alice_next_swap().await; let alice_swap_2 = ctx.alice_next_swap().await;
let alice_swap_2 = tokio::spawn(alice::run(alice_swap_2)); let alice_swap_2 = tokio::spawn(alice::run(alice_swap_2, FixedRate::default()));
// The 2nd swap should ALWAYS finish successfully in this // The 2nd swap should ALWAYS finish successfully in this
// scenario // scenario

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -16,7 +17,7 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() {
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));
let alice_swap_1 = ctx.alice_next_swap().await; let alice_swap_1 = ctx.alice_next_swap().await;
let alice_swap_1 = tokio::spawn(alice::run(alice_swap_1)); let alice_swap_1 = tokio::spawn(alice::run(alice_swap_1, FixedRate::default()));
let bob_state_1 = bob_swap_1.await??; let bob_state_1 = bob_swap_1.await??;
assert!(matches!(bob_state_1, BobState::BtcLocked(_))); assert!(matches!(bob_state_1, BobState::BtcLocked(_)));
@ -28,7 +29,7 @@ async fn concurrent_bobs_before_xmr_lock_proof_sent() {
let bob_swap_2 = tokio::spawn(bob::run(bob_swap_2)); let bob_swap_2 = tokio::spawn(bob::run(bob_swap_2));
let alice_swap_2 = ctx.alice_next_swap().await; let alice_swap_2 = ctx.alice_next_swap().await;
let alice_swap_2 = tokio::spawn(alice::run(alice_swap_2)); let alice_swap_2 = tokio::spawn(alice::run(alice_swap_2, FixedRate::default()));
// The 2nd swap ALWAYS finish successfully in this // The 2nd swap ALWAYS finish successfully in this
// scenario, but will receive an "unwanted" transfer proof that is ignored in // scenario, but will receive an "unwanted" transfer proof that is ignored in

View File

@ -1,6 +1,7 @@
pub mod harness; pub mod harness;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
use tokio::join; use tokio::join;
@ -11,7 +12,7 @@ async fn happy_path() {
let bob_swap = tokio::spawn(bob::run(bob_swap)); let bob_swap = tokio::spawn(bob::run(bob_swap));
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let (bob_state, alice_state) = join!(bob_swap, alice_swap); let (bob_state, alice_state) = join!(bob_swap, alice_swap);

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::alice_run_until::is_xmr_lock_transaction_sent; use harness::alice_run_until::is_xmr_lock_transaction_sent;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::alice::AliceState; use swap::protocol::alice::AliceState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -12,7 +13,11 @@ async fn given_alice_restarts_after_xmr_is_locked_resume_swap() {
let bob_swap = tokio::spawn(bob::run(bob_swap)); let bob_swap = tokio::spawn(bob::run(bob_swap));
let alice_swap = ctx.alice_next_swap().await; let alice_swap = ctx.alice_next_swap().await;
let alice_swap = tokio::spawn(alice::run_until(alice_swap, is_xmr_lock_transaction_sent)); let alice_swap = tokio::spawn(alice::run_until(
alice_swap,
is_xmr_lock_transaction_sent,
FixedRate::default(),
));
let alice_state = alice_swap.await??; let alice_state = alice_swap.await??;
@ -28,7 +33,7 @@ async fn given_alice_restarts_after_xmr_is_locked_resume_swap() {
AliceState::XmrLockTransactionSent { .. } AliceState::XmrLockTransactionSent { .. }
)); ));
let alice_state = alice::run(alice_swap).await?; let alice_state = alice::run(alice_swap, FixedRate::default()).await?;
ctx.assert_alice_redeemed(alice_state).await; ctx.assert_alice_redeemed(alice_state).await;
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::bob_run_until::is_xmr_locked; use harness::bob_run_until::is_xmr_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -13,7 +14,7 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
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;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::bob_run_until::is_xmr_locked; use harness::bob_run_until::is_xmr_locked;
use harness::SlowCancelConfig; use harness::SlowCancelConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -13,7 +14,7 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
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;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;

View File

@ -2,6 +2,7 @@ pub mod harness;
use harness::bob_run_until::is_btc_locked; use harness::bob_run_until::is_btc_locked;
use harness::FastPunishConfig; use harness::FastPunishConfig;
use swap::protocol::alice::event_loop::FixedRate;
use swap::protocol::bob::BobState; use swap::protocol::bob::BobState;
use swap::protocol::{alice, bob}; use swap::protocol::{alice, bob};
@ -15,7 +16,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() {
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;
let alice_swap = tokio::spawn(alice::run(alice_swap)); let alice_swap = tokio::spawn(alice::run(alice_swap, FixedRate::default()));
let bob_state = bob_swap.await??; let bob_state = bob_swap.await??;
assert!(matches!(bob_state, BobState::BtcLocked { .. })); assert!(matches!(bob_state, BobState::BtcLocked { .. }));