@@ -252,8 +252,12 @@ mod test {
252
252
// assert_eq!(expected, evaluation_result)
253
253
}
254
254
255
+ /// Performance test that evaluates VRF for a large number of delegators.
256
+ /// This test is ignored because it takes a long time to run (evaluates 14,403 delegators).
257
+ /// It's useful for measuring VRF calculation performance with realistic producer sizes.
258
+ /// Run with: `cargo test test_slot_calculation_time_big_producer -- --ignored`
255
259
#[ test]
256
- #[ ignore]
260
+ #[ ignore = "Performance test - takes several minutes to complete" ]
257
261
fn test_slot_calculation_time_big_producer ( ) {
258
262
let start = redux:: Instant :: now ( ) ;
259
263
for i in 1 ..14403 {
@@ -282,8 +286,12 @@ mod test {
282
286
println ! ( "Duration: {}" , elapsed. as_secs( ) ) ;
283
287
}
284
288
289
+ /// Performance test that searches for winning VRF slots across many global slots.
290
+ /// This test is ignored because it takes a long time to run (checks 7,000 slots).
291
+ /// It's useful for understanding VRF winning slot distribution patterns.
292
+ /// Run with: `cargo test test_first_winning_slot -- --ignored`
285
293
#[ test]
286
- #[ ignore]
294
+ #[ ignore = "Performance test - takes several minutes to complete" ]
287
295
fn test_first_winning_slot ( ) {
288
296
for i in 0 ..7000 {
289
297
let vrf_input = VrfEvaluationInput {
@@ -309,4 +317,65 @@ mod test {
309
317
}
310
318
}
311
319
}
320
+
321
+ /// Test VRF evaluation performance with a smaller dataset suitable for CI.
322
+ /// This runs a reduced version of the big producer test to ensure VRF performance
323
+ /// doesn't regress without taking too long in CI.
324
+ #[ test]
325
+ fn test_vrf_performance_small ( ) {
326
+ let start = redux:: Instant :: now ( ) ;
327
+ for i in 1 ..10 { // Much smaller than 14,403
328
+ let vrf_input = VrfEvaluationInput {
329
+ producer_key : keypair_from_bs58_string (
330
+ "EKEEpMELfQkMbJDt2fB4cFXKwSf1x4t7YD4twREy5yuJ84HBZtF9" ,
331
+ ) ,
332
+ epoch_seed : EpochSeed :: from_str (
333
+ "2va9BGv9JrLTtrzZttiEMDYw1Zj6a6EHzXjmP9evHDTG3oEquURA" ,
334
+ )
335
+ . unwrap ( ) ,
336
+ global_slot : 6 ,
337
+ delegator_index : AccountIndex ( i) ,
338
+ delegated_stake : BigInt :: from_str ( "1000000000000000" )
339
+ . expect ( "Cannot convert to BigInt" ) ,
340
+ total_currency : BigInt :: from_str ( "6000000000001000" )
341
+ . expect ( "Cannot convert to BigInt" ) ,
342
+ account_pub_key : AccountSecretKey :: genesis_producer ( ) . public_key ( ) ,
343
+ } ;
344
+ let result = evaluate_vrf ( vrf_input) . expect ( "Failed to evaluate VRF" ) ;
345
+ // Ensure we get a valid result
346
+ assert ! ( matches!( result, VrfEvaluationOutput :: SlotWon ( _) | VrfEvaluationOutput :: SlotLost ( _) ) ) ;
347
+ }
348
+ let elapsed = start. elapsed ( ) ;
349
+ // Ensure the small test completes in reasonable time (under 10 seconds)
350
+ assert ! ( elapsed. as_secs( ) < 10 , "VRF evaluation took too long: {}s" , elapsed. as_secs( ) ) ;
351
+ }
352
+
353
+ /// Test VRF slot discovery with a smaller dataset suitable for CI.
354
+ /// This runs a reduced version of the winning slot test to ensure basic functionality
355
+ /// without taking too long in CI.
356
+ #[ test]
357
+ fn test_vrf_slot_discovery_small ( ) {
358
+ for i in 0 ..100 { // Much smaller than 7,000
359
+ let vrf_input = VrfEvaluationInput {
360
+ producer_key : keypair_from_bs58_string (
361
+ "EKEEpMELfQkMbJDt2fB4cFXKwSf1x4t7YD4twREy5yuJ84HBZtF9" ,
362
+ ) ,
363
+ epoch_seed : EpochSeed :: from_str (
364
+ "2va9BGv9JrLTtrzZttiEMDYw1Zj6a6EHzXjmP9evHDTG3oEquURA" ,
365
+ )
366
+ . unwrap ( ) ,
367
+ global_slot : i,
368
+ delegator_index : AccountIndex ( 2 ) ,
369
+ delegated_stake : BigInt :: from_str ( "1000000000000000" )
370
+ . expect ( "Cannot convert to BigInt" ) ,
371
+ total_currency : BigInt :: from_str ( "6000000000001000" )
372
+ . expect ( "Cannot convert to BigInt" ) ,
373
+ account_pub_key : AccountSecretKey :: genesis_producer ( ) . public_key ( ) ,
374
+ } ;
375
+ let evaluation_result =
376
+ evaluate_vrf ( vrf_input. clone ( ) ) . expect ( "Failed to evaluate vrf" ) ;
377
+ // Just ensure VRF evaluation works without errors for all slots
378
+ assert ! ( matches!( evaluation_result, VrfEvaluationOutput :: SlotWon ( _) | VrfEvaluationOutput :: SlotLost ( _) ) ) ;
379
+ }
380
+ }
312
381
}
0 commit comments