test: Document test_bump_fee_add_input_change_dust

Add a rationale for the feerate in the test
This commit is contained in:
Daniela Brozzoni 2022-08-02 12:07:16 +02:00
parent 632dabaa07
commit 419dc248b6
No known key found for this signature in database
GPG Key ID: 7DE4F1FDCED0AB87

View File

@ -3781,6 +3781,7 @@ pub(crate) mod test {
.del_utxo(&txin.previous_output) .del_utxo(&txin.previous_output)
.unwrap(); .unwrap();
} }
let original_tx_weight = tx.weight();
original_details.transaction = Some(tx); original_details.transaction = Some(tx);
wallet wallet
.database .database
@ -3789,7 +3790,20 @@ pub(crate) mod test {
.unwrap(); .unwrap();
let mut builder = wallet.build_fee_bump(txid).unwrap(); let mut builder = wallet.build_fee_bump(txid).unwrap();
builder.fee_rate(FeeRate::from_sat_per_vb(141.0)); // We set a fee high enough that during rbf we are forced to add
// a new input and also that we have to remove the change
// that we had previously
// We calculate the new weight as:
// original weight
// + extra input weight: 160 WU = (32 (prevout) + 4 (vout) + 4 (nsequence)) * 4
// + input satisfaction weight: 112 WU = 106 (witness) + 2 (witness len) + (1 (script len)) * 4
// - change output weight: 124 WU = (8 (value) + 1 (script len) + 22 (script)) * 4
let new_tx_weight = original_tx_weight + 160 + 112 - 124;
// two inputs (50k, 25k) and one output (45k) - epsilon
// We use epsilon here to avoid asking for a slightly too high feerate
let fee_abs = 50_000 + 25_000 - 45_000 - 10;
builder.fee_rate(FeeRate::from_wu(fee_abs, new_tx_weight));
let (psbt, details) = builder.finish().unwrap(); let (psbt, details) = builder.finish().unwrap();
assert_eq!( assert_eq!(