From 125959976f63a1e12fc139f048dc2856e993efe5 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 26 Apr 2024 03:28:41 -0400 Subject: [PATCH 1/2] chore: remove `anyhow` dev dependency from `electrum`, `esplora`, and `bitcoind_rpc` --- crates/bitcoind_rpc/Cargo.toml | 1 - crates/bitcoind_rpc/tests/test_emitter.rs | 2 +- crates/electrum/Cargo.toml | 4 +--- crates/electrum/tests/test_electrum.rs | 4 +--- crates/esplora/Cargo.toml | 2 -- crates/esplora/src/async_ext.rs | 3 +-- crates/esplora/src/blocking_ext.rs | 3 +-- crates/esplora/tests/async_ext.rs | 4 +--- crates/esplora/tests/blocking_ext.rs | 4 +--- 9 files changed, 7 insertions(+), 20 deletions(-) diff --git a/crates/bitcoind_rpc/Cargo.toml b/crates/bitcoind_rpc/Cargo.toml index 98992328..1d67a0f3 100644 --- a/crates/bitcoind_rpc/Cargo.toml +++ b/crates/bitcoind_rpc/Cargo.toml @@ -20,7 +20,6 @@ bdk_chain = { path = "../chain", version = "0.13", default-features = false } [dev-dependencies] bdk_testenv = { path = "../testenv", default_features = false } -anyhow = { version = "1" } [features] default = ["std"] diff --git a/crates/bitcoind_rpc/tests/test_emitter.rs b/crates/bitcoind_rpc/tests/test_emitter.rs index c517740f..f8d2afa0 100644 --- a/crates/bitcoind_rpc/tests/test_emitter.rs +++ b/crates/bitcoind_rpc/tests/test_emitter.rs @@ -7,7 +7,7 @@ use bdk_chain::{ local_chain::{CheckPoint, LocalChain}, Append, BlockId, IndexedTxGraph, SpkTxOutIndex, }; -use bdk_testenv::TestEnv; +use bdk_testenv::{anyhow, TestEnv}; use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash}; use bitcoincore_rpc::RpcApi; diff --git a/crates/electrum/Cargo.toml b/crates/electrum/Cargo.toml index 4205f229..2f7896f7 100644 --- a/crates/electrum/Cargo.toml +++ b/crates/electrum/Cargo.toml @@ -17,6 +17,4 @@ electrum-client = { version = "0.19" } #rustls = { version = "=0.21.1", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] -bdk_testenv = { path = "../testenv", default-features = false } -electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } -anyhow = "1" +bdk_testenv = { path = "../testenv", default-features = false } \ No newline at end of file diff --git a/crates/electrum/tests/test_electrum.rs b/crates/electrum/tests/test_electrum.rs index 8f77209f..9566167d 100644 --- a/crates/electrum/tests/test_electrum.rs +++ b/crates/electrum/tests/test_electrum.rs @@ -1,4 +1,3 @@ -use anyhow::Result; use bdk_chain::{ bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash}, keychain::Balance, @@ -6,8 +5,7 @@ use bdk_chain::{ ConfirmationTimeHeightAnchor, IndexedTxGraph, SpkTxOutIndex, }; use bdk_electrum::{ElectrumExt, ElectrumUpdate}; -use bdk_testenv::TestEnv; -use electrsd::bitcoind::bitcoincore_rpc::RpcApi; +use bdk_testenv::{anyhow, anyhow::Result, bitcoincore_rpc::RpcApi, TestEnv}; fn get_balance( recv_chain: &LocalChain, diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index d91627d3..12fd60a7 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -23,9 +23,7 @@ miniscript = { version = "11.0.0", optional = true, default-features = false } [dev-dependencies] bdk_testenv = { path = "../testenv", default_features = false } -electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] } -anyhow = "1" [features] default = ["std", "async-https", "blocking-https-rustls"] diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 2942d274..5070d11c 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -417,8 +417,7 @@ mod test { local_chain::LocalChain, BlockId, }; - use bdk_testenv::TestEnv; - use electrsd::bitcoind::bitcoincore_rpc::RpcApi; + use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv}; use esplora_client::Builder; use crate::async_ext::{chain_update, fetch_latest_blocks}; diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 469ab52e..d8d0c22b 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -407,8 +407,7 @@ mod test { use bdk_chain::bitcoin::Txid; use bdk_chain::local_chain::LocalChain; use bdk_chain::BlockId; - use bdk_testenv::TestEnv; - use electrsd::bitcoind::bitcoincore_rpc::RpcApi; + use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv}; use esplora_client::{BlockHash, Builder}; use std::collections::{BTreeMap, BTreeSet}; use std::time::Duration; diff --git a/crates/esplora/tests/async_ext.rs b/crates/esplora/tests/async_ext.rs index 6f7956d4..c6f7d6ce 100644 --- a/crates/esplora/tests/async_ext.rs +++ b/crates/esplora/tests/async_ext.rs @@ -1,7 +1,5 @@ use bdk_chain::spk_client::{FullScanRequest, SyncRequest}; use bdk_esplora::EsploraAsyncExt; -use electrsd::bitcoind::anyhow; -use electrsd::bitcoind::bitcoincore_rpc::RpcApi; use esplora_client::{self, Builder}; use std::collections::{BTreeSet, HashSet}; use std::str::FromStr; @@ -9,7 +7,7 @@ use std::thread::sleep; use std::time::Duration; use bdk_chain::bitcoin::{Address, Amount, Txid}; -use bdk_testenv::TestEnv; +use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv}; #[tokio::test] pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { diff --git a/crates/esplora/tests/blocking_ext.rs b/crates/esplora/tests/blocking_ext.rs index 61c2466d..1d8d8d78 100644 --- a/crates/esplora/tests/blocking_ext.rs +++ b/crates/esplora/tests/blocking_ext.rs @@ -1,7 +1,5 @@ use bdk_chain::spk_client::{FullScanRequest, SyncRequest}; use bdk_esplora::EsploraExt; -use electrsd::bitcoind::anyhow; -use electrsd::bitcoind::bitcoincore_rpc::RpcApi; use esplora_client::{self, Builder}; use std::collections::{BTreeSet, HashSet}; use std::str::FromStr; @@ -9,7 +7,7 @@ use std::thread::sleep; use std::time::Duration; use bdk_chain::bitcoin::{Address, Amount, Txid}; -use bdk_testenv::TestEnv; +use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv}; #[test] pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { From f6218e4741a4b036d33a9f075ce5feb484e9bd87 Mon Sep 17 00:00:00 2001 From: Wei Chen Date: Fri, 3 May 2024 11:38:48 +0800 Subject: [PATCH 2/2] chore: reexport crates in `TestEnv` --- crates/testenv/Cargo.toml | 2 -- crates/testenv/src/lib.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/testenv/Cargo.toml b/crates/testenv/Cargo.toml index 99845c0b..33a09252 100644 --- a/crates/testenv/Cargo.toml +++ b/crates/testenv/Cargo.toml @@ -13,10 +13,8 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bitcoincore-rpc = { version = "0.18" } bdk_chain = { path = "../chain", version = "0.13", default-features = false } electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } -anyhow = { version = "1" } [features] default = ["std"] diff --git a/crates/testenv/src/lib.rs b/crates/testenv/src/lib.rs index 2edd06eb..b0c75b30 100644 --- a/crates/testenv/src/lib.rs +++ b/crates/testenv/src/lib.rs @@ -11,6 +11,11 @@ use bitcoincore_rpc::{ bitcoincore_rpc_json::{GetBlockTemplateModes, GetBlockTemplateRules}, RpcApi, }; +pub use electrsd; +pub use electrsd::bitcoind; +pub use electrsd::bitcoind::anyhow; +pub use electrsd::bitcoind::bitcoincore_rpc; +pub use electrsd::electrum_client; use electrsd::electrum_client::ElectrumApi; use std::time::Duration; @@ -261,8 +266,7 @@ impl TestEnv { #[cfg(test)] mod test { use crate::TestEnv; - use anyhow::Result; - use bitcoincore_rpc::RpcApi; + use electrsd::bitcoind::{anyhow::Result, bitcoincore_rpc::RpcApi}; /// This checks that reorgs initiated by `bitcoind` is detected by our `electrsd` instance. #[test]