diff --git a/prop/src/main.rs b/prop/src/main.rs index 217b34c..c92001a 100644 --- a/prop/src/main.rs +++ b/prop/src/main.rs @@ -73,8 +73,45 @@ proptest! { let sum: Amount = selection.into_iter().sum(); assert_eq!(target, sum); } + + #[test] + fn test_bnb_arbitrary_target(t in any::()) { + let target_str = format!("{} cBTC", t % 10); + let target = Amount::from_str(&target_str).unwrap(); + + let pool: Vec<_> = (1..10) + .map(|i| format!("{} cBTC", i)) + .map(|s| Amount::from_str(&s).unwrap()) + .map(|a| { + let output = TxOut { + value: a, + script_pubkey: ScriptBuf::new() + }; + + let satisfaction_weight = Weight::ZERO; + + Utxo { + output, + satisfaction_weight + } + }) + .collect(); + + let selection_sum: Amount = + select_coins_bnb( + target, + Amount::ZERO, + FeeRate::ZERO, + FeeRate::ZERO, + &pool) + .unwrap() + .map(|i| i.value()).sum(); + + assert_eq!(selection_sum, target); + } } fn main() { test_bnb_arbitrary_pool(); + test_bnb_arbitrary_target(); }