Skip to content

Commit 4999462

Browse files
committed
Add test 6
1 parent c9429bd commit 4999462

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: src/coin_grinder.rs

+36
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,40 @@ mod tests {
501501

502502
assert_coin_select_params(&params, 213, Some(&["14 BTC", "13 BTC", "4 BTC"]));
503503
}
504+
505+
#[test]
506+
// 6) Test that the lightest solution among many clones is found
507+
// https://github.com/bitcoin/bitcoin/blob/43e71f74988b2ad87e4bfc0e1b5c921ab86ec176/src/wallet/test/coinselector_tests.cpp#L1244
508+
fn lightest_amount_many_clones() {
509+
let mut coins = vec![
510+
"4 BTC/400",
511+
"3 BTC/400",
512+
"2 BTC/400",
513+
"1 BTC/400"
514+
];
515+
516+
for _i in 0..100 {
517+
coins.push("8 BTC/4000");
518+
coins.push("7 BTC/3200");
519+
coins.push("6 BTC/2400");
520+
coins.push("5 BTC/1600");
521+
}
522+
523+
let params = ParamsStr {
524+
target: "9.9 BTC",
525+
change_target: "1000000 sats",
526+
max_weight: "400000",
527+
fee_rate: "5",
528+
weighted_utxos: coins
529+
};
530+
531+
let expected = vec![
532+
"4 BTC",
533+
"3 BTC",
534+
"2 BTC",
535+
"1 BTC"
536+
];
537+
538+
assert_coin_select_params(&params, 31, Some(&expected));
539+
}
504540
}

0 commit comments

Comments
 (0)