@@ -48,6 +48,7 @@ pub fn select_coins_srd<'a, R: rand::Rng + ?Sized, Utxo: WeightedUtxo>(
48
48
let mut value = Amount :: ZERO ;
49
49
50
50
let mut iteration = 0 ;
51
+
51
52
for w_utxo in origin {
52
53
iteration += 1 ;
53
54
let effective_value = w_utxo. effective_value ( fee_rate) ;
@@ -248,17 +249,18 @@ mod tests {
248
249
. assert ( ) ;
249
250
}
250
251
251
- //#[test]
252
- //fn select_coins_srd_addition_overflow() {
253
- //TestSRD {
254
- //target: "2 cBTC",
255
- //fee_rate: "10 sat/kwu",
256
- //weighted_utxos: &["1 cBTC/18446744073709551615 wu"], // weight= u64::MAX
257
- //expected_utxos: None,
258
- //expected_iterations: 0,
259
- //}
260
- //.assert();
261
- //}
252
+ #[ test]
253
+ fn select_coins_srd_addition_overflow ( ) {
254
+ // Overflow when effective_value is computed with MAX weight.
255
+ TestSRD {
256
+ target : "2 cBTC" ,
257
+ fee_rate : "10 sat/kwu" ,
258
+ weighted_utxos : & [ "1 cBTC/MAX" ] ,
259
+ expected_utxos : None ,
260
+ expected_iterations : 0 ,
261
+ }
262
+ . assert ( ) ;
263
+ }
262
264
263
265
#[ test]
264
266
fn select_coins_srd_threshold_overflow ( ) {
@@ -272,24 +274,28 @@ mod tests {
272
274
. assert ( ) ;
273
275
}
274
276
275
- //#[test]
276
- //fn select_coins_srd_pool_overflow() {
277
- //TestSRD {
278
- //target: "18315535.91666658 BTC",
279
- //fee_rate: "0",
280
- //weighted_utxos: &[
281
- //"e(1550078614956004 sats)/68 vB",
282
- //"e(1831540706090689 sats)/18446744073692774400 wu",
283
- //"e(12885625970 sats)/68 vB",
284
- //],
285
- //expected_utxos: Some(&[
286
- //"e(1831540706090689 sats)/18446744073692774400 wu",
287
- //"e(12885625970 sats)/68 vB",
288
- //]),
289
- //expected_iterations: 2,
290
- //}
291
- //.assert();
292
- //}
277
+ #[ test]
278
+ fn select_coins_srd_pool_overflow ( ) {
279
+ // Adding the first utxo to the second overflows.
280
+ // The test shows that the second UTXO is then skipped
281
+ // due to overflow and the next one is still selected.
282
+
283
+ TestSRD {
284
+ target : "18315535.91666658 BTC" ,
285
+ fee_rate : "0" ,
286
+ weighted_utxos : & [
287
+ "e(1550078614956004 sats)/68 vB" ,
288
+ "e(1831540706090689 sats)/68 vB" ,
289
+ "e(12885625970 sats)/68 vB" ,
290
+ ] ,
291
+ expected_utxos : Some ( & [
292
+ "e(1831540706090689 sats)/68 vB" ,
293
+ "e(12885625970 sats)/68 vB" ,
294
+ ] ) ,
295
+ expected_iterations : 2 ,
296
+ }
297
+ . assert ( ) ;
298
+ }
293
299
294
300
//#[test]
295
301
//fn select_srd_match_proptest() {
0 commit comments