@@ -5,7 +5,7 @@ use indexmap::{indexmap, IndexMap};
55use pretty_assertions:: assert_eq;
66use rstest:: rstest;
77use starknet_api:: block:: BlockNumber ;
8- use starknet_api:: core:: { ClassHash , ContractAddress , Nonce } ;
8+ use starknet_api:: core:: { ClassHash , CompiledClassHash , ContractAddress , Nonce } ;
99use starknet_api:: deprecated_contract_class:: ContractClass as DeprecatedContractClass ;
1010use starknet_api:: hash:: StarkHash ;
1111use starknet_api:: state:: { SierraContractClass , StateNumber , StorageKey , ThinStateDiff } ;
@@ -1096,3 +1096,36 @@ scan_cases!(
10961096 ) ;
10971097 }
10981098) ;
1099+
1100+ scan_cases ! (
1101+ key_macro = class_hash,
1102+ value_macro = compiled_class_hash,
1103+ fn test_scan_compiled_class_hashes_in_range(
1104+ #[ case] start: ClassHash ,
1105+ #[ case] end: ClassHash ,
1106+ #[ case] block_target: BlockNumber ,
1107+ #[ case] limit: usize ,
1108+ #[ case] expected: Vec <( ClassHash , CompiledClassHash ) >,
1109+ ) {
1110+ let ( ( reader, mut writer) , _temp_dir) = get_test_storage( ) ;
1111+ write_two_block_state_diffs(
1112+ & mut writer,
1113+ ThinStateDiff {
1114+ class_hash_to_compiled_class_hash: block_0_entries!( ) ,
1115+ ..Default :: default ( )
1116+ } ,
1117+ ThinStateDiff {
1118+ class_hash_to_compiled_class_hash: block_1_entries!( ) ,
1119+ ..Default :: default ( )
1120+ } ,
1121+ ) ;
1122+ let txn = reader. begin_ro_txn( ) . unwrap( ) ;
1123+ let state_reader = txn. get_state_reader( ) . unwrap( ) ;
1124+ assert_eq!(
1125+ state_reader
1126+ . scan_compiled_class_hashes_in_range( start, end, block_target, limit)
1127+ . unwrap( ) ,
1128+ expected,
1129+ ) ;
1130+ }
1131+ ) ;
0 commit comments