@@ -1011,11 +1011,35 @@ fn test_create_tx_absolute_zero_fee() {
1011
1011
let psbt = builder. finish ( ) . unwrap ( ) ;
1012
1012
let fee = check_fee ! ( wallet, psbt) ;
1013
1013
1014
- assert_eq ! ( fee. unwrap_or( Amount :: ZERO ) , Amount :: ZERO ) ;
1014
+ // we can't `unwrap_or(Amount::ZERO)` because the
1015
+ // test would succeed if there was an error with `fee`
1016
+ assert_eq ! ( fee. unwrap_or( Amount :: from_sat( 21 ) ) , Amount :: ZERO ) ;
1015
1017
assert_eq ! ( psbt. unsigned_tx. output. len( ) , 1 ) ;
1016
1018
assert_eq ! (
1017
1019
psbt. unsigned_tx. output[ 0 ] . value,
1018
- Amount :: from_sat( 50_000 ) - fee. unwrap_or( Amount :: ZERO )
1020
+ Amount :: from_sat( 50_000 ) - fee. unwrap_or( Amount :: from_sat( 21 ) )
1021
+ ) ;
1022
+ }
1023
+
1024
+ #[ test]
1025
+ fn test_legacy_create_tx_absolute_zero_fee ( ) {
1026
+ let ( mut wallet, _) = get_funded_wallet_single ( get_test_pkh ( ) ) ;
1027
+ let addr = wallet. next_unused_address ( KeychainKind :: External ) ;
1028
+ let mut builder = wallet. build_tx ( ) ;
1029
+ builder
1030
+ . drain_to ( addr. script_pubkey ( ) )
1031
+ . drain_wallet ( )
1032
+ . fee_absolute ( Amount :: ZERO ) ;
1033
+ let psbt = builder. finish ( ) . unwrap ( ) ;
1034
+ let fee = check_fee ! ( wallet, psbt) ;
1035
+
1036
+ // we can't `unwrap_or(Amount::ZERO)` because the
1037
+ // test would succeed if there was an error with `fee`
1038
+ assert_eq ! ( fee. unwrap_or( Amount :: from_sat( 21 ) ) , Amount :: ZERO ) ;
1039
+ assert_eq ! ( psbt. unsigned_tx. output. len( ) , 1 ) ;
1040
+ assert_eq ! (
1041
+ psbt. unsigned_tx. output[ 0 ] . value,
1042
+ Amount :: from_sat( 50_000 ) - fee. unwrap_or( Amount :: from_sat( 21 ) )
1019
1043
) ;
1020
1044
}
1021
1045
0 commit comments