@@ -3,10 +3,11 @@ use blockifier_test_utils::calldata::create_calldata;
33use blockifier_test_utils:: contracts:: FeatureContract ;
44use rstest:: fixture;
55use starknet_api:: abi:: abi_utils:: get_fee_token_var_address;
6- use starknet_api:: block:: { FeeType , GasPrice } ;
6+ use starknet_api:: block:: { BlockNumber , BlockTimestamp , FeeType , GasPrice } ;
77use starknet_api:: contract_class:: compiled_class_hash:: HashVersion ;
88use starknet_api:: contract_class:: { ClassInfo , ContractClass , SierraVersion } ;
9- use starknet_api:: core:: { ClassHash , ContractAddress , Nonce } ;
9+ use starknet_api:: core:: { ChainId , ClassHash , ContractAddress , EntryPointSelector , Nonce } ;
10+ use starknet_api:: data_availability:: DataAvailabilityMode ;
1011use starknet_api:: executable_transaction:: TransactionType ;
1112use starknet_api:: execution_resources:: { GasAmount , GasVector } ;
1213use starknet_api:: test_utils:: declare:: executable_declare_tx;
@@ -26,15 +27,23 @@ use starknet_api::test_utils::{
2627 MAX_FEE ,
2728} ;
2829use starknet_api:: transaction:: fields:: {
30+ AccountDeploymentData ,
2931 AllResourceBounds ,
3032 ContractAddressSalt ,
3133 Fee ,
3234 GasVectorComputationMode ,
35+ PaymasterData ,
36+ Resource ,
3337 ResourceBounds ,
3438 TransactionSignature ,
3539 ValidResourceBounds ,
3640} ;
37- use starknet_api:: transaction:: { constants, TransactionVersion } ;
41+ use starknet_api:: transaction:: {
42+ constants,
43+ TransactionHash ,
44+ TransactionVersion ,
45+ QUERY_VERSION_BASE ,
46+ } ;
3847use starknet_api:: { calldata, declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args} ;
3948use starknet_types_core:: felt:: Felt ;
4049use strum:: IntoEnumIterator ;
@@ -452,3 +461,125 @@ pub fn emit_n_events_tx(
452461
453462 AccountTransaction :: new_for_sequencing ( tx)
454463}
464+
465+ /// Utility struct to test the execution info syscall.
466+ /// For simplicity, some fields are not included in the struct, and assumed empty.
467+ pub struct ExpectedExecutionInfo {
468+ pub version : TransactionVersion ,
469+ pub account_address : ContractAddress ,
470+ pub max_fee : Fee ,
471+ pub transaction_hash : TransactionHash ,
472+ pub chain_id : ChainId ,
473+ pub nonce : Nonce ,
474+ pub resource_bounds : ValidResourceBounds ,
475+ pub paymaster_data : PaymasterData ,
476+ pub nonce_data_availability_mode : DataAvailabilityMode ,
477+ pub fee_data_availability_mode : DataAvailabilityMode ,
478+ pub account_deployment_data : AccountDeploymentData ,
479+ pub caller_address : ContractAddress ,
480+ pub contract_address : ContractAddress ,
481+ pub entry_point_selector : EntryPointSelector ,
482+ pub block_number : BlockNumber ,
483+ pub block_timestamp : BlockTimestamp ,
484+ pub sequencer_address : ContractAddress ,
485+ }
486+
487+ impl ExpectedExecutionInfo {
488+ #[ allow( clippy:: too_many_arguments) ]
489+ pub fn new (
490+ only_query : bool ,
491+ account_address : ContractAddress ,
492+ caller_address : ContractAddress ,
493+ contract_address : ContractAddress ,
494+ chain_id : ChainId ,
495+ entry_point_selector : EntryPointSelector ,
496+ block_number : BlockNumber ,
497+ block_timestamp : BlockTimestamp ,
498+ sequencer_address : ContractAddress ,
499+ resource_bounds : ValidResourceBounds ,
500+ nonce : Nonce ,
501+ ) -> Self {
502+ let mut version = Felt :: THREE ;
503+ if only_query {
504+ version += * QUERY_VERSION_BASE ;
505+ }
506+ Self {
507+ version : TransactionVersion ( version) ,
508+ account_address,
509+ caller_address,
510+ contract_address,
511+ chain_id,
512+ entry_point_selector,
513+ block_number,
514+ block_timestamp,
515+ sequencer_address,
516+ resource_bounds,
517+ nonce,
518+ max_fee : Fee :: default ( ) ,
519+ transaction_hash : TransactionHash :: default ( ) ,
520+ paymaster_data : PaymasterData :: default ( ) ,
521+ nonce_data_availability_mode : DataAvailabilityMode :: default ( ) ,
522+ fee_data_availability_mode : DataAvailabilityMode :: default ( ) ,
523+ account_deployment_data : AccountDeploymentData :: default ( ) ,
524+ }
525+ }
526+
527+ pub fn to_syscall_result ( self ) -> Vec < Felt > {
528+ let expected_tx_info = vec ! [
529+ self . version. 0 ,
530+ * * self . account_address,
531+ self . max_fee. 0 . into( ) ,
532+ Felt :: ZERO ,
533+ self . transaction_hash. 0 ,
534+ Felt :: from_hex_unchecked( & self . chain_id. as_hex( ) ) ,
535+ self . nonce. 0 ,
536+ ] ;
537+
538+ let expected_resource_bounds = match self . resource_bounds {
539+ ValidResourceBounds :: L1Gas ( l1_gas) => vec ! [
540+ Felt :: ONE ,
541+ felt!( Resource :: L1Gas . to_hex( ) ) ,
542+ felt!( l1_gas. max_amount. 0 ) ,
543+ felt!( l1_gas. max_price_per_unit. 0 ) ,
544+ ] ,
545+ ValidResourceBounds :: AllResources ( AllResourceBounds {
546+ l1_gas,
547+ l2_gas,
548+ l1_data_gas,
549+ } ) => {
550+ vec ! [
551+ Felt :: THREE ,
552+ felt!( Resource :: L1Gas . to_hex( ) ) ,
553+ felt!( l1_gas. max_amount. 0 ) ,
554+ felt!( l1_gas. max_price_per_unit. 0 ) ,
555+ felt!( Resource :: L2Gas . to_hex( ) ) ,
556+ felt!( l2_gas. max_amount. 0 ) ,
557+ felt!( l2_gas. max_price_per_unit. 0 ) ,
558+ felt!( Resource :: L1DataGas . to_hex( ) ) ,
559+ felt!( l1_data_gas. max_amount. 0 ) ,
560+ felt!( l1_data_gas. max_price_per_unit. 0 ) ,
561+ ]
562+ }
563+ } ;
564+
565+ // Tip, Paymaster data, Nonce DA, Fee DA, Account data.
566+ let expected_unsupported_fields = vec ! [ Felt :: ZERO ; 5 ] ;
567+
568+ let expected_call_info =
569+ vec ! [ * * self . caller_address, * * self . contract_address, self . entry_point_selector. 0 ] ;
570+ let expected_block_info = vec ! [
571+ felt!( self . block_number. 0 ) ,
572+ felt!( self . block_timestamp. 0 ) ,
573+ * * self . sequencer_address,
574+ ] ;
575+
576+ [
577+ expected_block_info,
578+ expected_tx_info,
579+ expected_resource_bounds,
580+ expected_unsupported_fields,
581+ expected_call_info,
582+ ]
583+ . concat ( )
584+ }
585+ }
0 commit comments