Skip to content

Commit

Permalink
testing: bitcoind wait for startup
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Feb 27, 2024
1 parent c8d6fac commit f4453ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions testing/src/btc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use port::Port;
use port_selector as port;
use tempfile::TempDir;

use crate::wait_for;

pub mod macros {
#[macro_export]
macro_rules! bitcoind {
Expand Down Expand Up @@ -84,6 +86,19 @@ impl BtcNode {
&format!("http://localhost:{port}"),
Auth::UserPass(user.clone(), pass.clone()),
)?;

wait_for!(async {
let Ok(info) = rpc.get_blockchain_info() else {
return Err(());
};

if info.initial_block_download {
return Err(());
}

Ok(())
});

let bg_process = vec![process];
Ok(Self {
inner: rpc,
Expand Down

0 comments on commit f4453ab

Please sign in to comment.