Skip to content

Commit

Permalink
change default to func
Browse files Browse the repository at this point in the history
  • Loading branch information
piotmag769 committed Apr 16, 2024
1 parent 7554386 commit 4d5cb9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ pub enum CallResult {
Failure(CallFailure),
}

impl Default for CallResult {
fn default() -> Self {
Self::Failure(CallFailure::Error { msg: String::new() })
}
}

/// Enum representing possible call failure and its type.
/// `Panic` - Recoverable, meant to be caught by the user.
/// `Error` - Unrecoverable, equivalent of panic! in rust.
Expand Down
20 changes: 16 additions & 4 deletions crates/cheatnet/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ impl<T> CheatStatus<T> {
}

/// Tree structure representing trace of a call.
#[derive(Default)]
pub struct CallTrace {
pub entry_point: CallEntryPoint,
// These also include resources used by internal calls
Expand All @@ -161,6 +160,20 @@ pub struct CallTrace {
pub vm_trace: Option<Vec<TraceEntry>>,
}

impl CallTrace {
fn default_successful_call() -> Self {
Self {
entry_point: Default::default(),
used_execution_resources: Default::default(),
used_l1_resources: Default::default(),
used_syscalls: Default::default(),
nested_calls: vec![],
result: CallResult::Success { ret_data: vec![] },
vm_trace: None,
}
}
}

/// Enum representing node of a trace of a call.
#[derive(Clone)]
pub enum CallTraceNode {
Expand Down Expand Up @@ -278,8 +291,7 @@ impl Default for CheatnetState {
test_code_entry_point.class_hash = Some(class_hash!(TEST_CONTRACT_CLASS_HASH));
let test_call = Rc::new(RefCell::new(CallTrace {
entry_point: test_code_entry_point,
result: CallResult::Success { ret_data: vec![] },
..Default::default()
..CallTrace::default_successful_call()
}));
Self {
rolled_contracts: Default::default(),
Expand Down Expand Up @@ -411,7 +423,7 @@ impl TraceData {
) {
let new_call = Rc::new(RefCell::new(CallTrace {
entry_point,
..Default::default()
..CallTrace::default_successful_call()
}));
let current_call = self.current_call_stack.top();

Expand Down

0 comments on commit 4d5cb9b

Please sign in to comment.