Skip to content

Commit c1d4c9c

Browse files
starknet_os_flow_tests: implement FuzzCallInfo::new_call
1 parent 7a06a12 commit c1d4c9c

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

crates/starknet_os_flow_tests/src/fuzz_tests.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ struct FuzzCallInfo {
200200
pub inner_calls: Vec<FuzzCallInfo>,
201201
}
202202

203+
impl FuzzCallInfo {
204+
pub fn new_call(
205+
address: ContractAddress,
206+
class_hash: ClassHash,
207+
parent_failure_behavior: ParentFailureBehavior,
208+
) -> Self {
209+
Self { address, class_hash, parent_failure_behavior, inner_calls: vec![] }
210+
}
211+
}
212+
203213
/// Represents the call tree of a fuzz test.
204214
#[allow(dead_code)]
205215
struct FuzzTestManager {
@@ -268,13 +278,12 @@ impl FuzzTestManager {
268278
}
269279

270280
// First call is the orchestrator calling the first fuzz test contract.
271-
let first_call = FuzzCallInfo {
272-
address: cairo1_contract_address_a,
273-
class_hash: *CAIRO1_CONTRACT_CLASS_HASH,
281+
let first_call = FuzzCallInfo::new_call(
282+
cairo1_contract_address_a,
283+
*CAIRO1_CONTRACT_CLASS_HASH,
274284
// The orchestrator always starts the test in a catching context.
275-
parent_failure_behavior: ParentFailureBehavior::Cairo1Catching,
276-
inner_calls: vec![],
277-
};
285+
ParentFailureBehavior::Cairo1Catching,
286+
);
278287
Self {
279288
calls: vec![first_call],
280289
current_call: vec![0],
@@ -403,22 +412,20 @@ impl FuzzTestManager {
403412
FuzzOperationData::Call(call_operation_data) => {
404413
let address = *call_operation_data.address();
405414
let class_hash = *self.deployed_fuzz_contracts.get(&address).unwrap();
406-
self.current_fuzz_call_info_mut().inner_calls.push(FuzzCallInfo {
415+
self.current_fuzz_call_info_mut().inner_calls.push(FuzzCallInfo::new_call(
407416
address,
408417
class_hash,
409-
parent_failure_behavior: call_operation_data.parent_failure_behavior(),
410-
inner_calls: vec![],
411-
});
418+
call_operation_data.parent_failure_behavior(),
419+
));
412420
self.current_call.push(self.current_fuzz_call_info().inner_calls.len() - 1);
413421
}
414422
FuzzOperationData::LibraryCall(library_call_operation_data) => {
415423
let current_address = self.current_fuzz_call_info().address;
416-
self.current_fuzz_call_info_mut().inner_calls.push(FuzzCallInfo {
417-
address: current_address,
418-
class_hash: *library_call_operation_data.class_hash(),
419-
parent_failure_behavior: library_call_operation_data.parent_failure_behavior(),
420-
inner_calls: vec![],
421-
});
424+
self.current_fuzz_call_info_mut().inner_calls.push(FuzzCallInfo::new_call(
425+
current_address,
426+
*library_call_operation_data.class_hash(),
427+
library_call_operation_data.parent_failure_behavior(),
428+
));
422429
self.current_call.push(self.current_fuzz_call_info().inner_calls.len() - 1);
423430
}
424431
}

0 commit comments

Comments
 (0)