Skip to content

Commit 1019336

Browse files
Fix tests for new API.
1 parent 2ef1436 commit 1019336

1 file changed

Lines changed: 41 additions & 24 deletions

File tree

crates/bdk/tests/wallet.rs

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn test_create_tx_drain_to_and_utxos() {
437437
let utxos: Vec<_> = wallet
438438
.list_unspent()
439439
.into_iter()
440-
.map(|u| u.outpoint)
440+
.map(|(u, k)| (u.outpoint, k))
441441
.collect();
442442
let mut builder = wallet.build_tx();
443443
builder
@@ -818,10 +818,13 @@ fn test_create_tx_add_utxo() {
818818
let mut builder = wallet.build_tx();
819819
builder
820820
.add_recipient(addr.script_pubkey(), 30_000)
821-
.add_utxo(OutPoint {
822-
txid: small_output_tx.txid(),
823-
vout: 0,
824-
})
821+
.add_utxo(
822+
OutPoint {
823+
txid: small_output_tx.txid(),
824+
vout: 0,
825+
},
826+
KeychainKind::External,
827+
)
825828
.unwrap();
826829
let (psbt, details) = builder.finish().unwrap();
827830

@@ -855,10 +858,13 @@ fn test_create_tx_manually_selected_insufficient() {
855858
let mut builder = wallet.build_tx();
856859
builder
857860
.add_recipient(addr.script_pubkey(), 30_000)
858-
.add_utxo(OutPoint {
859-
txid: small_output_tx.txid(),
860-
vout: 0,
861-
})
861+
.add_utxo(
862+
OutPoint {
863+
txid: small_output_tx.txid(),
864+
vout: 0,
865+
},
866+
KeychainKind::External,
867+
)
862868
.unwrap()
863869
.manually_selected_only();
864870
builder.finish().unwrap();
@@ -972,9 +978,10 @@ fn test_add_foreign_utxo() {
972978
get_funded_wallet("wpkh(cVbZ8ovhye9AoAHFsqobCf7LxbXDAECy9Kb8TZdfsDYMZGBUyCnm)");
973979

974980
let addr = Address::from_str("2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX").unwrap();
975-
let utxo = wallet2.list_unspent().remove(0);
981+
let (utxo, _) = wallet2.list_unspent().remove(0);
976982
let foreign_utxo_satisfaction = wallet2
977983
.get_descriptor_for_keychain(KeychainKind::External)
984+
.unwrap()
978985
.max_satisfaction_weight()
979986
.unwrap();
980987

@@ -1036,9 +1043,10 @@ fn test_add_foreign_utxo() {
10361043
#[should_panic(expected = "Generic(\"Foreign utxo missing witness_utxo or non_witness_utxo\")")]
10371044
fn test_add_foreign_utxo_invalid_psbt_input() {
10381045
let (mut wallet, _) = get_funded_wallet(get_test_wpkh());
1039-
let outpoint = wallet.list_unspent()[0].outpoint;
1046+
let outpoint = wallet.list_unspent()[0].0.outpoint;
10401047
let foreign_utxo_satisfaction = wallet
10411048
.get_descriptor_for_keychain(KeychainKind::External)
1049+
.unwrap()
10421050
.max_satisfaction_weight()
10431051
.unwrap();
10441052

@@ -1054,12 +1062,13 @@ fn test_add_foreign_utxo_where_outpoint_doesnt_match_psbt_input() {
10541062
let (wallet2, txid2) =
10551063
get_funded_wallet("wpkh(cVbZ8ovhye9AoAHFsqobCf7LxbXDAECy9Kb8TZdfsDYMZGBUyCnm)");
10561064

1057-
let utxo2 = wallet2.list_unspent().remove(0);
1065+
let (utxo2, _) = wallet2.list_unspent().remove(0);
10581066
let tx1 = wallet1.get_tx(txid1, true).unwrap().transaction.unwrap();
10591067
let tx2 = wallet2.get_tx(txid2, true).unwrap().transaction.unwrap();
10601068

10611069
let satisfaction_weight = wallet2
10621070
.get_descriptor_for_keychain(KeychainKind::External)
1071+
.unwrap()
10631072
.max_satisfaction_weight()
10641073
.unwrap();
10651074

@@ -1098,10 +1107,11 @@ fn test_add_foreign_utxo_only_witness_utxo() {
10981107
let (wallet2, txid2) =
10991108
get_funded_wallet("wpkh(cVbZ8ovhye9AoAHFsqobCf7LxbXDAECy9Kb8TZdfsDYMZGBUyCnm)");
11001109
let addr = Address::from_str("2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX").unwrap();
1101-
let utxo2 = wallet2.list_unspent().remove(0);
1110+
let (utxo2, _) = wallet2.list_unspent().remove(0);
11021111

11031112
let satisfaction_weight = wallet2
11041113
.get_descriptor_for_keychain(KeychainKind::External)
1114+
.unwrap()
11051115
.max_satisfaction_weight()
11061116
.unwrap();
11071117

@@ -1160,7 +1170,7 @@ fn test_add_foreign_utxo_only_witness_utxo() {
11601170
fn test_get_psbt_input() {
11611171
// this should grab a known good utxo and set the input
11621172
let (wallet, _) = get_funded_wallet(get_test_wpkh());
1163-
for utxo in wallet.list_unspent() {
1173+
for (utxo, _) in wallet.list_unspent() {
11641174
let psbt_input = wallet.get_psbt_input(utxo, None, false).unwrap();
11651175
assert!(psbt_input.witness_utxo.is_some() || psbt_input.non_witness_utxo.is_some());
11661176
}
@@ -1478,10 +1488,13 @@ fn test_bump_fee_drain_wallet() {
14781488
let mut builder = wallet.build_tx();
14791489
builder
14801490
.drain_to(addr.script_pubkey())
1481-
.add_utxo(OutPoint {
1482-
txid: tx.txid(),
1483-
vout: 0,
1484-
})
1491+
.add_utxo(
1492+
OutPoint {
1493+
txid: tx.txid(),
1494+
vout: 0,
1495+
},
1496+
KeychainKind::External,
1497+
)
14851498
.unwrap()
14861499
.manually_selected_only()
14871500
.enable_rbf();
@@ -1533,7 +1546,7 @@ fn test_bump_fee_remove_output_manually_selected_only() {
15331546
let mut builder = wallet.build_tx();
15341547
builder
15351548
.drain_to(addr.script_pubkey())
1536-
.add_utxo(outpoint)
1549+
.add_utxo(outpoint, KeychainKind::External)
15371550
.unwrap()
15381551
.manually_selected_only()
15391552
.enable_rbf();
@@ -1660,7 +1673,7 @@ fn test_bump_fee_no_change_add_input_and_change() {
16601673
let mut builder = wallet.build_tx();
16611674
builder
16621675
.drain_to(addr.script_pubkey())
1663-
.add_utxo(op)
1676+
.add_utxo(op, KeychainKind::External)
16641677
.unwrap()
16651678
.manually_selected_only()
16661679
.enable_rbf();
@@ -1790,7 +1803,7 @@ fn test_bump_fee_force_add_input() {
17901803
// the addition of an extra input with `add_utxo()`
17911804
let mut builder = wallet.build_fee_bump(txid).unwrap();
17921805
builder
1793-
.add_utxo(incoming_op)
1806+
.add_utxo(incoming_op, KeychainKind::External)
17941807
.unwrap()
17951808
.fee_rate(FeeRate::from_sat_per_vb(5.0));
17961809
let (psbt, details) = builder.finish().unwrap();
@@ -1845,7 +1858,10 @@ fn test_bump_fee_absolute_force_add_input() {
18451858
// the new fee_rate is low enough that just reducing the change would be fine, but we force
18461859
// the addition of an extra input with `add_utxo()`
18471860
let mut builder = wallet.build_fee_bump(txid).unwrap();
1848-
builder.add_utxo(incoming_op).unwrap().fee_absolute(250);
1861+
builder
1862+
.add_utxo(incoming_op, KeychainKind::External)
1863+
.unwrap()
1864+
.fee_absolute(250);
18491865
let (psbt, details) = builder.finish().unwrap();
18501866

18511867
assert_eq!(details.sent, original_details.sent + 25_000);
@@ -1956,7 +1972,7 @@ fn test_fee_amount_negative_drain_val() {
19561972
let mut builder = wallet.build_tx();
19571973
builder
19581974
.add_recipient(send_to.script_pubkey(), 8630)
1959-
.add_utxo(incoming_op)
1975+
.add_utxo(incoming_op, KeychainKind::External)
19601976
.unwrap()
19611977
.enable_rbf()
19621978
.fee_rate(fee_rate);
@@ -2660,10 +2676,11 @@ fn test_taproot_foreign_utxo() {
26602676
let (wallet2, _) = get_funded_wallet(get_test_tr_single_sig());
26612677

26622678
let addr = Address::from_str("2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX").unwrap();
2663-
let utxo = wallet2.list_unspent().remove(0);
2679+
let (utxo, _) = wallet2.list_unspent().remove(0);
26642680
let psbt_input = wallet2.get_psbt_input(utxo.clone(), None, false).unwrap();
26652681
let foreign_utxo_satisfaction = wallet2
26662682
.get_descriptor_for_keychain(KeychainKind::External)
2683+
.unwrap()
26672684
.max_satisfaction_weight()
26682685
.unwrap();
26692686

0 commit comments

Comments
 (0)