Use -ed terminology for cancel.. test

This commit is contained in:
Franck Royer 2020-12-15 10:26:53 +11:00
parent 1a5b9f9fa9
commit 38a128706b
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4

View File

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