mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Drop monero-wallet-rpc
test container if errors
Previously we tried to wait longer upon errors on startup, but that did not fix the problem: ``` May 28 05:35:01.440 INFO monero_harness: Starting wallet: bob May 28 05:35:04.350 INFO testcontainers::core::wait_for_message: Found message after comparing 16 lines May 28 05:35:04.409 WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds... May 28 05:35:06.413 WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds... May 28 05:35:08.416 WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds... May 28 05:35:10.420 WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds... May 28 05:35:12.424 WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds... thread 'alice_manually_redeems_after_enc_sig_learned' panicked at 'called `Result::unwrap()` on an `Err` value: All retry attempts for creating a wallet exhausted ``` Thus we now drop the container upon error and try to spin up a new one. If the container is not up within 5 minutes we timeout.
This commit is contained in:
parent
61aaeb1579
commit
d7b4f8ea51
@ -31,7 +31,6 @@ 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;
|
||||
@ -78,8 +77,21 @@ impl<'c> Monero {
|
||||
containers.push(miner_container);
|
||||
for wallet in additional_wallets.iter() {
|
||||
tracing::info!("Starting wallet: {}", wallet);
|
||||
let (wallet, container) =
|
||||
MoneroWalletRpc::new(cli, &wallet, &monerod, prefix.clone()).await?;
|
||||
|
||||
// Create new wallet, the RPC sometimes has startup problems so we allow retries
|
||||
// (drop the container that failed and try again) Times out after
|
||||
// trying for 5 minutes
|
||||
let (wallet, container) = tokio::time::timeout(Duration::from_secs(300), async {
|
||||
loop {
|
||||
let result = MoneroWalletRpc::new(cli, &wallet, &monerod, prefix.clone()).await;
|
||||
|
||||
match result {
|
||||
Ok(tuple) => { return tuple; }
|
||||
Err(e) => { tracing::warn!("Monero wallet RPC emitted error {} - retrying to create wallet in 2 seconds...", e); }
|
||||
}
|
||||
}
|
||||
}).await.context("All retry attempts for creating a wallet exhausted")?;
|
||||
|
||||
wallets.push(wallet);
|
||||
containers.push(container);
|
||||
}
|
||||
@ -254,22 +266,9 @@ impl<'c> MoneroWalletRpc {
|
||||
|
||||
let client = wallet::Client::localhost(wallet_rpc_port)?;
|
||||
|
||||
// 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
|
||||
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")?;
|
||||
.await?;
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
|
Loading…
Reference in New Issue
Block a user