diff --git a/src/bitcoin/electrum/client.rs b/src/bitcoin/electrum/client.rs index 1fd5a3d0e..eec542f1f 100644 --- a/src/bitcoin/electrum/client.rs +++ b/src/bitcoin/electrum/client.rs @@ -57,7 +57,9 @@ impl Client { pub fn new(electrum_config: &config::ElectrumConfig) -> Result { // First use a dummy config to check connectivity (no retries, short timeout). let dummy_config = Config::builder().retry(0).timeout(Some(3)).build(); + // Try to ping the server. bdk_electrum::electrum_client::Client::from_config(&electrum_config.addr, dummy_config) + .and_then(|dummy_client| dummy_client.ping()) .map_err(Error::Server)?; // Now connection has been checked, create client with required retries and timeout. diff --git a/tests/test_framework/electrs.py b/tests/test_framework/electrs.py index ee8c6a518..2c32b88f6 100644 --- a/tests/test_framework/electrs.py +++ b/tests/test_framework/electrs.py @@ -2,7 +2,7 @@ import os from ephemeral_port_reserve import reserve -from test_framework.utils import BitcoinBackend, TailableProc, ELECTRS_PATH +from test_framework.utils import BitcoinBackend, TailableProc, ELECTRS_PATH, TIMEOUT class Electrs(BitcoinBackend): @@ -54,6 +54,7 @@ def __init__( def start(self): TailableProc.start(self) + self.wait_for_log("auto-compactions enabled", timeout=TIMEOUT) logging.info("Electrs started") def startup(self):