diff --git a/monero-harness/src/lib.rs b/monero-harness/src/lib.rs index 0e3b2127..27521b7f 100644 --- a/monero-harness/src/lib.rs +++ b/monero-harness/src/lib.rs @@ -31,6 +31,7 @@ use std::time::Duration; use testcontainers::clients::Cli; use testcontainers::{Container, Docker, RunArgs}; use tokio::time; +use tokio::time::sleep; /// How often we mine a block. const BLOCK_TIME_SECS: u64 = 1; @@ -251,12 +252,24 @@ impl<'c> MoneroWalletRpc { .get_host_port(RPC_PORT) .context("port not exposed")?; - // create new wallet let client = wallet::Client::localhost(wallet_rpc_port)?; - client - .create_wallet(name.to_owned(), "English".to_owned()) - .await?; + // Create new wallet, the RPC sometimes has startup problems so we allow some + // retries + tokio::time::timeout(Duration::from_secs(10), async { + loop { + let result = client + .create_wallet(name.to_owned(), "English".to_owned()) + .await; + + match result { + Ok(_) => { break; } + Err(e) => { tracing::warn!("Monero wallet RPC emitted error {} - retrying to create wallet in 2 seconds...", e); } + } + + sleep(Duration::from_secs(2)).await; + } + }).await.context("All retry attempts for creating a wallet exhausted")?; Ok(( Self {