From b609064a20e2e5e4a1da4c41fba5cfd632896af0 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Fri, 16 Aug 2024 10:21:04 -0300 Subject: [PATCH] refactor: rename recoverable to retryable Signed-off-by: Gustavo Inacio --- tap_core/src/manager/tap_manager.rs | 2 +- tap_core/src/receipt/checks.rs | 2 +- tap_core/src/receipt/error.rs | 4 ++-- tap_core/src/receipt/received_receipt.rs | 6 +++--- tap_core/tests/manager_test.rs | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tap_core/src/manager/tap_manager.rs b/tap_core/src/manager/tap_manager.rs index 14fad60c..ef0d47fc 100644 --- a/tap_core/src/manager/tap_manager.rs +++ b/tap_core/src/manager/tap_manager.rs @@ -142,7 +142,7 @@ where let receipt = receipt .finalize_receipt_checks(&self.checks) .await - .map_err(|e| Error::ReceiptError(ReceiptError::RecoverableCheckError(e)))?; + .map_err(|e| Error::ReceiptError(ReceiptError::RetryableCheck(e)))?; match receipt { Ok(checked) => awaiting_reserve_receipts.push(checked), diff --git a/tap_core/src/receipt/checks.rs b/tap_core/src/receipt/checks.rs index 5ece5ac7..2922415a 100644 --- a/tap_core/src/receipt/checks.rs +++ b/tap_core/src/receipt/checks.rs @@ -50,7 +50,7 @@ pub type CheckResult = Result<(), CheckError>; #[derive(thiserror::Error, Debug)] pub enum CheckError { #[error(transparent)] - Recoverable(anyhow::Error), + Retryable(anyhow::Error), #[error(transparent)] Failure(anyhow::Error), } diff --git a/tap_core/src/receipt/error.rs b/tap_core/src/receipt/error.rs index 28a5d894..ddf55ead 100644 --- a/tap_core/src/receipt/error.rs +++ b/tap_core/src/receipt/error.rs @@ -23,7 +23,7 @@ pub enum ReceiptError { #[error("Attempt to collect escrow failed")] SubtractEscrowFailed, #[error("Issue encountered while performing check: {0}")] - CheckFailedToComplete(String), + CheckFailure(String), #[error("Issue encountered while performing check: {0}")] - RecoverableCheckError(String), + RetryableCheck(String), } diff --git a/tap_core/src/receipt/received_receipt.rs b/tap_core/src/receipt/received_receipt.rs index 260e2590..c45d51a7 100644 --- a/tap_core/src/receipt/received_receipt.rs +++ b/tap_core/src/receipt/received_receipt.rs @@ -94,8 +94,8 @@ impl ReceiptWithState { for check in checks { // return early on an error check.check(self).await.map_err(|e| match e { - CheckError::Recoverable(e) => ReceiptError::RecoverableCheckError(e.to_string()), - CheckError::Failure(e) => ReceiptError::CheckFailedToComplete(e.to_string()), + CheckError::Retryable(e) => ReceiptError::RetryableCheck(e.to_string()), + CheckError::Failure(e) => ReceiptError::CheckFailure(e.to_string()), })?; } Ok(()) @@ -111,7 +111,7 @@ impl ReceiptWithState { checks: &[ReceiptCheck], ) -> Result, String> { let all_checks_passed = self.perform_checks(checks).await; - if let Err(ReceiptError::RecoverableCheckError(e)) = all_checks_passed { + if let Err(ReceiptError::RetryableCheck(e)) = all_checks_passed { Err(e.to_string()) } else if let Err(e) = all_checks_passed { Ok(Err(self.perform_state_error(e))) diff --git a/tap_core/tests/manager_test.rs b/tap_core/tests/manager_test.rs index 516d3822..8b7a05d9 100644 --- a/tap_core/tests/manager_test.rs +++ b/tap_core/tests/manager_test.rs @@ -535,21 +535,21 @@ async fn manager_create_rav_and_ignore_invalid_receipts( #[rstest] #[tokio::test] -async fn test_recoverable_checks( +async fn test_retryable_checks( allocation_ids: Vec
, domain_separator: Eip712Domain, context: ContextFixture, ) { - struct RecoverableCheck(Arc); + struct RetryableCheck(Arc); #[async_trait::async_trait] - impl Check for RecoverableCheck { + impl Check for RetryableCheck { async fn check(&self, receipt: &ReceiptWithState) -> Result<(), CheckError> { // we want to fail only if nonce is 5 and if is create rav step if self.0.load(std::sync::atomic::Ordering::SeqCst) && receipt.signed_receipt().message.nonce == 5 { - Err(CheckError::Recoverable(anyhow!("Recoverable error"))) + Err(CheckError::Retryable(anyhow!("Recoverable error"))) } else { Ok(()) } @@ -567,7 +567,7 @@ async fn test_recoverable_checks( let is_create_rav = Arc::new(AtomicBool::new(false)); let mut checks: Vec> = checks.iter().cloned().collect(); - checks.push(Arc::new(RecoverableCheck(is_create_rav.clone()))); + checks.push(Arc::new(RetryableCheck(is_create_rav.clone()))); let manager = Manager::new( domain_separator.clone(), @@ -602,7 +602,7 @@ async fn test_recoverable_checks( assert_eq!( rav_request.expect_err("Didn't fail").to_string(), - tap_core::Error::ReceiptError(tap_core::receipt::ReceiptError::RecoverableCheckError( + tap_core::Error::ReceiptError(tap_core::receipt::ReceiptError::RetryableCheck( "Recoverable error".to_string() )) .to_string()