Test refactor

- Fix esplora module level feature flag
- Move esplora blockchain tests to module, to cover for both variants
This commit is contained in:
rajarshimaitra 2021-08-31 14:28:10 +05:30
parent a41a0030dc
commit 8d1d92e71e
No known key found for this signature in database
GPG Key ID: 558ACE7DBB4377C8
2 changed files with 12 additions and 34 deletions

View File

@ -29,38 +29,16 @@ use bitcoin::{BlockHash, Txid};
use crate::error::Error;
use crate::FeeRate;
#[cfg(all(
feature = "esplora",
feature = "reqwest",
any(feature = "async-interface", target_arch = "wasm32"),
))]
#[cfg(feature = "reqwest")]
mod reqwest;
#[cfg(all(
feature = "esplora",
feature = "reqwest",
any(feature = "async-interface", target_arch = "wasm32"),
))]
#[cfg(feature = "reqwest")]
pub use self::reqwest::*;
#[cfg(all(
feature = "esplora",
not(any(
feature = "async-interface",
feature = "reqwest",
target_arch = "wasm32"
)),
))]
#[cfg(feature = "ureq")]
mod ureq;
#[cfg(all(
feature = "esplora",
not(any(
feature = "async-interface",
feature = "reqwest",
target_arch = "wasm32"
)),
))]
#[cfg(feature = "ureq")]
pub use self::ureq::*;
fn into_fee_rate(target: usize, estimates: HashMap<String, f64>) -> Result<FeeRate, Error> {
@ -141,3 +119,11 @@ impl_error!(io::Error, Io, EsploraError);
impl_error!(std::num::ParseIntError, Parsing, EsploraError);
impl_error!(consensus::encode::Error, BitcoinEncoding, EsploraError);
impl_error!(bitcoin::hashes::hex::Error, Hex, EsploraError);
#[cfg(test)]
#[cfg(feature = "test-esplora")]
crate::bdk_blockchain_tests! {
fn test_instance(test_client: &TestClient) -> EsploraBlockchain {
EsploraBlockchain::new(&format!("http://{}",test_client.electrsd.esplora_url.as_ref().unwrap()), 20)
}
}

View File

@ -350,11 +350,3 @@ impl ConfigurableBlockchain for EsploraBlockchain {
Ok(blockchain)
}
}
#[cfg(test)]
#[cfg(feature = "test-esplora")]
crate::bdk_blockchain_tests! {
fn test_instance(test_client: &TestClient) -> EsploraBlockchain {
EsploraBlockchain::new(&format!("http://{}",test_client.electrsd.esplora_url.as_ref().unwrap()), None, 20)
}
}