Skip to content

Commit 9310942

Browse files
committed
Merge rust-bitcoin#4529: psbt: replace the fee rate magic numbers with named constants in tests
ade7ea5 psbt: replace the fee rate magic numbers with named constants in tests (frankomosh) Pull request description: Replace a hardcoded fee rate numbers in PSBT high-fee checks test with named constants. Close rust-bitcoin#4378 ACKs for top commit: tcharding: ACK ade7ea5 apoelstra: ACK ade7ea5; successfully ran local tests Tree-SHA512: fa02217940ae32f00164c762c82ecb6bd28da58e5ad44165124a7ad44367d7d0f752e7ab189b991edb2460c449bbd0a83df16a47b082f6755bd9e9d38e398cd8
2 parents cc66dde + ade7ea5 commit 9310942

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

bitcoin/src/psbt/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ mod tests {
13041304
use crate::witness::Witness;
13051305
use crate::Sequence;
13061306

1307+
/// Fee rate in sat/kwu for a high-fee PSBT with an input=5_000_000_000_000, output=1000
1308+
const ABSURD_FEE_RATE: FeeRate = FeeRate::from_sat_per_kwu(15_060_240_960_843);
1309+
/// Fee rate which is just below absurd threshold (1 sat/kwu less)
1310+
const JUST_BELOW_ABSURD_FEE_RATE: FeeRate = FeeRate::from_sat_per_kwu(15_060_240_960_842);
1311+
13071312
#[track_caller]
13081313
pub fn hex_psbt(s: &str) -> Result<Psbt, crate::psbt::error::Error> {
13091314
let r = Vec::from_hex(s);
@@ -1393,26 +1398,26 @@ mod tests {
13931398
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
13941399
_ => panic!(""),
13951400
}),
1396-
Err(FeeRate::from_sat_per_kwu(15060240960843))
1401+
Err(ABSURD_FEE_RATE)
13971402
);
13981403
assert_eq!(
13991404
psbt.clone().extract_tx_fee_rate_limit().map_err(|e| match e {
14001405
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
14011406
_ => panic!(""),
14021407
}),
1403-
Err(FeeRate::from_sat_per_kwu(15060240960843))
1408+
Err(ABSURD_FEE_RATE)
14041409
);
14051410
assert_eq!(
14061411
psbt.clone()
1407-
.extract_tx_with_fee_rate_limit(FeeRate::from_sat_per_kwu(15060240960842))
1412+
.extract_tx_with_fee_rate_limit(JUST_BELOW_ABSURD_FEE_RATE)
14081413
.map_err(|e| match e {
14091414
ExtractTxError::AbsurdFeeRate { fee_rate, .. } => fee_rate,
14101415
_ => panic!(""),
14111416
}),
1412-
Err(FeeRate::from_sat_per_kwu(15060240960843))
1417+
Err(ABSURD_FEE_RATE)
14131418
);
14141419
assert!(psbt
1415-
.extract_tx_with_fee_rate_limit(FeeRate::from_sat_per_kwu(15060240960843))
1420+
.extract_tx_with_fee_rate_limit(ABSURD_FEE_RATE)
14161421
.is_ok());
14171422

14181423
// Testing that extract_tx will error at 25k sat/vbyte (6250000 sat/kwu)

0 commit comments

Comments
 (0)