@@ -28,7 +28,7 @@ use starknet_api::transaction::fields::{
2828 ResourceBounds ,
2929 ValidResourceBounds ,
3030} ;
31- use starknet_api:: { declare_tx_args, invoke_tx_args} ;
31+ use starknet_api:: { calldata , declare_tx_args, invoke_tx_args} ;
3232use starknet_committer:: block_committer:: input:: {
3333 StarknetStorageKey ,
3434 StarknetStorageValue ,
@@ -61,7 +61,7 @@ pub(crate) static NON_TRIVIAL_RESOURCE_BOUNDS: LazyLock<ValidResourceBounds> =
6161
6262#[ tokio:: test]
6363async fn test_initial_state_creation ( ) {
64- let _initial_state = create_default_initial_state_data :: < DictStateReader > ( ) . await ;
64+ let _initial_state = create_default_initial_state_data :: < DictStateReader , 0 > ( [ ] ) . await ;
6565}
6666
6767#[ rstest]
@@ -91,8 +91,8 @@ async fn declare_deploy_scenario(
9191 // Initialize the test manager with a default initial state and get the nonce manager to help
9292 // keep track of nonces.
9393
94- let ( mut test_manager, mut nonce_manager) =
95- TestManager :: < DictStateReader > :: new_with_default_initial_state ( ) . await ;
94+ let ( mut test_manager, mut nonce_manager, _ ) =
95+ TestManager :: < DictStateReader > :: new_with_default_initial_state ( [ ] ) . await ;
9696
9797 // Declare a test contract.
9898 let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
@@ -184,66 +184,15 @@ async fn trivial_diff_scenario(
184184 #[ values( false , true ) ] use_kzg_da : bool ,
185185 #[ values( false , true ) ] full_output : bool ,
186186) {
187- // TODO(Dori): Create a util to define an initial state with the test contract declared and
188- // deployed. The address of the test contract should be part of the initial state data.
189-
190187 // Initialize the test manager with a default initial state and get the nonce manager to help
191188 // keep track of nonces.
192189
193- let ( mut test_manager, mut nonce_manager) =
194- TestManager :: < DictStateReader > :: new_with_default_initial_state ( ) . await ;
195-
196- // Declare and deploy a test contract.
197- let test_contract = FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ;
198- let test_contract_sierra = test_contract. get_sierra ( ) ;
199- let class_hash = test_contract_sierra. calculate_class_hash ( ) ;
200- let compiled_class_hash = test_contract. get_compiled_class_hash ( & HashVersion :: V2 ) ;
201- let declare_tx_args = declare_tx_args ! {
202- sender_address: * FUNDED_ACCOUNT_ADDRESS ,
203- class_hash,
204- compiled_class_hash,
205- resource_bounds: * NON_TRIVIAL_RESOURCE_BOUNDS ,
206- nonce: nonce_manager. next( * FUNDED_ACCOUNT_ADDRESS ) ,
207- } ;
208- let account_declare_tx = declare_tx ( declare_tx_args) ;
209- let class_info = get_class_info_of_feature_contract ( test_contract) ;
210- let tx =
211- DeclareTransaction :: create ( account_declare_tx, class_info, & CHAIN_ID_FOR_TESTS ) . unwrap ( ) ;
212- // Add the transaction to the test manager.
213- test_manager. add_cairo1_declare_tx ( tx, & test_contract_sierra) ;
214- let arg1 = Felt :: from ( 7 ) ;
215- let arg2 = Felt :: from ( 90 ) ;
216- // Deploy the test contract using the deploy contract syscall.
217- let constructor_calldata = [
218- 2 . into ( ) , // constructor length
219- arg1,
220- arg2,
221- ] ;
222- let contract_address_salt = ContractAddressSalt ( Felt :: ONE ) ;
223- let calldata: Vec < _ > =
224- [ class_hash. 0 , contract_address_salt. 0 ] . into_iter ( ) . chain ( constructor_calldata) . collect ( ) ;
225- let deploy_contract_calldata = create_calldata (
226- * FUNDED_ACCOUNT_ADDRESS ,
227- DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME ,
228- & calldata,
229- ) ;
230- let invoke_tx_args = invoke_tx_args ! {
231- sender_address: * FUNDED_ACCOUNT_ADDRESS ,
232- nonce: nonce_manager. next( * FUNDED_ACCOUNT_ADDRESS ) ,
233- calldata: deploy_contract_calldata,
234- resource_bounds: * NON_TRIVIAL_RESOURCE_BOUNDS ,
235- } ;
236- let test_contract_address = calculate_contract_address (
237- contract_address_salt,
238- class_hash,
239- & Calldata ( constructor_calldata[ 1 ..] . to_vec ( ) . into ( ) ) ,
240- * FUNDED_ACCOUNT_ADDRESS ,
241- )
242- . unwrap ( ) ;
243- let deploy_contract_tx = invoke_tx ( invoke_tx_args) ;
244- let deploy_contract_tx =
245- InvokeTransaction :: create ( deploy_contract_tx, & CHAIN_ID_FOR_TESTS ) . unwrap ( ) ;
246- test_manager. add_invoke_tx ( deploy_contract_tx) ;
190+ let ( mut test_manager, mut nonce_manager, [ test_contract_address] ) =
191+ TestManager :: < DictStateReader > :: new_with_default_initial_state ( [ (
192+ FeatureContract :: TestContract ( CairoVersion :: Cairo1 ( RunnableCairo1 :: Casm ) ) ,
193+ calldata ! [ Felt :: ONE , Felt :: TWO ] ,
194+ ) ] )
195+ . await ;
247196
248197 let key = Felt :: from ( 10u8 ) ;
249198 let value = Felt :: from ( 11u8 ) ;
@@ -280,15 +229,9 @@ async fn trivial_diff_scenario(
280229 )
281230 . await ;
282231
283- // Explicitly check the storage updates (not just inclusion) to make sure the key has no diff.
284- // Only storage update expected is due to the constructor call.
285- let expected_test_contract_storage_updates = HashMap :: from ( [ (
286- StarknetStorageKey ( get_storage_var_address ( "my_storage_var" , & [ ] ) ) ,
287- StarknetStorageValue ( arg1 + arg2) ,
288- ) ] ) ;
289- assert_eq ! (
290- test_output. decompressed_state_diff. storage_updates. get( & test_contract_address) . unwrap( ) ,
291- & expected_test_contract_storage_updates
232+ // Explicitly check the test contract has no storage update.
233+ assert ! (
234+ !test_output. decompressed_state_diff. storage_updates. contains_key( & test_contract_address)
292235 ) ;
293236
294237 let perform_global_validations = true ;
0 commit comments