Skip to content

Commit

Permalink
Add max selection test for when some coins surpass the max allowed
Browse files Browse the repository at this point in the history
weight while others not.
  • Loading branch information
yancyribbens committed Jan 25, 2025
1 parent 7987d90 commit 9b3a7bc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/coin_grinder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,36 @@ mod tests {

assert_coin_select_params(&params, None);
}

#[test]
fn max_weight_with_result() {
let mut coins = Vec::new();
// TODO change this to match the core test by providing 60 utxos
// that are 0.33. Currently the missing optimizations cause this
// to take a very very long time.
for _i in 0..20 {
coins.push("0.33 BTC/272");
}
for _i in 0..10 {
coins.push("2 BTC/272");
}

let params = ParamsStr {
target: "25.33 BTC",
change_target: "1000000 sats",
max_weight: "10000",
fee_rate: "5",
weighted_utxos: coins
};

let mut expected = Vec::new();
for _i in 0..10 {
expected.push("2 BTC");
}
for _i in 0..17 {
expected.push("0.33 BTC");
}

assert_coin_select_params(&params, Some(&expected));
}
}

0 comments on commit 9b3a7bc

Please sign in to comment.