From 405e377f798976d9de1cf7233726d55770706e4c Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 22 Dec 2020 14:53:21 +1100 Subject: [PATCH] Rename `EncSign` to `EncSig` `EncSig` means "encrypted signature", the item, not be confused with "signing", the action --- swap/src/alice/swap.rs | 20 ++++++++++---------- swap/src/state.rs | 4 ++-- swap/tests/happy_path_restart_alice.rs | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/swap/src/alice/swap.rs b/swap/src/alice/swap.rs index 4f0b9cf6..262e831a 100644 --- a/swap/src/alice/swap.rs +++ b/swap/src/alice/swap.rs @@ -60,7 +60,7 @@ pub enum AliceState { XmrLocked { state3: State3, }, - EncSignLearned { + EncSigLearned { state3: State3, encrypted_signature: EncryptedSignature, }, @@ -92,7 +92,7 @@ impl fmt::Display for AliceState { AliceState::Negotiated { .. } => write!(f, "negotiated"), AliceState::BtcLocked { .. } => write!(f, "btc_locked"), AliceState::XmrLocked { .. } => write!(f, "xmr_locked"), - AliceState::EncSignLearned { .. } => write!(f, "encsig_learned"), + AliceState::EncSigLearned { .. } => write!(f, "encsig_learned"), AliceState::BtcRedeemed => write!(f, "btc_redeemed"), AliceState::BtcCancelled { .. } => write!(f, "btc_cancelled"), AliceState::BtcRefunded { .. } => write!(f, "btc_refunded"), @@ -111,10 +111,10 @@ impl From<&AliceState> for state::Alice { AliceState::Negotiated { state3, .. } => Alice::Negotiated(state3.clone()), AliceState::BtcLocked { state3, .. } => Alice::BtcLocked(state3.clone()), AliceState::XmrLocked { state3 } => Alice::XmrLocked(state3.clone()), - AliceState::EncSignLearned { + AliceState::EncSigLearned { state3, - encrypted_signature, - } => Alice::EncSignLearned { + encrypted_signature,, + } => Alice::EncSigLearned { state: state3.clone(), encrypted_signature: encrypted_signature.clone(), }, @@ -159,10 +159,10 @@ impl TryFrom for AliceState { }, Alice::XmrLocked(state3) => XmrLocked { state3 }, Alice::BtcRedeemable { .. } => bail!("BtcRedeemable state is unexpected"), - Alice::EncSignLearned { + Alice::EncSigLearned { state, encrypted_signature, - } => EncSignLearned { + } => EncSigLearned { state3: state, encrypted_signature, }, @@ -253,7 +253,7 @@ pub fn is_xmr_locked(state: &AliceState) -> bool { pub fn is_encsig_learned(state: &AliceState) -> bool { matches!( state, - AliceState::EncSignLearned{..} + AliceState::EncSigLearned{..} ) } @@ -401,7 +401,7 @@ pub async fn run_until( match select(t1_timeout, wait_for_enc_sig).await { Either::Left(_) => AliceState::T1Expired { state3 }, - Either::Right((enc_sig, _)) => AliceState::EncSignLearned { + Either::Right((enc_sig, _)) => AliceState::EncSigLearned { state3, encrypted_signature: enc_sig?, }, @@ -425,7 +425,7 @@ pub async fn run_until( ) .await } - AliceState::EncSignLearned { + AliceState::EncSigLearned { state3, encrypted_signature, } => { diff --git a/swap/src/state.rs b/swap/src/state.rs index a2f209c6..5540aa70 100644 --- a/swap/src/state.rs +++ b/swap/src/state.rs @@ -20,7 +20,7 @@ pub enum Alice { state: alice::State3, redeem_tx: bitcoin::Transaction, }, - EncSignLearned { + EncSigLearned { state: alice::State3, encrypted_signature: EncryptedSignature, }, @@ -81,7 +81,7 @@ impl Display for Alice { Alice::BtcPunishable(_) => f.write_str("Bitcoin punishable"), Alice::BtcRefunded { .. } => f.write_str("Monero refundable"), Alice::SwapComplete => f.write_str("Swap complete"), - Alice::EncSignLearned { .. } => f.write_str("Encrypted signature learned"), + Alice::EncSigLearned { .. } => f.write_str("Encrypted signature learned"), } } } diff --git a/swap/tests/happy_path_restart_alice.rs b/swap/tests/happy_path_restart_alice.rs index db21ba67..6b1ad0cd 100644 --- a/swap/tests/happy_path_restart_alice.rs +++ b/swap/tests/happy_path_restart_alice.rs @@ -108,13 +108,13 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() { .await .unwrap(); - assert!(matches!(alice_state, AliceState::EncSignLearned {..})); + assert!(matches!(alice_state, AliceState::EncSigLearned {..})); let alice_db = Database::open(alice_db_datadir.path()).unwrap(); let state_before_restart = alice_db.get_state(alice_swap_id).unwrap(); if let swap::state::Swap::Alice(state) = state_before_restart.clone() { - assert!(matches!(state, swap::state::Alice::EncSignLearned {..})); + assert!(matches!(state, swap::state::Alice::EncSigLearned {..})); } let (mut event_loop_after_restart, event_loop_handle_after_restart) =