From a528655fb69bc5560c77f1b3bd3bba8e6fc46bb7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Raynaud Date: Thu, 28 Nov 2024 16:25:23 +0100 Subject: [PATCH] chore: better naming for caught devnet retryable error --- .../mithril-end-to-end/src/devnet/mod.rs | 2 +- .../mithril-end-to-end/src/devnet/runner.rs | 12 ++++++------ mithril-test-lab/mithril-end-to-end/src/main.rs | 10 ++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/mithril-test-lab/mithril-end-to-end/src/devnet/mod.rs b/mithril-test-lab/mithril-end-to-end/src/devnet/mod.rs index 37b38d1f4a..551593c489 100644 --- a/mithril-test-lab/mithril-end-to-end/src/devnet/mod.rs +++ b/mithril-test-lab/mithril-end-to-end/src/devnet/mod.rs @@ -1,3 +1,3 @@ mod runner; -pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode, UnrecoverableDevnetError}; +pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode, RetryableDevnetError}; diff --git a/mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs b/mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs index 7e2547e386..c2312b9b15 100644 --- a/mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs +++ b/mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs @@ -10,8 +10,8 @@ use thiserror::Error; use tokio::process::Command; #[derive(Error, Debug, PartialEq, Eq)] -#[error("Unrecoverable devnet error: `{0}`")] -pub struct UnrecoverableDevnetError(pub String); +#[error("Retryable devnet error: `{0}`")] +pub struct RetryableDevnetError(pub String); #[derive(Debug, Clone, Default)] pub struct Devnet { @@ -216,7 +216,7 @@ impl Devnet { .with_context(|| "Error while starting the devnet")?; match status.code() { Some(0) => Ok(()), - Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!( + Some(code) => Err(anyhow!(RetryableDevnetError(format!( "Run devnet exited with status code: {code}" )))), None => Err(anyhow!("Run devnet terminated by signal")), @@ -265,7 +265,7 @@ impl Devnet { .with_context(|| "Error while delegating stakes to the pools")?; match status.code() { Some(0) => Ok(()), - Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!( + Some(code) => Err(anyhow!(RetryableDevnetError(format!( "Delegating stakes exited with status code: {code}" )))), None => Err(anyhow!("Delegating stakes terminated by signal")), @@ -291,7 +291,7 @@ impl Devnet { .with_context(|| "Error while writing era marker on chain")?; match status.code() { Some(0) => Ok(()), - Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!( + Some(code) => Err(anyhow!(RetryableDevnetError(format!( "Write era marker on chain exited with status code: {code}" )))), None => Err(anyhow!("Write era marker on chain terminated by signal")), @@ -317,7 +317,7 @@ impl Devnet { .with_context(|| "Error while to transferring funds on chain")?; match status.code() { Some(0) => Ok(()), - Some(code) => Err(anyhow!(UnrecoverableDevnetError(format!( + Some(code) => Err(anyhow!(RetryableDevnetError(format!( "Transfer funds on chain exited with status code: {code}" )))), None => Err(anyhow!("Transfer funds on chain terminated by signal")), diff --git a/mithril-test-lab/mithril-end-to-end/src/main.rs b/mithril-test-lab/mithril-end-to-end/src/main.rs index 1e5f67439a..77efedd372 100644 --- a/mithril-test-lab/mithril-end-to-end/src/main.rs +++ b/mithril-test-lab/mithril-end-to-end/src/main.rs @@ -18,8 +18,8 @@ use tokio::{ use mithril_common::StdResult; use mithril_doc::GenerateDocCommands; use mithril_end_to_end::{ - Devnet, DevnetBootstrapArgs, MithrilInfrastructure, MithrilInfrastructureConfig, RunOnly, Spec, - UnrecoverableDevnetError, + Devnet, DevnetBootstrapArgs, MithrilInfrastructure, MithrilInfrastructureConfig, + RetryableDevnetError, RunOnly, Spec, }; /// Tests args @@ -257,7 +257,7 @@ impl From> for AppResult { match result { Ok(()) => AppResult::Success(), Err(error) => { - if error.is::() { + if error.is::() { AppResult::RetryableError(error) } else { AppResult::UnretryableError(error) @@ -466,9 +466,7 @@ mod tests { assert!(matches!(AppResult::from(Ok(())), AppResult::Success())); assert!(matches!( - AppResult::from(Err(anyhow!(UnrecoverableDevnetError( - "an error".to_string() - )))), + AppResult::from(Err(anyhow!(RetryableDevnetError("an error".to_string())))), AppResult::RetryableError(_) ));