Skip to content

Commit a99e58e

Browse files
committed
fix(testenv): disable downloads (bitcoind and electrsd) for docs.rs builds in crate testenv
1 parent dc0511f commit a99e58e

File tree

7 files changed

+18
-1
lines changed

7 files changed

+18
-1
lines changed

crates/bitcoind_rpc/tests/test_emitter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(docsrs))]
2+
13
use std::collections::{BTreeMap, BTreeSet};
24

35
use bdk_bitcoind_rpc::Emitter;

crates/electrum/tests/test_electrum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(docsrs))]
2+
13
use bdk_chain::{
24
bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash},
35
local_chain::LocalChain,

crates/esplora/src/async_ext.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ mod test {
503503
}
504504

505505
/// Ensure that update does not remove heights (from original), and all anchor heights are included.
506+
#[cfg(not(docsrs))]
506507
#[tokio::test]
507508
pub async fn test_finalize_chain_update() -> anyhow::Result<()> {
508509
struct TestCase<'a> {

crates/esplora/src/blocking_ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ mod test {
492492
}
493493

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

659+
#[cfg(not(docsrs))]
658660
#[test]
659661
fn update_local_chain() -> anyhow::Result<()> {
660662
const TIP_HEIGHT: u32 = 50;

crates/esplora/tests/async_ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(docsrs))]
2+
13
use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
24
use bdk_chain::{ConfirmationBlockTime, TxGraph};
35
use bdk_esplora::EsploraAsyncExt;

crates/esplora/tests/blocking_ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(not(docsrs))]
2+
13
use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
24
use bdk_chain::{ConfirmationBlockTime, TxGraph};
35
use bdk_esplora::EsploraExt;

crates/testenv/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, feature(doc_cfg))]
2+
13
pub mod utils;
24

35
use bdk_chain::{
@@ -25,12 +27,14 @@ use std::time::Duration;
2527

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

3336
/// Configuration parameters.
37+
#[cfg_attr(docsrs, doc(cfg(not(docsrs))))]
3438
#[derive(Debug)]
3539
pub struct Config<'a> {
3640
/// [`bitcoind::Conf`]
@@ -39,6 +43,7 @@ pub struct Config<'a> {
3943
pub electrsd: electrsd::Conf<'a>,
4044
}
4145

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

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

313-
#[cfg(test)]
319+
#[cfg(all(test, not(docsrs)))]
314320
mod test {
315321
use crate::TestEnv;
316322
use core::time::Duration;

0 commit comments

Comments
 (0)