Skip to content

Commit

Permalink
adapted the tests for bdk-reserves 0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichard committed Apr 1, 2022
1 parent 7becf6f commit 081d040
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 37 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
- esplora-reqwest
- compiler
- compact_filters
# - reserves
# - reserves,electrum
# - reserves,esplora-ureq
# - reserves,compact_filters
# - reserves,rpc
- reserves
- reserves,electrum
- reserves,esplora-ureq
- reserves,compact_filters
- reserves,rpc
- rpc
- electrum,verify
steps:
Expand Down
26 changes: 4 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dirs-next = { version = "2.0", optional = true }
env_logger = { version = "0.7", optional = true }
clap = { version = "2.33", optional = true }
regex = { version = "1", optional = true }
bdk-reserves = { version = "0.16", optional = true}
bdk-reserves = { version = "0.17", optional = true}

[features]
default = ["cli", "repl"]
Expand Down
27 changes: 18 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ use bdk::bitcoin::secp256k1::Secp256k1;
use bdk::bitcoin::util::bip32::{DerivationPath, ExtendedPrivKey, KeySource};
use bdk::bitcoin::util::psbt::PartiallySignedTransaction;
use bdk::bitcoin::{Address, Network, OutPoint, Script, Txid};
#[cfg(feature = "reserves")]
use bdk::blockchain::Capability;
#[cfg(any(
feature = "electrum",
feature = "esplora",
feature = "compact_filters",
feature = "rpc"
))]
use bdk::blockchain::{log_progress, Blockchain};
#[cfg(feature = "reserves")]
use bdk::blockchain::{Capability, GetHeight};
use bdk::database::BatchDatabase;
use bdk::descriptor::Segwitv0;
#[cfg(feature = "compiler")]
Expand Down Expand Up @@ -1136,12 +1136,11 @@ where
} => {
let psbt = base64::decode(&psbt).unwrap();
let psbt: PartiallySignedTransaction = deserialize(&psbt).unwrap();
let current_height = wallet.client().get_height()?;
let current_height = blockchain.get_height()?;
let max_confirmation_height = if confirmations == 0 {
None
} else {
if !wallet
.client()
if !blockchain
.get_capabilities()
.contains(&Capability::GetAnyTx)
{
Expand Down Expand Up @@ -2275,20 +2274,30 @@ mod test {
#[cfg(all(feature = "reserves", feature = "electrum"))]
#[test]
fn test_proof_of_reserves_wallet() {
use bdk::blockchain::log_progress;
use bdk::SyncOptions;

let descriptor = "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)".to_string();
let message = "Those coins belong to Satoshi Nakamoto";

let client = Client::new("ssl://electrum.blockstream.info:60002").unwrap();
let blockchain = ElectrumBlockchain::from(client);
let wallet = Wallet::new(
&descriptor,
None,
Network::Testnet,
MemoryDatabase::default(),
ElectrumBlockchain::from(client),
)
.unwrap();

wallet.sync(noop_progress(), None).unwrap();
wallet
.sync(
&blockchain,
SyncOptions {
progress: Some(Box::new(log_progress())),
},
)
.unwrap();
let balance = wallet.get_balance().unwrap();

let addr = wallet.get_address(bdk::wallet::AddressIndex::New).unwrap();
Expand Down Expand Up @@ -2317,7 +2326,7 @@ mod test {
} => online_subcommand,
_ => panic!("unexpected subcommand"),
};
let result = handle_online_wallet_subcommand(&wallet, wallet_subcmd).unwrap();
let result = handle_online_wallet_subcommand(&wallet, &blockchain, wallet_subcmd).unwrap();
let psbt: PartiallySignedTransaction =
serde_json::from_str(&result.as_object().unwrap().get("psbt").unwrap().to_string())
.unwrap();
Expand Down Expand Up @@ -2355,7 +2364,7 @@ mod test {
} => online_subcommand,
_ => panic!("unexpected subcommand"),
};
let result = handle_online_wallet_subcommand(&wallet, wallet_subcmd).unwrap();
let result = handle_online_wallet_subcommand(&wallet, &blockchain, wallet_subcmd).unwrap();
let spendable = result
.as_object()
.unwrap()
Expand Down

0 comments on commit 081d040

Please sign in to comment.