Skip to content

Commit

Permalink
Blockchain stop_gap testing improvements
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
evanlinjin committed Jul 4, 2022
1 parent 1332660 commit c5c3c61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/blockchain/esplora/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,38 @@ mod test {
"should inherit from value for 25"
);
}

#[test]
#[cfg(feature = "test-esplora")]
fn test_esplora_with_variable_configs() {
use crate::testutils::{
blockchain_tests::TestClient,
configurable_blockchain_tests::ConfigurableBlockchainTester,
};

struct EsploraTester;

impl ConfigurableBlockchainTester<EsploraBlockchain> for EsploraTester {
const BLOCKCHAIN_NAME: &'static str = "Esplora";

fn config_with_stop_gap(
&self,
test_client: &mut TestClient,
stop_gap: usize,
) -> Option<EsploraBlockchainConfig> {
Some(EsploraBlockchainConfig {
base_url: format!(
"http://{}",
test_client.electrsd.esplora_url.as_ref().unwrap()
),
proxy: None,
concurrency: None,
stop_gap: stop_gap,
timeout: None,
})
}
}

EsploraTester.run();
}
}
2 changes: 1 addition & 1 deletion src/blockchain/esplora/ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Blockchain for EsploraBlockchain {
}

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

Expand Down

0 comments on commit c5c3c61

Please sign in to comment.