Skip to content

Commit cf0125c

Browse files
committed
test: add test_legacy_create_tx_absolute_fee()
1 parent a8a0df4 commit cf0125c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

wallet/tests/wallet.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,26 @@ fn test_create_tx_absolute_fee() {
979979
);
980980
}
981981

982+
#[test]
983+
fn test_legacy_create_tx_absolute_fee() {
984+
let (mut wallet, _) = get_funded_wallet_single(get_test_pkh());
985+
let addr = wallet.next_unused_address(KeychainKind::External);
986+
let mut builder = wallet.build_tx();
987+
builder
988+
.drain_to(addr.script_pubkey())
989+
.drain_wallet()
990+
.fee_absolute(Amount::from_sat(100));
991+
let psbt = builder.finish().unwrap();
992+
let fee = check_fee!(wallet, psbt);
993+
994+
assert_eq!(fee.unwrap_or(Amount::ZERO), Amount::from_sat(100));
995+
assert_eq!(psbt.unsigned_tx.output.len(), 1);
996+
assert_eq!(
997+
psbt.unsigned_tx.output[0].value,
998+
Amount::from_sat(50_000) - fee.unwrap_or(Amount::ZERO)
999+
);
1000+
}
1001+
9821002
#[test]
9831003
fn test_create_tx_absolute_zero_fee() {
9841004
let (mut wallet, _) = get_funded_wallet_wpkh();

0 commit comments

Comments
 (0)