@@ -318,7 +318,7 @@ macro_rules! assert_loaded_program_with_size {
318318 $loader_status
319319 ) ;
320320 let actual_size = loaded_program. program_data. len( ) ;
321- let ( min, max) = $crate:: min_max_with_deviation_percent( $size, 5.0 ) ;
321+ let ( min, max) = $crate:: min_max_with_deviation_percent! ( $size, 5.0 ) ;
322322 assert!(
323323 actual_size >= min && actual_size <= max,
324324 "Expected program {} to have size around {}, got {}" ,
@@ -334,7 +334,7 @@ macro_rules! assert_loaded_program_with_size {
334334macro_rules! assert_data_has_size {
335335 ( $data: expr, $size: expr) => { {
336336 let actual_size = $data. len( ) ;
337- let ( min, max) = $crate:: min_max_with_deviation_percent( $size, 5.0 ) ;
337+ let ( min, max) = $crate:: min_max_with_deviation_percent! ( $size, 5.0 ) ;
338338 assert!(
339339 actual_size >= min && actual_size <= max,
340340 "Expected data to have size around {}, got {}" ,
@@ -344,14 +344,14 @@ macro_rules! assert_data_has_size {
344344 } } ;
345345}
346346
347- #[ allow ( unused ) ]
348- fn min_max_with_deviation_percent ( size : usize , percent : f64 ) -> ( usize , usize ) {
349- // Program size may vary a bit
350- // especially across differnt solana versions + OSes
351- let deviation = ( size as f64 * percent / 100.0 ) . ceil ( ) as usize ;
352- let min = size. saturating_sub ( deviation) ;
353- let max = size + deviation ;
354- ( min , max )
347+ #[ macro_export ]
348+ macro_rules! min_max_with_deviation_percent {
349+ ( $ size: expr , $percent : expr ) => { {
350+ let deviation = ( $size as f64 * $percent / 100.0 ) . ceil ( ) as usize ;
351+ let min = $size - deviation ;
352+ let max = $ size + deviation;
353+ ( min , max )
354+ } } ;
355355}
356356
357357#[ macro_export]
0 commit comments