@@ -149,6 +149,7 @@ pub fn append_fact_topologies(
149149 Ok ( ( ) )
150150}
151151
152+ // TODO(idanh): can't find this hint anywhere in the starkware main repo, consider removing it.
152153/// Implements
153154/// # Validate hash.
154155/// from starkware.cairo.bootloaders.hash_program import compute_program_hash_chain
@@ -202,6 +203,7 @@ pub const ALL_BUILTINS: [BuiltinName; 11] = [
202203 BuiltinName :: mul_mod,
203204] ;
204205
206+ // TODO(idanh): This function seems to be unused, consider removing it.
205207fn check_cairo_pie_builtin_usage (
206208 vm : & mut VirtualMachine ,
207209 builtin_name : & BuiltinName ,
@@ -509,6 +511,7 @@ pub fn execute_task_exit_scope(
509511 Ok ( HintExtension :: default ( ) )
510512}
511513
514+ // TODO(idanh): can't find this hint anywhere in the starkware main repo, consider removing it.
512515/// Implements
513516/// # Validate hash.
514517/// from starkware.cairo.bootloaders.hash_program import compute_program_hash_chain
@@ -585,11 +588,13 @@ mod tests {
585588 use super :: * ;
586589 use crate :: hints:: codes:: * ;
587590 use crate :: hints:: types:: { Cairo0Executable , Task } ;
588- use crate :: test_utils:: prepare_vm_for_load_program_loading_test;
589591 use crate :: test_utils:: { get_hint_codes_at_pc, prepare_non_continuous_ids_data_for_test} ;
592+ use crate :: test_utils:: { prepare_ids_data_for_test, prepare_vm_for_load_program_loading_test} ;
593+ use cairo_lang_casm:: ap_change;
590594 use cairo_vm:: any_box;
591595 use cairo_vm:: hint_processor:: builtin_hint_processor:: builtin_hint_processor_definition:: HintProcessorData ;
592596 use cairo_vm:: hint_processor:: hint_processor_definition:: HintProcessorLogic ;
597+ use cairo_vm:: types:: exec_scope;
593598 use cairo_vm:: vm:: runners:: builtin_runner:: BuiltinRunner ;
594599 use cairo_vm:: vm:: runners:: cairo_pie:: PublicMemoryPage ;
595600 use rstest:: { fixture, rstest} ;
@@ -1108,5 +1113,29 @@ mod tests {
11081113 assert_eq ! ( n_selected_builtins, n_builtins) ;
11091114 }
11101115
1111- //TODO(Idanh): Add tests for the untested hints in this file.
1116+ #[ rstest( use_prev_hash, case( 0 ) , case( 1 ) ) ]
1117+ fn test_determine_use_prev_hash ( use_prev_hash : i32 ) {
1118+ // This test checks that the determine_use_prev_hash hint works correctly.
1119+ // It sets up the VM state to before the hint is called, and checks that
1120+ // the use_prev_hash variable is set correctly after the hint is called in the VM's memory.
1121+ let mut vm = VirtualMachine :: new ( false , false ) ;
1122+ vm. add_memory_segment ( ) ;
1123+ vm. add_memory_segment ( ) ;
1124+ vm. set_fp ( 1 ) ;
1125+ vm. set_ap ( 1 ) ;
1126+ let mut exec_scopes = ExecutionScopes :: new ( ) ;
1127+ exec_scopes. insert_value ( vars:: USE_PREV_HASH , use_prev_hash) ;
1128+ let ids_data = prepare_ids_data_for_test ( & [ "use_prev_hash" ] ) ;
1129+ let ap_tracking = ApTracking :: new ( ) ;
1130+ determine_use_prev_hash ( & mut vm, & mut exec_scopes, & ids_data, & ap_tracking)
1131+ . expect ( "Hint failed unexpectedly" ) ;
1132+
1133+ // Check that the use_prev_hash variable is set correctly in the execution scope
1134+ assert_eq ! (
1135+ vm. get_integer( Relocatable :: from( ( 1 , 0 ) ) )
1136+ . unwrap( )
1137+ . into_owned( ) ,
1138+ Felt252 :: from( use_prev_hash)
1139+ ) ;
1140+ }
11121141}
0 commit comments