Merge bitcoindevkit/bdk#1414: chore: clean up electrsd and anyhow dev dependencies

f6218e4741a4b036d33a9f075ce5feb484e9bd87 chore: reexport crates in `TestEnv` (Wei Chen)
125959976f63a1e12fc139f048dc2856e993efe5 chore: remove `anyhow` dev dependency from `electrum`, `esplora`, and `bitcoind_rpc` (Wei Chen)

Pull request description:

  <!-- You can erase any parts of this template not applicable to your Pull Request. -->

  ### Description

  Reexports `electrsd` in `TestEnv` to remove the `electrsd` dev depedency out of `bdk_electrum` and `bdk_esplora`.
  Credit to @ValuedMammal for the idea.

  Since `bitcoind` reexports `anyhow`, this dev dependency was also removed from `bdk_electrum`, `bdk_esplora`, and `bdk_bitcoind_rpc`. `bitcoind`, `bitcoincore_rpc` and `electrum_client` were also reexported for convenience.

  ### Changelog notice

  * Change `bdk_testenv` to re-export internally used crates.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  evanlinjin:
    ACK f6218e4741a4b036d33a9f075ce5feb484e9bd87

Tree-SHA512: c7645eb91d08d4ccb80982a992f691b5a8c0df39df506f6b361bc6f2bb076d62cbe5bb5d88b4c684c36e22464c0674f21f6ef4e23733f89b03aa12ec43a67cba
This commit is contained in:
志宇 2024-05-06 20:12:07 +08:00
commit 23538c4039
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8
11 changed files with 13 additions and 24 deletions

View File

@ -20,7 +20,6 @@ bdk_chain = { path = "../chain", version = "0.13", default-features = false }
[dev-dependencies] [dev-dependencies]
bdk_testenv = { path = "../testenv", default_features = false } bdk_testenv = { path = "../testenv", default_features = false }
anyhow = { version = "1" }
[features] [features]
default = ["std"] default = ["std"]

View File

@ -7,7 +7,7 @@ use bdk_chain::{
local_chain::{CheckPoint, LocalChain}, local_chain::{CheckPoint, LocalChain},
Append, BlockId, IndexedTxGraph, SpkTxOutIndex, Append, BlockId, IndexedTxGraph, SpkTxOutIndex,
}; };
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, TestEnv};
use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash}; use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash};
use bitcoincore_rpc::RpcApi; use bitcoincore_rpc::RpcApi;

View File

@ -17,6 +17,4 @@ electrum-client = { version = "0.19" }
#rustls = { version = "=0.21.1", optional = true, features = ["dangerous_configuration"] } #rustls = { version = "=0.21.1", optional = true, features = ["dangerous_configuration"] }
[dev-dependencies] [dev-dependencies]
bdk_testenv = { path = "../testenv", default-features = false } bdk_testenv = { path = "../testenv", default-features = false }
electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] }
anyhow = "1"

View File

@ -1,4 +1,3 @@
use anyhow::Result;
use bdk_chain::{ use bdk_chain::{
bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash}, bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash},
keychain::Balance, keychain::Balance,
@ -6,8 +5,7 @@ use bdk_chain::{
ConfirmationTimeHeightAnchor, IndexedTxGraph, SpkTxOutIndex, ConfirmationTimeHeightAnchor, IndexedTxGraph, SpkTxOutIndex,
}; };
use bdk_electrum::{ElectrumExt, ElectrumUpdate}; use bdk_electrum::{ElectrumExt, ElectrumUpdate};
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, anyhow::Result, bitcoincore_rpc::RpcApi, TestEnv};
use electrsd::bitcoind::bitcoincore_rpc::RpcApi;
fn get_balance( fn get_balance(
recv_chain: &LocalChain, recv_chain: &LocalChain,

View File

@ -23,9 +23,7 @@ miniscript = { version = "11.0.0", optional = true, default-features = false }
[dev-dependencies] [dev-dependencies]
bdk_testenv = { path = "../testenv", default_features = false } 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"] } tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
anyhow = "1"
[features] [features]
default = ["std", "async-https", "blocking-https-rustls"] default = ["std", "async-https", "blocking-https-rustls"]

View File

@ -411,8 +411,7 @@ mod test {
local_chain::LocalChain, local_chain::LocalChain,
BlockId, BlockId,
}; };
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
use electrsd::bitcoind::bitcoincore_rpc::RpcApi;
use esplora_client::Builder; use esplora_client::Builder;
use crate::async_ext::{chain_update, fetch_latest_blocks}; use crate::async_ext::{chain_update, fetch_latest_blocks};

View File

@ -401,8 +401,7 @@ mod test {
use bdk_chain::bitcoin::Txid; use bdk_chain::bitcoin::Txid;
use bdk_chain::local_chain::LocalChain; use bdk_chain::local_chain::LocalChain;
use bdk_chain::BlockId; use bdk_chain::BlockId;
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
use electrsd::bitcoind::bitcoincore_rpc::RpcApi;
use esplora_client::{BlockHash, Builder}; use esplora_client::{BlockHash, Builder};
use std::collections::{BTreeMap, BTreeSet}; use std::collections::{BTreeMap, BTreeSet};
use std::time::Duration; use std::time::Duration;

View File

@ -1,7 +1,5 @@
use bdk_chain::spk_client::{FullScanRequest, SyncRequest}; use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_esplora::EsploraAsyncExt; use bdk_esplora::EsploraAsyncExt;
use electrsd::bitcoind::anyhow;
use electrsd::bitcoind::bitcoincore_rpc::RpcApi;
use esplora_client::{self, Builder}; use esplora_client::{self, Builder};
use std::collections::{BTreeSet, HashSet}; use std::collections::{BTreeSet, HashSet};
use std::str::FromStr; use std::str::FromStr;
@ -9,7 +7,7 @@ use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use bdk_chain::bitcoin::{Address, Amount, Txid}; use bdk_chain::bitcoin::{Address, Amount, Txid};
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
#[tokio::test] #[tokio::test]
pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {

View File

@ -1,7 +1,5 @@
use bdk_chain::spk_client::{FullScanRequest, SyncRequest}; use bdk_chain::spk_client::{FullScanRequest, SyncRequest};
use bdk_esplora::EsploraExt; use bdk_esplora::EsploraExt;
use electrsd::bitcoind::anyhow;
use electrsd::bitcoind::bitcoincore_rpc::RpcApi;
use esplora_client::{self, Builder}; use esplora_client::{self, Builder};
use std::collections::{BTreeSet, HashSet}; use std::collections::{BTreeSet, HashSet};
use std::str::FromStr; use std::str::FromStr;
@ -9,7 +7,7 @@ use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use bdk_chain::bitcoin::{Address, Amount, Txid}; use bdk_chain::bitcoin::{Address, Amount, Txid};
use bdk_testenv::TestEnv; use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
#[test] #[test]
pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { pub fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> {

View File

@ -13,10 +13,8 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bitcoincore-rpc = { version = "0.18" }
bdk_chain = { path = "../chain", version = "0.13", default-features = false } bdk_chain = { path = "../chain", version = "0.13", default-features = false }
electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } electrsd = { version= "0.27.1", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] }
anyhow = { version = "1" }
[features] [features]
default = ["std"] default = ["std"]

View File

@ -11,6 +11,11 @@ use bitcoincore_rpc::{
bitcoincore_rpc_json::{GetBlockTemplateModes, GetBlockTemplateRules}, bitcoincore_rpc_json::{GetBlockTemplateModes, GetBlockTemplateRules},
RpcApi, 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 electrsd::electrum_client::ElectrumApi;
use std::time::Duration; use std::time::Duration;
@ -261,8 +266,7 @@ impl TestEnv {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::TestEnv; use crate::TestEnv;
use anyhow::Result; use electrsd::bitcoind::{anyhow::Result, bitcoincore_rpc::RpcApi};
use bitcoincore_rpc::RpcApi;
/// This checks that reorgs initiated by `bitcoind` is detected by our `electrsd` instance. /// This checks that reorgs initiated by `bitcoind` is detected by our `electrsd` instance.
#[test] #[test]