diff --git a/crates/bitcoind_rpc/Cargo.toml b/crates/bitcoind_rpc/Cargo.toml index bb18bb05ca..48e0bf55cc 100644 --- a/crates/bitcoind_rpc/Cargo.toml +++ b/crates/bitcoind_rpc/Cargo.toml @@ -20,7 +20,6 @@ bdk_chain = { path = "../chain", version = "0.12", 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 c517740f51..b70c128cc6 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::{electrsd::bitcoind::anyhow::Result, TestEnv}; use bitcoin::{hashes::Hash, Block, OutPoint, ScriptBuf, WScriptHash}; use bitcoincore_rpc::RpcApi; @@ -18,7 +18,7 @@ use bitcoincore_rpc::RpcApi; /// 3. Reorg highest 6 blocks. /// 4. Emit blocks from [`Emitter`] and re-update the [`LocalChain`]. #[test] -pub fn test_sync_local_chain() -> anyhow::Result<()> { +pub fn test_sync_local_chain() -> Result<()> { let env = TestEnv::new()?; let network_tip = env.rpc_client().get_block_count()?; let (mut local_chain, _) = LocalChain::from_genesis_hash(env.rpc_client().get_block_hash(0)?); @@ -127,7 +127,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> { /// /// [`EmittedUpdate::into_tx_graph_update`]: bdk_bitcoind_rpc::EmittedUpdate::into_tx_graph_update #[test] -fn test_into_tx_graph() -> anyhow::Result<()> { +fn test_into_tx_graph() -> Result<()> { let env = TestEnv::new()?; println!("getting new addresses!"); @@ -242,7 +242,7 @@ fn test_into_tx_graph() -> anyhow::Result<()> { /// TODO: If the reorg height is lower than the fallback height, how do we find a block height to /// emit that can connect with our receiver chain? #[test] -fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> anyhow::Result<()> { +fn ensure_block_emitted_after_reorg_is_at_reorg_height() -> Result<()> { const EMITTER_START_HEIGHT: usize = 100; const CHAIN_TIP_HEIGHT: usize = 110; @@ -281,7 +281,7 @@ fn process_block( recv_graph: &mut IndexedTxGraph>, block: Block, block_height: u32, -) -> anyhow::Result<()> { +) -> Result<()> { recv_chain.apply_update(CheckPoint::from_header(&block.header, block_height))?; let _ = recv_graph.apply_block(block, block_height); Ok(()) @@ -291,7 +291,7 @@ fn sync_from_emitter( recv_chain: &mut LocalChain, recv_graph: &mut IndexedTxGraph>, emitter: &mut Emitter, -) -> anyhow::Result<()> +) -> Result<()> where C: bitcoincore_rpc::RpcApi, { @@ -305,7 +305,7 @@ where fn get_balance( recv_chain: &LocalChain, recv_graph: &IndexedTxGraph>, -) -> anyhow::Result { +) -> Result { let chain_tip = recv_chain.tip().block_id(); let outpoints = recv_graph.index.outpoints().clone(); let balance = recv_graph @@ -317,7 +317,7 @@ fn get_balance( /// If a block is reorged out, ensure that containing transactions that do not exist in the /// replacement block(s) become unconfirmed. #[test] -fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { +fn tx_can_become_unconfirmed_after_reorg() -> Result<()> { const PREMINE_COUNT: usize = 101; const ADDITIONAL_COUNT: usize = 11; const SEND_AMOUNT: Amount = Amount::from_sat(10_000); @@ -409,7 +409,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { /// When we call Emitter::mempool multiple times, mempool txs should not be re-emitted, even if the /// chain tip is extended. #[test] -fn mempool_avoids_re_emission() -> anyhow::Result<()> { +fn mempool_avoids_re_emission() -> Result<()> { const BLOCKS_TO_MINE: usize = 101; const MEMPOOL_TX_COUNT: usize = 2; @@ -474,7 +474,7 @@ fn mempool_avoids_re_emission() -> anyhow::Result<()> { /// that `mempool` should always re-emit txs that have introduced at a height greater than the last /// emitted block height. #[test] -fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<()> { +fn mempool_re_emits_if_tx_introduction_height_not_reached() -> Result<()> { const PREMINE_COUNT: usize = 101; const MEMPOOL_TX_COUNT: usize = 21; @@ -498,12 +498,12 @@ fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<() // mine blocks to introduce txs to mempool at different heights let tx_introductions = (0..MEMPOOL_TX_COUNT) - .map(|_| -> anyhow::Result<_> { + .map(|_| -> Result<_> { let (height, _) = env.mine_empty_block()?; let txid = env.send(&addr, Amount::from_sat(2100))?; Ok((height, txid)) }) - .collect::>>()?; + .collect::>>()?; assert_eq!( emitter @@ -562,7 +562,7 @@ fn mempool_re_emits_if_tx_introduction_height_not_reached() -> anyhow::Result<() /// Ensure we force re-emit all mempool txs after reorg. #[test] -fn mempool_during_reorg() -> anyhow::Result<()> { +fn mempool_during_reorg() -> Result<()> { const TIP_DIFF: usize = 10; const PREMINE_COUNT: usize = 101; @@ -687,7 +687,7 @@ fn mempool_during_reorg() -> anyhow::Result<()> { /// The block hash of 99b should be different than 99a, but their previous block hashes should /// be the same. #[test] -fn no_agreement_point() -> anyhow::Result<()> { +fn no_agreement_point() -> Result<()> { const PREMINE_COUNT: usize = 101; let env = TestEnv::new()?; diff --git a/crates/electrum/Cargo.toml b/crates/electrum/Cargo.toml index ef5051d68d..443cadbe74 100644 --- a/crates/electrum/Cargo.toml +++ b/crates/electrum/Cargo.toml @@ -17,5 +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 } -anyhow = "1" \ No newline at end of file +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 da5a3d0cee..798a63f7b6 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,7 +5,10 @@ use bdk_chain::{ ConfirmationTimeHeightAnchor, IndexedTxGraph, SpkTxOutIndex, }; use bdk_electrum::{ElectrumExt, ElectrumUpdate}; -use bdk_testenv::{electrsd::bitcoind::bitcoincore_rpc::RpcApi, TestEnv}; +use bdk_testenv::{ + electrsd::bitcoind::{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 3cca71a892..8ecfe8634f 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -24,7 +24,6 @@ miniscript = { version = "11.0.0", optional = true, default-features = false } [dev-dependencies] bdk_testenv = { path = "../testenv", default_features = false } 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 5de9cfab63..5e78d65b6a 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -409,7 +409,10 @@ mod test { local_chain::LocalChain, BlockId, }; - use bdk_testenv::{electrsd::bitcoind::bitcoincore_rpc::RpcApi, TestEnv}; + use bdk_testenv::{ + electrsd::bitcoind::{anyhow::Result, bitcoincore_rpc::RpcApi}, + TestEnv, + }; use esplora_client::Builder; use crate::async_ext::{chain_update, fetch_latest_blocks}; @@ -422,7 +425,7 @@ mod test { /// Ensure that update does not remove heights (from original), and all anchor heights are included. #[tokio::test] - pub async fn test_finalize_chain_update() -> anyhow::Result<()> { + pub async fn test_finalize_chain_update() -> Result<()> { struct TestCase<'a> { name: &'a str, /// Initial blockchain height to start the env with. @@ -485,7 +488,7 @@ mod test { let anchors = t .initial_cps .iter() - .map(|&height| -> anyhow::Result<_> { + .map(|&height| -> Result<_> { Ok(( BlockId { height, @@ -494,7 +497,7 @@ mod test { Txid::all_zeros(), )) }) - .collect::>>()?; + .collect::>>()?; let update = chain_update( &client, &fetch_latest_blocks(&client).await?, @@ -523,7 +526,7 @@ mod test { let anchors = t .anchors .iter() - .map(|&(height, txid)| -> anyhow::Result<_> { + .map(|&(height, txid)| -> Result<_> { Ok(( BlockId { height, @@ -532,7 +535,7 @@ mod test { txid, )) }) - .collect::>()?; + .collect::>()?; chain_update( &client, &fetch_latest_blocks(&client).await?, diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 8312fd5e6a..01ef475769 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -414,7 +414,10 @@ mod test { use bdk_chain::bitcoin::Txid; use bdk_chain::local_chain::LocalChain; use bdk_chain::BlockId; - use bdk_testenv::{electrsd::bitcoind::bitcoincore_rpc::RpcApi, TestEnv}; + use bdk_testenv::{ + electrsd::bitcoind::{anyhow::Result, bitcoincore_rpc::RpcApi}, + TestEnv, + }; use esplora_client::{BlockHash, Builder}; use std::collections::{BTreeMap, BTreeSet}; use std::time::Duration; @@ -435,7 +438,7 @@ mod test { /// Ensure that update does not remove heights (from original), and all anchor heights are included. #[test] - pub fn test_finalize_chain_update() -> anyhow::Result<()> { + pub fn test_finalize_chain_update() -> Result<()> { struct TestCase<'a> { name: &'a str, /// Initial blockchain height to start the env with. @@ -498,7 +501,7 @@ mod test { let anchors = t .initial_cps .iter() - .map(|&height| -> anyhow::Result<_> { + .map(|&height| -> Result<_> { Ok(( BlockId { height, @@ -507,7 +510,7 @@ mod test { Txid::all_zeros(), )) }) - .collect::>>()?; + .collect::>>()?; let update = chain_update( &client, &fetch_latest_blocks(&client)?, @@ -535,7 +538,7 @@ mod test { let anchors = t .anchors .iter() - .map(|&(height, txid)| -> anyhow::Result<_> { + .map(|&(height, txid)| -> Result<_> { Ok(( BlockId { height, @@ -544,7 +547,7 @@ mod test { txid, )) }) - .collect::>()?; + .collect::>()?; chain_update( &client, &fetch_latest_blocks(&client)?, @@ -598,7 +601,7 @@ mod test { } #[test] - fn update_local_chain() -> anyhow::Result<()> { + fn update_local_chain() -> Result<()> { const TIP_HEIGHT: u32 = 50; let env = TestEnv::new()?;