From 38a128706bfa4709a5c96a8f1aafd92cb4a233d9 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 15 Dec 2020 10:26:53 +1100 Subject: [PATCH] Use `-ed` terminology for cancel.. test --- swap/src/alice/swap.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/swap/src/alice/swap.rs b/swap/src/alice/swap.rs index 85251d27..c17a7476 100644 --- a/swap/src/alice/swap.rs +++ b/swap/src/alice/swap.rs @@ -80,7 +80,7 @@ pub enum AliceState { state3: State3, }, XmrRefunded, - Cancelling { + T1Expired { state3: State3, }, Punished, @@ -102,7 +102,7 @@ impl fmt::Display for AliceState { AliceState::SafelyAborted => write!(f, "safely_aborted"), AliceState::BtcPunishable { .. } => write!(f, "btc_punishable"), AliceState::XmrRefunded => write!(f, "xmr_refunded"), - AliceState::Cancelling { .. } => write!(f, "cancelling"), + AliceState::T1Expired { .. } => write!(f, "t1 is expired"), } } } @@ -136,7 +136,7 @@ impl From<&AliceState> for state::Alice { AliceState::XmrRefunded => Alice::SwapComplete, // TODO(Franck): it may be more efficient to store the fact that we already want to // abort - AliceState::Cancelling { state3 } => Alice::XmrLocked(state3.clone()), + AliceState::T1Expired { state3 } => Alice::XmrLocked(state3.clone()), AliceState::Punished => Alice::SwapComplete, AliceState::SafelyAborted => Alice::SwapComplete, } @@ -401,14 +401,14 @@ pub async fn run_until( pin_mut!(t1_timeout); match select(t1_timeout, wait_for_enc_sig).await { - Either::Left(_) => AliceState::Cancelling { state3 }, + Either::Left(_) => AliceState::T1Expired { state3 }, Either::Right((enc_sig, _)) => AliceState::EncSignLearned { state3, encrypted_signature: enc_sig?, }, } } - _ => AliceState::Cancelling { state3 }, + _ => AliceState::T1Expired { state3 }, }; let db_state = (&state).into(); @@ -440,7 +440,9 @@ pub async fn run_until( ) { Ok(tx) => tx, Err(_) => { - let state = AliceState::Cancelling { state3 }; + state3.wait_for_t1(bitcoin_wallet.as_ref()).await; + + let state = AliceState::T1Expired { state3 }; let db_state = (&state).into(); db.insert_latest_state(swap_id, Swap::Alice(db_state)) .await?; @@ -484,7 +486,7 @@ pub async fn run_until( ) .await } - AliceState::Cancelling { state3 } => { + AliceState::T1Expired { state3 } => { let tx_cancel = publish_cancel_transaction( state3.tx_lock.clone(), state3.a.clone(),