From 7612eda78874b879aefaaa790aab56429c33473c Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 6 Sep 2024 11:46:19 +0100 Subject: [PATCH 1/2] electrum: ping server before returning client --- src/bitcoin/electrum/client.rs | 2 ++ 1 file changed, 2 insertions(+) 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. From 537ebb2fb3301e82a297a5c8c4c5043d8d0938e4 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 6 Sep 2024 16:50:45 +0100 Subject: [PATCH 2/2] func test: check electrs has started --- tests/test_framework/electrs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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):