Skip to content

Commit

Permalink
chore: better naming for caught devnet retryable error
Browse files Browse the repository at this point in the history
  • Loading branch information
jpraynaud committed Nov 28, 2024
1 parent ba92825 commit a528655
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mithril-test-lab/mithril-end-to-end/src/devnet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod runner;

pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode, UnrecoverableDevnetError};
pub use runner::{Devnet, DevnetBootstrapArgs, DevnetTopology, PoolNode, RetryableDevnetError};
12 changes: 6 additions & 6 deletions mithril-test-lab/mithril-end-to-end/src/devnet/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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")),
Expand All @@ -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")),
Expand All @@ -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")),
Expand Down
10 changes: 4 additions & 6 deletions mithril-test-lab/mithril-end-to-end/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -257,7 +257,7 @@ impl From<StdResult<()>> for AppResult {
match result {
Ok(()) => AppResult::Success(),
Err(error) => {
if error.is::<UnrecoverableDevnetError>() {
if error.is::<RetryableDevnetError>() {
AppResult::RetryableError(error)
} else {
AppResult::UnretryableError(error)
Expand Down Expand Up @@ -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(_)
));

Expand Down

0 comments on commit a528655

Please sign in to comment.