Merge #1282: electrum: ping server before returning client
537ebb2fb3301e82a297a5c8c4c5043d8d0938e4 func test: check electrs has started (Michael Mallan)
7612eda78874b879aefaaa790aab56429c33473c electrum: ping server before returning client (Michael Mallan)
Pull request description:
Ping server as an extra connectivity check.
ACKs for top commit:
darosior:
utACK 537ebb2fb3301e82a297a5c8c4c5043d8d0938e4
Tree-SHA512: 77186595acdabe878a4158847e878e0e004c58dd9476b9e5b4d99f4a79bb6fa552edb0b8b42f25a353bd6028505e66f6e7c6ffebfc7b1c252ad0b89db475bc23
This commit is contained in:
commit
61bc69012d
@ -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.
|
||||
|
||||
@ -2,7 +2,7 @@ import logging
|
||||
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 @@ class Electrs(BitcoinBackend):
|
||||
|
||||
def start(self):
|
||||
TailableProc.start(self)
|
||||
self.wait_for_log("auto-compactions enabled", timeout=TIMEOUT)
|
||||
logging.info("Electrs started")
|
||||
|
||||
def startup(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user