From 5953037b8184fc3de1c849c3abc80cfe4c8e37c4 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 4 Mar 2021 17:02:03 +1100 Subject: [PATCH] Don't repeat the module name within the type --- swap/src/bin/swap_cli.rs | 5 ++--- swap/src/protocol/bob/cancel.rs | 8 ++++---- ...sing_cancel_and_refund_command_timelock_not_expired.rs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/swap/src/bin/swap_cli.rs b/swap/src/bin/swap_cli.rs index 9d95e41e..ffe8cf51 100644 --- a/swap/src/bin/swap_cli.rs +++ b/swap/src/bin/swap_cli.rs @@ -26,7 +26,6 @@ use swap::database::Database; use swap::execution_params::GetExecutionParams; use swap::network::quote::BidQuote; use swap::protocol::bob; -use swap::protocol::bob::cancel::CancelError; use swap::protocol::bob::{Builder, EventLoop}; use swap::seed::Seed; use swap::{bitcoin, execution_params, monero}; @@ -213,11 +212,11 @@ async fn main() -> Result<()> { Ok((txid, _)) => { debug!("Cancel transaction successfully published with id {}", txid) } - Err(CancelError::CancelTimelockNotExpiredYet) => error!( + Err(bob::cancel::Error::CancelTimelockNotExpiredYet) => error!( "The Cancel Transaction cannot be published yet, \ because the timelock has not expired. Please try again later." ), - Err(CancelError::CancelTxAlreadyPublished) => { + Err(bob::cancel::Error::CancelTxAlreadyPublished) => { warn!("The Cancel Transaction has already been published.") } } diff --git a/swap/src/protocol/bob/cancel.rs b/swap/src/protocol/bob/cancel.rs index c3c70fd1..90209383 100644 --- a/swap/src/protocol/bob/cancel.rs +++ b/swap/src/protocol/bob/cancel.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use uuid::Uuid; #[derive(Debug, thiserror::Error, Clone, Copy)] -pub enum CancelError { +pub enum Error { #[error("The cancel timelock has not expired yet.")] CancelTimelockNotExpiredYet, #[error("The cancel transaction has already been published.")] @@ -19,7 +19,7 @@ pub async fn cancel( bitcoin_wallet: Arc, db: Database, force: bool, -) -> Result> { +) -> Result> { let state4 = match state { BobState::BtcLocked(state3) => state3.cancel(), BobState::XmrLockProofReceived { state, .. } => state.cancel(), @@ -35,7 +35,7 @@ pub async fn cancel( if !force { if let ExpiredTimelocks::None = state4.expired_timelock(bitcoin_wallet.as_ref()).await? { - return Ok(Err(CancelError::CancelTimelockNotExpiredYet)); + return Ok(Err(Error::CancelTimelockNotExpiredYet)); } if state4 @@ -47,7 +47,7 @@ pub async fn cancel( let db_state = state.into(); db.insert_latest_state(swap_id, Swap::Bob(db_state)).await?; - return Ok(Err(CancelError::CancelTxAlreadyPublished)); + return Ok(Err(Error::CancelTxAlreadyPublished)); } } diff --git a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs index f2d03608..d5f23aad 100644 --- a/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs +++ b/swap/tests/bob_refunds_using_cancel_and_refund_command_timelock_not_expired.rs @@ -1,6 +1,6 @@ pub mod testutils; -use bob::cancel::CancelError; +use bob::cancel::Error; use swap::protocol::bob; use swap::protocol::bob::BobState; use testutils::bob_run_until::is_btc_locked; @@ -30,7 +30,7 @@ async fn given_bob_manually_cancels_when_timelock_not_expired_errors() { .err() .unwrap(); - assert!(matches!(result, CancelError::CancelTimelockNotExpiredYet)); + assert!(matches!(result, Error::CancelTimelockNotExpiredYet)); let (bob_swap, bob_join_handle) = ctx.stop_and_resume_bob_from_db(bob_join_handle).await; assert!(matches!(bob_swap.state, BobState::BtcLocked { .. }));