@@ -509,15 +509,15 @@ async fn test_execute_txs_inner_resources() {
509509 let version = StarknetVersion :: LATEST ;
510510 let mut raw_vc: RawVersionedConstants =
511511 serde_json:: from_str ( VersionedConstants :: json_str ( & version) . unwrap ( ) ) . unwrap ( ) ;
512- // TODO(Dori): L1Handler.
513- const N_TXS : usize = 5 ;
512+ const N_TXS : usize = 7 ;
514513
515514 // For linear factor measurements, it's not enough to just add one more calldata element; the
516515 // increase is not the same per element. The linear scale is on average.
517516 const INVOKE_SCALING_FACTOR : usize = 2 ;
518517 const DEPLOY_SCALING_FACTOR : usize = 2 ;
519518 const INVOKE_EXTRA_ARGS : usize = 10 ;
520519 const DEPLOY_EXTRA_ARGS : usize = 10 ;
520+ const L1_HANDLER_EXTRA_ARGS : usize = 10 ;
521521
522522 let OsResourcesTestSetup {
523523 stable_contract_address,
@@ -605,6 +605,28 @@ async fn test_execute_txs_inner_resources() {
605605 test_builder. add_deploy_account_tx ( deploy_tx_first) ;
606606 test_builder. add_deploy_account_tx ( deploy_tx_second) ;
607607
608+ // L1 handler.
609+ test_builder. add_l1_handler (
610+ stable_contract_address,
611+ "l1_handler" ,
612+ // From address, extra args length.
613+ calldata ! [ Felt :: from( 100 ) , Felt :: ZERO ] ,
614+ None ,
615+ ) ;
616+ test_builder. add_l1_handler (
617+ stable_contract_address,
618+ "l1_handler" ,
619+ // From address, extra args.
620+ Calldata ( Arc :: new (
621+ [
622+ vec ! [ Felt :: from( 100 ) , Felt :: from( L1_HANDLER_EXTRA_ARGS ) ] ,
623+ vec ! [ Felt :: ZERO ; L1_HANDLER_EXTRA_ARGS ] ,
624+ ]
625+ . concat ( ) ,
626+ ) ) ,
627+ None ,
628+ ) ;
629+
608630 // Execute the business logic and extract the business logic resources for each tx.
609631 let test_runner = test_builder. build ( ) . await ;
610632 let business_logic_resources: [ ExecutionResources ; N_TXS ] = test_runner
@@ -643,6 +665,8 @@ async fn test_execute_txs_inner_resources() {
643665 declare_constant,
644666 deploy_first,
645667 deploy_second,
668+ l1_handler_first,
669+ l1_handler_second,
646670 ] : [ ExecutionResources ; N_TXS ] = test_output
647671 . runner_output
648672 . txs_trace
@@ -669,6 +693,10 @@ async fn test_execute_txs_inner_resources() {
669693 let deploy_linear_factor = ( & ( & deploy_second - & deploy_first) . filter_unused_builtins ( )
670694 * DEPLOY_SCALING_FACTOR )
671695 . div_ceil ( DEPLOY_EXTRA_ARGS ) ;
696+ // L1 handler linear factor is unscaled.
697+ let l1_handler_linear_factor = ( & l1_handler_second - & l1_handler_first)
698+ . filter_unused_builtins ( )
699+ . div_ceil ( L1_HANDLER_EXTRA_ARGS ) ;
672700 raw_vc. os_resources . execute_txs_inner . extend ( [
673701 (
674702 TransactionType :: InvokeFunction ,
@@ -691,6 +719,13 @@ async fn test_execute_txs_inner_resources() {
691719 } ) ,
692720 } ) ,
693721 ) ,
722+ (
723+ TransactionType :: L1Handler ,
724+ VariableResourceParams :: WithFactor ( ResourcesParams {
725+ constant : ( & l1_handler_first - & l1_handler_linear_factor) . filter_unused_builtins ( ) ,
726+ calldata_factor : VariableCallDataFactor :: Unscaled ( l1_handler_linear_factor) ,
727+ } ) ,
728+ ) ,
694729 ] ) ;
695730
696731 // Verify computation.
0 commit comments