Skip to content

Commit 529d05a

Browse files
sanket1729danielabrozzoni
authored andcommitted
Fix test_cpp
1 parent a46e121 commit 529d05a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

bitcoind-tests/tests/test_cpp.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@ use std::path::Path;
1111

1212
use bitcoin::hashes::{sha256d, Hash};
1313
use bitcoin::psbt::Psbt;
14-
use bitcoin::secp256k1::{self, Secp256k1};
15-
use bitcoin::{psbt, Amount, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid};
14+
use bitcoin::{psbt, secp256k1, Amount, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid};
1615
use bitcoind::bitcoincore_rpc::{json, Client, RpcApi};
1716
use miniscript::bitcoin::absolute;
1817
use miniscript::psbt::PsbtExt;
19-
use miniscript::{bitcoin, Descriptor};
18+
use miniscript::{bitcoin, DefiniteDescriptorKey, Descriptor};
2019

2120
mod setup;
2221
use setup::test_util::{self, PubData, TestData};
2322

2423
// parse ~30 miniscripts from file
25-
pub(crate) fn parse_miniscripts(
26-
secp: &Secp256k1<secp256k1::All>,
27-
pubdata: &PubData,
28-
) -> Vec<Descriptor<bitcoin::PublicKey>> {
24+
pub(crate) fn parse_miniscripts(pubdata: &PubData) -> Vec<Descriptor<DefiniteDescriptorKey>> {
2925
// File must exist in current path before this produces output
3026
let mut desc_vec = vec![];
3127
// Consumes the iterator, returns an (Optional) String
3228
for line in read_lines("tests/data/random_ms.txt") {
3329
let ms = test_util::parse_insane_ms(&line.unwrap(), pubdata);
3430
let wsh = Descriptor::new_wsh(ms).unwrap();
35-
desc_vec.push(wsh.derived_descriptor(secp, 0).unwrap());
31+
desc_vec.push(wsh.at_derivation_index(0).unwrap());
3632
}
3733
desc_vec
3834
}
@@ -71,7 +67,7 @@ fn get_vout(cl: &Client, txid: Txid, value: u64) -> (OutPoint, TxOut) {
7167

7268
pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
7369
let secp = secp256k1::Secp256k1::new();
74-
let desc_vec = parse_miniscripts(&secp, &testdata.pubdata);
70+
let desc_vec = parse_miniscripts(&testdata.pubdata);
7571
let sks = &testdata.secretdata.sks;
7672
let pks = &testdata.pubdata.pks;
7773
// Generate some blocks
@@ -152,6 +148,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
152148
input.witness_utxo = Some(witness_utxo);
153149
input.witness_script = Some(desc.explicit_script().unwrap());
154150
psbt.inputs.push(input);
151+
psbt.update_input_with_descriptor(0, &desc).unwrap();
155152
psbt.outputs.push(psbt::Output::default());
156153
psbts.push(psbt);
157154
}
@@ -160,7 +157,8 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
160157
// Sign the transactions with all keys
161158
// AKA the signer role of psbt
162159
for i in 0..psbts.len() {
163-
let ms = if let Descriptor::Wsh(wsh) = &desc_vec[i] {
160+
let wsh_derived = desc_vec[i].derived_descriptor(&secp).unwrap();
161+
let ms = if let Descriptor::Wsh(wsh) = &wsh_derived {
164162
match wsh.as_inner() {
165163
miniscript::descriptor::WshInner::Ms(ms) => ms,
166164
_ => unreachable!(),

0 commit comments

Comments
 (0)