Skip to content

Commit

Permalink
Add test for utxo pool sum overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Jan 5, 2024
1 parent 66d4274 commit f4bb483
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,25 @@ mod tests {
select_coins_bnb(target, Amount::ZERO, FeeRate::ZERO, &mut weighted_utxos).unwrap();
assert_eq!(list, Vec::new());
}

#[test]
fn utxo_pool_sum_overflow() {
let target = Amount::from_str("1 cBTC").unwrap();
let mut weighted_utxos = vec![
WeightedUtxo {
satisfaction_weight: Weight::ZERO,
utxo: TxOut { value: Amount::MAX, script_pubkey: ScriptBuf::new() },
},
WeightedUtxo {
satisfaction_weight: Weight::ZERO,
utxo: TxOut { value: Amount::MAX, script_pubkey: ScriptBuf::new() },
},
];

let list = select_coins_bnb(target, Amount::ZERO, FeeRate::ZERO, &mut weighted_utxos);

assert!(list.is_none());
}
}

#[cfg(bench)]
Expand Down

0 comments on commit f4bb483

Please sign in to comment.