Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rusqlite = { version = "0.31.0", features = ["bundled"], optional = true }
[dev-dependencies]
rand = "0.8"
proptest = "1.2.0"
bdk_testenv = { path = "../testenv" }
bdk_testenv = { path = "../testenv", features = ["miniscript"] }
criterion = { version = "0.7" }

[features]
Expand Down
4 changes: 1 addition & 3 deletions crates/chain/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(feature = "miniscript")]

mod tx_template;
#[allow(unused_imports)]
pub use tx_template::*;
pub use bdk_testenv::tx_template::*;
3 changes: 3 additions & 0 deletions crates/testenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ workspace = true
bdk_chain = { path = "../chain", version = "0.23.1", default-features = false }
electrsd = { version = "0.38.0", features = [ "legacy" ], default-features = false }
bitcoin = { version = "0.32.0", default-features = false }
miniscript = { version = "13.0.0", optional = true, default-features = false }
rand = { version = "0.8", optional = true }

[dev-dependencies]
bdk_testenv = { path = "." }
Expand All @@ -28,6 +30,7 @@ default = ["std", "download"]
download = ["electrsd/bitcoind_download", "electrsd/bitcoind_28_2", "electrsd/esplora_a33e97e1"]
std = ["bdk_chain/std", "bitcoin/rand-std"]
serde = ["bdk_chain/serde"]
miniscript = ["dep:miniscript", "bdk_chain/miniscript", "rand"]

[package.metadata.docs.rs]
no-default-features = true
3 changes: 3 additions & 0 deletions crates/testenv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

pub mod utils;

#[cfg(feature = "miniscript")]
pub mod tx_template;

use anyhow::Context;
use bdk_chain::bitcoin::{
block::Header, hash_types::TxMerkleNode, hex::FromHex, script::PushBytesBuf, transaction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![cfg(feature = "miniscript")]

use bdk_testenv::utils::DESCRIPTORS;
use crate::utils::DESCRIPTORS;
use rand::distributions::{Alphanumeric, DistString};
use std::collections::HashMap;

Expand All @@ -27,7 +25,6 @@ pub struct TxTemplate<'a, A> {
pub assume_canonical: bool,
}

#[allow(dead_code)]
pub enum TxInTemplate<'a> {
/// This will give a random txid and vout.
Bogus,
Expand All @@ -45,22 +42,20 @@ pub struct TxOutTemplate {
pub spk_index: Option<u32>, // some = get spk from SpkTxOutIndex, none = random spk
}

#[allow(unused)]
impl TxOutTemplate {
pub fn new(value: u64, spk_index: Option<u32>) -> Self {
TxOutTemplate { value, spk_index }
}
}

#[allow(dead_code)]
pub struct TxTemplateEnv<'a, A> {
pub tx_graph: TxGraph<A>,
pub indexer: SpkTxOutIndex<u32>,
pub txid_to_name: HashMap<&'a str, Txid>,
pub canonicalization_params: CanonicalParams,
}

#[allow(dead_code)]
/// Build a [`TxGraph`] and associated indexer from a series of [`TxTemplate`]s.
pub fn init_graph<'a, A: Anchor + Clone + 'a>(
tx_templates: impl IntoIterator<Item = &'a TxTemplate<'a, A>>,
) -> TxTemplateEnv<'a, A> {
Expand Down