@@ -12,7 +12,10 @@ use crate::{
1212
1313use crate :: generation:: { frequency, Arbitrary , ArbitraryFrom } ;
1414
15- use super :: { pick, property:: Property } ;
15+ use super :: {
16+ pick,
17+ property:: { remaining, Property } ,
18+ } ;
1619
1720pub ( crate ) type ResultSet = Result < Vec < Vec < Value > > > ;
1821
@@ -470,38 +473,39 @@ impl ArbitraryFrom<(&SimulatorEnv, InteractionStats)> for Interactions {
470473 rng : & mut R ,
471474 ( env, stats) : ( & SimulatorEnv , InteractionStats ) ,
472475 ) -> Self {
473- let remaining_read = ( ( env. opts . max_interactions as f64 * env. opts . read_percent / 100.0 )
474- - ( stats. read_count as f64 ) )
475- . max ( 0.0 ) ;
476- let remaining_write = ( ( env. opts . max_interactions as f64 * env. opts . write_percent / 100.0 )
477- - ( stats. write_count as f64 ) )
478- . max ( 0.0 ) ;
479- let remaining_create = ( ( env. opts . max_interactions as f64 * env. opts . create_percent
480- / 100.0 )
481- - ( stats. create_count as f64 ) )
482- . max ( 0.0 ) ;
483-
476+ let remaining_ = remaining ( env, & stats) ;
477+ println ! (
478+ "remaining: {} {} {}" ,
479+ remaining_. read, remaining_. write, remaining_. create
480+ ) ;
484481 frequency (
485482 vec ! [
486483 (
487- f64 :: min( remaining_read , remaining_write ) + remaining_create ,
484+ f64 :: min( remaining_ . read , remaining_ . write ) + remaining_ . create ,
488485 Box :: new( |rng: & mut R | {
489486 Interactions :: Property ( Property :: arbitrary_from( rng, ( env, & stats) ) )
490487 } ) ,
491488 ) ,
492489 (
493- remaining_read ,
490+ remaining_ . read ,
494491 Box :: new( |rng: & mut R | random_read( rng, env) ) ,
495492 ) ,
496493 (
497- remaining_write ,
494+ remaining_ . write ,
498495 Box :: new( |rng: & mut R | random_write( rng, env) ) ,
499496 ) ,
500497 (
501- remaining_create ,
498+ remaining_ . create ,
502499 Box :: new( |rng: & mut R | create_table( rng, env) ) ,
503500 ) ,
504- ( 1.0 , Box :: new( |rng: & mut R | random_fault( rng, env) ) ) ,
501+ (
502+ remaining_
503+ . read
504+ . min( remaining_. write)
505+ . min( remaining_. create)
506+ . max( 1.0 ) ,
507+ Box :: new( |rng: & mut R | random_fault( rng, env) ) ,
508+ ) ,
505509 ] ,
506510 rng,
507511 )
0 commit comments