mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
To avoid CI failure wait for the balance instead of sleep
This commit is contained in:
parent
c4df3fdcbc
commit
bdb35c310d
@ -30,7 +30,7 @@ use swap::{
|
||||
};
|
||||
use tempfile::tempdir;
|
||||
use testcontainers::{clients::Cli, Container, Docker, RunArgs};
|
||||
use tokio::{sync::mpsc, task::JoinHandle, time::sleep};
|
||||
use tokio::{sync::mpsc, task::JoinHandle, time::interval};
|
||||
use tracing_core::dispatcher::DefaultGuard;
|
||||
use tracing_log::LogTracer;
|
||||
use url::Url;
|
||||
@ -625,15 +625,31 @@ async fn init_test_wallets(
|
||||
)
|
||||
.await
|
||||
.expect("could not mint btc starting balance");
|
||||
|
||||
let mut interval = interval(Duration::from_secs(1u64));
|
||||
let mut retries = 0u8;
|
||||
let max_retries = 30u8;
|
||||
loop {
|
||||
retries += 1;
|
||||
btc_wallet
|
||||
.sync_wallet()
|
||||
.await
|
||||
.expect("Could not sync btc wallet");
|
||||
|
||||
let btc_balance = btc_wallet.balance().await.unwrap();
|
||||
|
||||
if btc_balance == starting_balances.btc {
|
||||
break;
|
||||
} else if retries == max_retries {
|
||||
panic!(
|
||||
"Bitcoin wallet initialization failed, reached max retries upon balance sync"
|
||||
)
|
||||
}
|
||||
|
||||
interval.tick().await;
|
||||
}
|
||||
}
|
||||
|
||||
sleep(Duration::from_secs(5)).await;
|
||||
|
||||
btc_wallet
|
||||
.sync_wallet()
|
||||
.await
|
||||
.expect("Could not sync btc wallet");
|
||||
|
||||
(Arc::new(btc_wallet), Arc::new(xmr_wallet))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user