Skip to content

Commit

Permalink
Merge #1282: electrum: ping server before returning client
Browse files Browse the repository at this point in the history
537ebb2 func test: check electrs has started (Michael Mallan)
7612eda electrum: ping server before returning client (Michael Mallan)

Pull request description:

  Ping server as an extra connectivity check.

ACKs for top commit:
  darosior:
    utACK 537ebb2

Tree-SHA512: 77186595acdabe878a4158847e878e0e004c58dd9476b9e5b4d99f4a79bb6fa552edb0b8b42f25a353bd6028505e66f6e7c6ffebfc7b1c252ad0b89db475bc23
  • Loading branch information
darosior committed Sep 10, 2024
2 parents 533bf3e + 537ebb2 commit 61bc690
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bitcoin/electrum/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ impl Client {
pub fn new(electrum_config: &config::ElectrumConfig) -> Result<Self, Error> {
// 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.
Expand Down
3 changes: 2 additions & 1 deletion tests/test_framework/electrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 61bc690

Please sign in to comment.