@@ -173,6 +173,16 @@ struct FuzzCallInfo {
173173 pub inner_calls : Vec < FuzzCallInfo > ,
174174}
175175
176+ impl FuzzCallInfo {
177+ pub fn new_call (
178+ address : ContractAddress ,
179+ class_hash : ClassHash ,
180+ parent_failure_behavior : ParentFailureBehavior ,
181+ ) -> Self {
182+ Self { address, class_hash, parent_failure_behavior, inner_calls : vec ! [ ] }
183+ }
184+ }
185+
176186/// Represents the call tree of a fuzz test.
177187struct FuzzTestManager {
178188 /// The call tree of the fuzz test.
@@ -260,13 +270,12 @@ impl FuzzTestManager {
260270 }
261271
262272 // First call is the orchestrator calling the first fuzz test contract.
263- let first_call = FuzzCallInfo {
264- address : cairo1_contract_address_a,
265- class_hash : cairo1_contract_class_hash,
273+ let first_call = FuzzCallInfo :: new_call (
274+ cairo1_contract_address_a,
275+ cairo1_contract_class_hash,
266276 // The orchestrator always starts the test in a catching context.
267- parent_failure_behavior : ParentFailureBehavior :: Cairo1Catching ,
268- inner_calls : vec ! [ ] ,
269- } ;
277+ ParentFailureBehavior :: Cairo1Catching ,
278+ ) ;
270279 Self {
271280 calls : vec ! [ first_call] ,
272281 current_call : vec ! [ 0 ] ,
@@ -397,22 +406,20 @@ impl FuzzTestManager {
397406 FuzzOperationData :: Call ( call_operation_data) => {
398407 let address = * call_operation_data. address ( ) ;
399408 let class_hash = * self . deployed_fuzz_contracts . get ( & address) . unwrap ( ) ;
400- self . current_fuzz_call_info_mut ( ) . inner_calls . push ( FuzzCallInfo {
409+ self . current_fuzz_call_info_mut ( ) . inner_calls . push ( FuzzCallInfo :: new_call (
401410 address,
402411 class_hash,
403- parent_failure_behavior : call_operation_data. parent_failure_behavior ( ) ,
404- inner_calls : vec ! [ ] ,
405- } ) ;
412+ call_operation_data. parent_failure_behavior ( ) ,
413+ ) ) ;
406414 self . current_call . push ( self . current_fuzz_call_info ( ) . inner_calls . len ( ) - 1 ) ;
407415 }
408416 FuzzOperationData :: LibraryCall ( library_call_operation_data) => {
409417 let current_address = self . current_fuzz_call_info ( ) . address ;
410- self . current_fuzz_call_info_mut ( ) . inner_calls . push ( FuzzCallInfo {
411- address : current_address,
412- class_hash : * library_call_operation_data. class_hash ( ) ,
413- parent_failure_behavior : library_call_operation_data. parent_failure_behavior ( ) ,
414- inner_calls : vec ! [ ] ,
415- } ) ;
418+ self . current_fuzz_call_info_mut ( ) . inner_calls . push ( FuzzCallInfo :: new_call (
419+ current_address,
420+ * library_call_operation_data. class_hash ( ) ,
421+ library_call_operation_data. parent_failure_behavior ( ) ,
422+ ) ) ;
416423 self . current_call . push ( self . current_fuzz_call_info ( ) . inner_calls . len ( ) - 1 ) ;
417424 }
418425 }
0 commit comments