Skip to content

Commit

Permalink
fix(testenv): disable downloads (bitcoind and electrsd) for docs.rs b…
Browse files Browse the repository at this point in the history
…uilds in crate testenv
  • Loading branch information
riverKanies committed Nov 9, 2024
1 parent dc0511f commit a99e58e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/bitcoind_rpc/tests/test_emitter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(docsrs))]

use std::collections::{BTreeMap, BTreeSet};

use bdk_bitcoind_rpc::Emitter;
Expand Down
2 changes: 2 additions & 0 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(docsrs))]

use bdk_chain::{
bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash},
local_chain::LocalChain,
Expand Down
1 change: 1 addition & 0 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ mod test {
}

/// Ensure that update does not remove heights (from original), and all anchor heights are included.
#[cfg(not(docsrs))]
#[tokio::test]
pub async fn test_finalize_chain_update() -> anyhow::Result<()> {
struct TestCase<'a> {
Expand Down
2 changes: 2 additions & 0 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ mod test {
}

/// Ensure that update does not remove heights (from original), and all anchor heights are included.
#[cfg(not(docsrs))]
#[test]
pub fn test_finalize_chain_update() -> anyhow::Result<()> {
struct TestCase<'a> {
Expand Down Expand Up @@ -655,6 +656,7 @@ mod test {
Ok(())
}

#[cfg(not(docsrs))]
#[test]
fn update_local_chain() -> anyhow::Result<()> {
const TIP_HEIGHT: u32 = 50;
Expand Down
2 changes: 2 additions & 0 deletions crates/esplora/tests/async_ext.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(docsrs))]

use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_chain::{ConfirmationBlockTime, TxGraph};
use bdk_esplora::EsploraAsyncExt;
Expand Down
2 changes: 2 additions & 0 deletions crates/esplora/tests/blocking_ext.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(docsrs))]

use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_chain::{ConfirmationBlockTime, TxGraph};
use bdk_esplora::EsploraExt;
Expand Down
8 changes: 7 additions & 1 deletion crates/testenv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod utils;

use bdk_chain::{
Expand Down Expand Up @@ -25,12 +27,14 @@ use std::time::Duration;

/// Struct for running a regtest environment with a single `bitcoind` node with an `electrs`
/// instance connected to it.
#[cfg_attr(docsrs, doc(cfg(not(docsrs))))]
pub struct TestEnv {
pub bitcoind: electrsd::bitcoind::BitcoinD,
pub electrsd: electrsd::ElectrsD,
}

/// Configuration parameters.
#[cfg_attr(docsrs, doc(cfg(not(docsrs))))]
#[derive(Debug)]
pub struct Config<'a> {
/// [`bitcoind::Conf`]
Expand All @@ -39,6 +43,7 @@ pub struct Config<'a> {
pub electrsd: electrsd::Conf<'a>,
}

#[cfg(not(docsrs))]
impl<'a> Default for Config<'a> {
/// Use the default configuration plus set `http_enabled = true` for [`electrsd::Conf`]
/// which is required for testing `bdk_esplora`.
Expand All @@ -54,6 +59,7 @@ impl<'a> Default for Config<'a> {
}
}

#[cfg(not(docsrs))]
impl TestEnv {
/// Construct a new [`TestEnv`] instance with the default configuration used by BDK.
pub fn new() -> anyhow::Result<Self> {
Expand Down Expand Up @@ -310,7 +316,7 @@ impl TestEnv {
}
}

#[cfg(test)]
#[cfg(all(test, not(docsrs)))]
mod test {
use crate::TestEnv;
use core::time::Duration;
Expand Down

0 comments on commit a99e58e

Please sign in to comment.