@@ -58,6 +58,7 @@ use starknet_api::transaction::fields::{
5858 ContractAddressSalt ,
5959 Fee ,
6060 ProofFacts ,
61+ ProofVersion ,
6162 ResourceBounds ,
6263 Tip ,
6364 TransactionSignature ,
@@ -91,6 +92,7 @@ use starknet_os::hints::hint_implementation::deprecated_compiled_class::class_ha
9192use starknet_os:: hints:: vars:: Const ;
9293use starknet_types_core:: felt:: Felt ;
9394use starknet_types_core:: hash:: { Pedersen , StarkHash } ;
95+ use strum:: IntoEnumIterator ;
9496
9597use crate :: initial_state:: {
9698 create_default_initial_state_data,
@@ -3019,3 +3021,43 @@ async fn test_get_block_hash_current_block_number() {
30193021 let test_output = test_builder. build_and_run ( ) . await ;
30203022 test_output. perform_default_validations ( ) ;
30213023}
3024+
3025+ /// Verifies the OS accepts an invoke with `proof_facts` for every supported
3026+ /// proof version and for every allowed virtual-OS program hash.
3027+ #[ rstest]
3028+ #[ tokio:: test]
3029+ async fn test_proof_facts_versions_and_program_hashes ( ) {
3030+ let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
3031+ let ( mut test_builder, [ test_contract_address] ) =
3032+ TestBuilder :: create_standard ( [ ( test_contract, calldata ! [ Felt :: ZERO , Felt :: ZERO ] ) ] ) . await ;
3033+ let config_hash = test_builder. compute_virtual_os_config_hash ( ) ;
3034+ let allowed_program_hashes = VersionedConstants :: latest_constants ( )
3035+ . os_constants
3036+ . allowed_virtual_os_program_hashes
3037+ . clone ( ) ;
3038+ let calldata = create_calldata ( test_contract_address, "empty_function" , & [ ] ) ;
3039+ let reference_program_hash =
3040+ * allowed_program_hashes. first ( ) . expect ( "expected at least one allowed program hash" ) ;
3041+ let reference_proof_version =
3042+ ProofVersion :: iter ( ) . next ( ) . expect ( "ProofVersion must have at least one variant" ) ;
3043+
3044+ // Cover every allowed program hash (with a fixed proof version).
3045+ for program_hash in & allowed_program_hashes {
3046+ let mut proof_facts =
3047+ ProofFacts :: custom_proof_facts_for_testing ( * program_hash, config_hash) ;
3048+ Arc :: make_mut ( & mut proof_facts. 0 ) [ 0 ] = reference_proof_version. as_felt ( ) ;
3049+ test_builder
3050+ . add_funded_account_invoke ( invoke_tx_args ! { calldata: calldata. clone( ) , proof_facts } ) ;
3051+ }
3052+
3053+ // Cover every proof version (with a fixed program hash).
3054+ for proof_version in ProofVersion :: iter ( ) {
3055+ let mut proof_facts =
3056+ ProofFacts :: custom_proof_facts_for_testing ( reference_program_hash, config_hash) ;
3057+ Arc :: make_mut ( & mut proof_facts. 0 ) [ 0 ] = proof_version. as_felt ( ) ;
3058+ test_builder
3059+ . add_funded_account_invoke ( invoke_tx_args ! { calldata: calldata. clone( ) , proof_facts } ) ;
3060+ }
3061+
3062+ test_builder. build_and_run ( ) . await . perform_default_validations ( ) ;
3063+ }
0 commit comments