Skip to content

Commit

Permalink
chore: remove anyhow dev dependency from electrum and esplora
Browse files Browse the repository at this point in the history
  • Loading branch information
LagginTimes committed Apr 26, 2024
1 parent ec34ad1 commit c8e9913
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
3 changes: 1 addition & 2 deletions crates/electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
bdk_testenv = { path = "../testenv", default-features = false }
6 changes: 4 additions & 2 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use anyhow::Result;
use bdk_chain::{
bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash},
keychain::Balance,
local_chain::LocalChain,
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,
Expand Down
1 change: 0 additions & 1 deletion crates/esplora/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
15 changes: 9 additions & 6 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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.
Expand Down Expand Up @@ -485,7 +488,7 @@ mod test {
let anchors = t
.initial_cps
.iter()
.map(|&height| -> anyhow::Result<_> {
.map(|&height| -> Result<_> {
Ok((
BlockId {
height,
Expand All @@ -494,7 +497,7 @@ mod test {
Txid::all_zeros(),
))
})
.collect::<anyhow::Result<BTreeSet<_>>>()?;
.collect::<Result<BTreeSet<_>>>()?;
let update = chain_update(
&client,
&fetch_latest_blocks(&client).await?,
Expand Down Expand Up @@ -523,7 +526,7 @@ mod test {
let anchors = t
.anchors
.iter()
.map(|&(height, txid)| -> anyhow::Result<_> {
.map(|&(height, txid)| -> Result<_> {
Ok((
BlockId {
height,
Expand All @@ -532,7 +535,7 @@ mod test {
txid,
))
})
.collect::<anyhow::Result<_>>()?;
.collect::<Result<_>>()?;
chain_update(
&client,
&fetch_latest_blocks(&client).await?,
Expand Down
17 changes: 10 additions & 7 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -498,7 +501,7 @@ mod test {
let anchors = t
.initial_cps
.iter()
.map(|&height| -> anyhow::Result<_> {
.map(|&height| -> Result<_> {
Ok((
BlockId {
height,
Expand All @@ -507,7 +510,7 @@ mod test {
Txid::all_zeros(),
))
})
.collect::<anyhow::Result<BTreeSet<_>>>()?;
.collect::<Result<BTreeSet<_>>>()?;
let update = chain_update(
&client,
&fetch_latest_blocks(&client)?,
Expand Down Expand Up @@ -535,7 +538,7 @@ mod test {
let anchors = t
.anchors
.iter()
.map(|&(height, txid)| -> anyhow::Result<_> {
.map(|&(height, txid)| -> Result<_> {
Ok((
BlockId {
height,
Expand All @@ -544,7 +547,7 @@ mod test {
txid,
))
})
.collect::<anyhow::Result<_>>()?;
.collect::<Result<_>>()?;
chain_update(
&client,
&fetch_latest_blocks(&client)?,
Expand Down Expand Up @@ -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()?;
Expand Down

0 comments on commit c8e9913

Please sign in to comment.