Throw appealing error in case that cancel timelock hasnt expired yet

This commit is contained in:
patrini32 2024-06-10 12:21:47 +03:00 committed by patrini32
parent b80cc820f7
commit 3beb41c25c
2 changed files with 2 additions and 5 deletions

View File

@ -75,7 +75,7 @@ pub async fn cancel(
if let ExpiredTimelocks::None { .. } =
state6.expired_timelock(bitcoin_wallet.as_ref()).await?
{
tracing::info!("Cancel timelock hasn't expired yet.");
bail!("Cancel timelock hasn't expired yet");
}
if let Ok(error_code) = parse_rpc_error_code(&err) {
tracing::debug!(%error_code, "parse rpc error");

View File

@ -42,10 +42,7 @@ async fn given_alice_and_bob_manually_cancel_when_timelock_not_expired_errors()
let error = cli::cancel(bob_swap.id, bob_swap.bitcoin_wallet, bob_swap.db)
.await
.unwrap_err();
assert_eq!(
parse_rpc_error_code(&error).unwrap(),
i64::from(RpcErrorCode::RpcVerifyRejected)
);
assert_eq!(error.to_string(), "Cancel timelock hasn't expired yet");
ctx.restart_alice().await;
let alice_swap = ctx.alice_next_swap().await;