Skip to content

Commit c5c3c61

Browse files
committed
Blockchain stop_gap testing improvements
This is a continuation of the #651 fix. We should also check whether the same bug affects esplora as noted by @afilini. To achieve this, I've introduced a `ConfigurableBlockchainTester` trait that can test multiple blockchain implementations. * Introduce `ConfigurableBlockchainTester` trait. * Use the aforementioned trait to also test esplora. * Change the electrum test to also use the new trait. * Fix some complaints by clippy in ureq.rs file (why is CI not seeing this?). * Refactor some code.
1 parent 1332660 commit c5c3c61

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/blockchain/esplora/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,38 @@ mod test {
209209
"should inherit from value for 25"
210210
);
211211
}
212+
213+
#[test]
214+
#[cfg(feature = "test-esplora")]
215+
fn test_esplora_with_variable_configs() {
216+
use crate::testutils::{
217+
blockchain_tests::TestClient,
218+
configurable_blockchain_tests::ConfigurableBlockchainTester,
219+
};
220+
221+
struct EsploraTester;
222+
223+
impl ConfigurableBlockchainTester<EsploraBlockchain> for EsploraTester {
224+
const BLOCKCHAIN_NAME: &'static str = "Esplora";
225+
226+
fn config_with_stop_gap(
227+
&self,
228+
test_client: &mut TestClient,
229+
stop_gap: usize,
230+
) -> Option<EsploraBlockchainConfig> {
231+
Some(EsploraBlockchainConfig {
232+
base_url: format!(
233+
"http://{}",
234+
test_client.electrsd.esplora_url.as_ref().unwrap()
235+
),
236+
proxy: None,
237+
concurrency: None,
238+
stop_gap: stop_gap,
239+
timeout: None,
240+
})
241+
}
242+
}
243+
244+
EsploraTester.run();
245+
}
212246
}

src/blockchain/esplora/ureq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Blockchain for EsploraBlockchain {
8888
}
8989

9090
fn broadcast(&self, tx: &Transaction) -> Result<(), Error> {
91-
let _txid = self.url_client._broadcast(tx)?;
91+
self.url_client._broadcast(tx)?;
9292
Ok(())
9393
}
9494

0 commit comments

Comments
 (0)