Skip to content

Commit f0d68ec

Browse files
committed
adapted the tests for bdk-reserves 0.17
1 parent 7becf6f commit f0d68ec

4 files changed

Lines changed: 28 additions & 37 deletions

File tree

.github/workflows/cont_integration.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
- esplora-reqwest
2020
- compiler
2121
- compact_filters
22-
# - reserves
23-
# - reserves,electrum
24-
# - reserves,esplora-ureq
25-
# - reserves,compact_filters
26-
# - reserves,rpc
22+
- reserves
23+
- reserves,electrum
24+
- reserves,esplora-ureq
25+
- reserves,compact_filters
26+
- reserves,rpc
2727
- rpc
2828
- electrum,verify
2929
steps:

Cargo.lock

Lines changed: 4 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dirs-next = { version = "2.0", optional = true }
2727
env_logger = { version = "0.7", optional = true }
2828
clap = { version = "2.33", optional = true }
2929
regex = { version = "1", optional = true }
30-
bdk-reserves = { version = "0.16", optional = true}
30+
bdk-reserves = { version = "0.17", optional = true}
3131

3232
[features]
3333
default = ["cli", "repl"]

src/lib.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ use bdk::bitcoin::secp256k1::Secp256k1;
124124
use bdk::bitcoin::util::bip32::{DerivationPath, ExtendedPrivKey, KeySource};
125125
use bdk::bitcoin::util::psbt::PartiallySignedTransaction;
126126
use bdk::bitcoin::{Address, Network, OutPoint, Script, Txid};
127-
#[cfg(feature = "reserves")]
128-
use bdk::blockchain::Capability;
129127
#[cfg(any(
130128
feature = "electrum",
131129
feature = "esplora",
132130
feature = "compact_filters",
133131
feature = "rpc"
134132
))]
135133
use bdk::blockchain::{log_progress, Blockchain};
134+
#[cfg(feature = "reserves")]
135+
use bdk::blockchain::{Capability, GetHeight};
136136
use bdk::database::BatchDatabase;
137137
use bdk::descriptor::Segwitv0;
138138
#[cfg(feature = "compiler")]
@@ -1136,12 +1136,11 @@ where
11361136
} => {
11371137
let psbt = base64::decode(&psbt).unwrap();
11381138
let psbt: PartiallySignedTransaction = deserialize(&psbt).unwrap();
1139-
let current_height = wallet.client().get_height()?;
1139+
let current_height = blockchain.get_height()?;
11401140
let max_confirmation_height = if confirmations == 0 {
11411141
None
11421142
} else {
1143-
if !wallet
1144-
.client()
1143+
if !blockchain
11451144
.get_capabilities()
11461145
.contains(&Capability::GetAnyTx)
11471146
{
@@ -2275,20 +2274,30 @@ mod test {
22752274
#[cfg(all(feature = "reserves", feature = "electrum"))]
22762275
#[test]
22772276
fn test_proof_of_reserves_wallet() {
2277+
use bdk::SyncOptions;
2278+
use bdk::blockchain::log_progress;
2279+
22782280
let descriptor = "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)".to_string();
22792281
let message = "Those coins belong to Satoshi Nakamoto";
22802282

22812283
let client = Client::new("ssl://electrum.blockstream.info:60002").unwrap();
2284+
let blockchain = ElectrumBlockchain::from(client);
22822285
let wallet = Wallet::new(
22832286
&descriptor,
22842287
None,
22852288
Network::Testnet,
22862289
MemoryDatabase::default(),
2287-
ElectrumBlockchain::from(client),
22882290
)
22892291
.unwrap();
22902292

2291-
wallet.sync(noop_progress(), None).unwrap();
2293+
wallet
2294+
.sync(
2295+
&blockchain,
2296+
SyncOptions {
2297+
progress: Some(Box::new(log_progress())),
2298+
},
2299+
)
2300+
.unwrap();
22922301
let balance = wallet.get_balance().unwrap();
22932302

22942303
let addr = wallet.get_address(bdk::wallet::AddressIndex::New).unwrap();
@@ -2317,7 +2326,7 @@ mod test {
23172326
} => online_subcommand,
23182327
_ => panic!("unexpected subcommand"),
23192328
};
2320-
let result = handle_online_wallet_subcommand(&wallet, wallet_subcmd).unwrap();
2329+
let result = handle_online_wallet_subcommand(&wallet, &blockchain, wallet_subcmd).unwrap();
23212330
let psbt: PartiallySignedTransaction =
23222331
serde_json::from_str(&result.as_object().unwrap().get("psbt").unwrap().to_string())
23232332
.unwrap();
@@ -2355,7 +2364,7 @@ mod test {
23552364
} => online_subcommand,
23562365
_ => panic!("unexpected subcommand"),
23572366
};
2358-
let result = handle_online_wallet_subcommand(&wallet, wallet_subcmd).unwrap();
2367+
let result = handle_online_wallet_subcommand(&wallet, &blockchain, wallet_subcmd).unwrap();
23592368
let spendable = result
23602369
.as_object()
23612370
.unwrap()

0 commit comments

Comments
 (0)