Skip to content
Merged
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/bitcoind_rpc/tests/test_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bdk_chain::{
};
use bdk_testenv::{
anyhow,
corepc_node::{Input, Output},
bitcoind::{Input, Output},
TestEnv,
};
use bitcoin::{hashes::Hash, Block, Network, ScriptBuf, WScriptHash};
Expand Down
4 changes: 2 additions & 2 deletions crates/bitcoind_rpc/tests/test_filter_iter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bdk_bitcoind_rpc::bip158::{Error, FilterIter};
use bdk_core::CheckPoint;
use bdk_testenv::{anyhow, corepc_node, TestEnv};
use bdk_testenv::{anyhow, bitcoind, TestEnv};
use bitcoin::{Address, Amount, Network, ScriptBuf};
use bitcoincore_rpc::RpcApi;

Expand All @@ -9,7 +9,7 @@ use crate::common::ClientExt;
mod common;

fn testenv() -> anyhow::Result<TestEnv> {
let mut conf = corepc_node::Conf::default();
let mut conf = bitcoind::Conf::default();
conf.args.push("-blockfilterindex=1");
conf.args.push("-peerblockfilters=1");
TestEnv::new_with_config(bdk_testenv::Config {
Expand Down
5 changes: 2 additions & 3 deletions crates/chain/tests/test_indexed_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ use bdk_chain::{
};
use bdk_testenv::{
anyhow::{self},
block_id,
corepc_node::{Input, Output},
hash,
bitcoind::{Input, Output},
block_id, hash,
utils::{new_tx, DESCRIPTORS},
TestEnv,
};
Expand Down
6 changes: 3 additions & 3 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bdk_core::bitcoin::{
use bdk_electrum::BdkElectrumClient;
use bdk_testenv::{
anyhow,
corepc_node::{Input, Output},
bitcoind::{Input, Output},
TestEnv,
};
use core::time::Duration;
Expand Down Expand Up @@ -141,7 +141,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
// Create and sign the `send_tx` that sends funds to the receiver address.
let send_tx_outputs = [Output::new(
receiver_addr,
selected_utxo.amount.to_unsigned()? - SEND_TX_FEE,
selected_utxo.amount - SEND_TX_FEE,
)];
let send_tx = rpc_client
.create_raw_transaction(&inputs, &send_tx_outputs)?
Expand All @@ -156,7 +156,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
// address.
let undo_send_outputs = [Output::new(
sender_addr,
selected_utxo.amount.to_unsigned()? - UNDO_SEND_TX_FEE,
selected_utxo.amount - UNDO_SEND_TX_FEE,
)];
let undo_send_tx = rpc_client
.create_raw_transaction(&inputs, &undo_send_outputs)?
Expand Down
6 changes: 3 additions & 3 deletions crates/esplora/tests/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_chain::spk_txout::SpkTxOutIndex;
use bdk_chain::{ConfirmationBlockTime, IndexedTxGraph, TxGraph};
use bdk_esplora::EsploraAsyncExt;
use bdk_testenv::corepc_node::{Input, Output};
use bdk_testenv::bitcoind::{Input, Output};
use bdk_testenv::{anyhow, TestEnv};
use esplora_client::{self, Builder};
use std::collections::{BTreeSet, HashSet};
Expand Down Expand Up @@ -62,7 +62,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {

// Create and sign the `send_tx` that sends funds to the receiver address.
let address = receiver_addr;
let value = selected_utxo.amount.to_unsigned()? - SEND_TX_FEE;
let value = selected_utxo.amount - SEND_TX_FEE;
let send_tx_outputs = Output::new(address, value);

let send_tx = rpc_client
Expand All @@ -78,7 +78,7 @@ pub async fn detect_receive_tx_cancel() -> anyhow::Result<()> {
// address.
let undo_send_outputs = [Output::new(
sender_addr,
selected_utxo.amount.to_unsigned()? - UNDO_SEND_TX_FEE,
selected_utxo.amount - UNDO_SEND_TX_FEE,
)];
let undo_send_tx = rpc_client
.create_raw_transaction(&inputs, &undo_send_outputs)?
Expand Down
6 changes: 3 additions & 3 deletions crates/esplora/tests/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_chain::spk_txout::SpkTxOutIndex;
use bdk_chain::{ConfirmationBlockTime, IndexedTxGraph, TxGraph};
use bdk_esplora::EsploraExt;
use bdk_testenv::corepc_node::{Input, Output};
use bdk_testenv::bitcoind::{Input, Output};
use bdk_testenv::{anyhow, TestEnv};
use esplora_client::{self, Builder};
use std::collections::{BTreeSet, HashSet};
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
// Create and sign the `send_tx` that sends funds to the receiver address.
let send_tx_outputs = [Output::new(
receiver_addr,
selected_utxo.amount.to_unsigned()? - SEND_TX_FEE,
selected_utxo.amount - SEND_TX_FEE,
)];

let send_tx = rpc_client
Expand All @@ -79,7 +79,7 @@ pub fn detect_receive_tx_cancel() -> anyhow::Result<()> {
// address.
let undo_send_outputs = [Output::new(
sender_addr,
selected_utxo.amount.to_unsigned()? - UNDO_SEND_TX_FEE,
selected_utxo.amount - UNDO_SEND_TX_FEE,
)];
let undo_send_tx = rpc_client
.create_raw_transaction(&inputs, &undo_send_outputs)?
Expand Down
4 changes: 2 additions & 2 deletions crates/testenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ workspace = true

[dependencies]
bdk_chain = { path = "../chain", version = "0.23.1", default-features = false }
electrsd = { version = "0.36.1", features = [ "legacy" ], default-features = false }
electrsd = { version = "0.38.0", features = [ "legacy" ], default-features = false }
bitcoin = { version = "0.32.0", default-features = false }

[dev-dependencies]
bdk_testenv = { path = "." }

[features]
default = ["std", "download"]
download = ["electrsd/corepc-node_28_2", "electrsd/esplora_a33e97e1"]
download = ["electrsd/bitcoind_download", "electrsd/bitcoind_28_2", "electrsd/esplora_a33e97e1"]
std = ["bdk_chain/std", "bitcoin/rand-std"]
serde = ["bdk_chain/serde"]

Expand Down
24 changes: 12 additions & 12 deletions crates/testenv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ use bdk_chain::CheckPoint;
use bitcoin::address::NetworkChecked;
use bitcoin::hex::HexToBytesError;
use core::time::Duration;
use electrsd::corepc_node::mtype::GetBlockTemplate;
use electrsd::corepc_node::{TemplateRequest, TemplateRules};
use electrsd::bitcoind::mtype::GetBlockTemplate;
use electrsd::bitcoind::{TemplateRequest, TemplateRules};

pub use electrsd;
pub use electrsd::bitcoind;
pub use electrsd::bitcoind::anyhow;
pub use electrsd::corepc_client;
pub use electrsd::corepc_node;
pub use electrsd::corepc_node::anyhow;
pub use electrsd::electrum_client;
use electrsd::electrum_client::ElectrumApi;

/// Struct for running a regtest environment with a single `bitcoind` node with an `electrs`
/// instance connected to it.
pub struct TestEnv {
pub bitcoind: electrsd::corepc_node::Node,
pub bitcoind: electrsd::bitcoind::BitcoinD,
pub electrsd: electrsd::ElectrsD,
}

/// Configuration parameters.
#[derive(Debug)]
pub struct Config<'a> {
/// [`corepc_node::Conf`]
pub bitcoind: corepc_node::Conf<'a>,
/// [`bitcoind::Conf`]
pub bitcoind: bitcoind::Conf<'a>,
/// [`electrsd::Conf`]
pub electrsd: electrsd::Conf<'a>,
}
Expand All @@ -42,7 +42,7 @@ impl Default for Config<'_> {
/// which is required for testing `bdk_esplora`.
fn default() -> Self {
Self {
bitcoind: corepc_node::Conf::default(),
bitcoind: bitcoind::Conf::default(),
electrsd: {
let mut conf = electrsd::Conf::default();
conf.http_enabled = true;
Expand Down Expand Up @@ -88,11 +88,11 @@ impl TestEnv {
pub fn new_with_config(config: Config) -> anyhow::Result<Self> {
let bitcoind_exe = match std::env::var("BITCOIND_EXE") {
Ok(path) => path,
Err(_) => corepc_node::downloaded_exe_path().context(
Err(_) => bitcoind::downloaded_exe_path().context(
"you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature",
)?,
};
let bitcoind = corepc_node::Node::with_conf(bitcoind_exe, &config.bitcoind)?;
let bitcoind = bitcoind::BitcoinD::with_conf(bitcoind_exe, &config.bitcoind)?;

let electrs_exe = match std::env::var("ELECTRS_EXE") {
Ok(path) => path,
Expand All @@ -110,7 +110,7 @@ impl TestEnv {
}

/// Exposes the RPC calls from [`corepc_client`].
pub fn rpc_client(&self) -> &corepc_node::Client {
pub fn rpc_client(&self) -> &bitcoind::Client {
&self.bitcoind.client
}

Expand Down Expand Up @@ -428,7 +428,7 @@ mod test {
use bdk_chain::bitcoin::opcodes::OP_TRUE;
use bdk_chain::bitcoin::Amount;
use core::time::Duration;
use electrsd::corepc_node::anyhow::Result;
use electrsd::bitcoind::anyhow::Result;
use std::collections::BTreeSet;

/// This checks that reorgs initiated by `bitcoind` is detected by our `electrsd` instance.
Expand Down
Loading