(outpoint(5), Amount::from_sat(103)),
(outpoint(6), Amount::from_sat(10_000)),
(outpoint(3), Amount::from_sat(104)),
(outpoint(7), Amount::from_sat(102)),
];
let mut tx_builder = TransactionBuilder::new(
satpoint(0, 0),
BTreeMap::new(),
utxos.into_iter().collect(),
BTreeSet::new(),
recipient(),
[change(0), change(1)],
FeeRate::try_from(1.0).unwrap(),
Target::Value(Amount::from_sat(10_000)),
);
assert_eq!(
tx_builder
.select_cardinal_utxo(target_value, prefer_under)
.unwrap()
.1,
expected_value
);
}
#[test]
fn select_cardinal_utxo_prefer_under() {
// select biggest utxo <= 104
select_cardinal_utxo_prefer_under_helper(Amount::from_sat(104), true, Amount::from_sat(104));
// select biggest utxo <= 1_000
select_cardinal_utxo_prefer_under_helper(Amount::from_sat(1_000), true, Amount::from_sat(105));
// select biggest utxo <= 10, else smallest > 10
select_cardinal_utxo_prefer_under_helper(Amount::from_sat(10), true, Amount::from_sat(101));