Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
include entry point selector in error (#1251)
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy authored Mar 18, 2024
1 parent d011ebe commit c90c46b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/execution/execution_entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ impl ExecutionEntryPoint {
entry_point
.or(default_entry_point)
.cloned()
.ok_or(TransactionError::EntryPointNotFound)
.ok_or(TransactionError::EntryPointNotFound(
self.entry_point_selector,
))
}

// Returns the entry point with selector corresponding with self.entry_point_selector, or the
Expand Down Expand Up @@ -302,7 +304,9 @@ impl ExecutionEntryPoint {
entry_point
.or(default_entry_point)
.cloned()
.ok_or(TransactionError::EntryPointNotFound)
.ok_or(TransactionError::EntryPointNotFound(
self.entry_point_selector,
))
}

/// Constructs a CallInfo object for deprecated contract classes.
Expand Down
4 changes: 2 additions & 2 deletions src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pub enum TransactionError {
NotDeployedContract(ClassHash),
#[error("Non-unique entry points are not possible in a ContractClass object")]
NonUniqueEntryPoint,
#[error("Requested entry point was not found")]
EntryPointNotFound,
#[error("Requested entry point with selector {0:#x} was not found")]
EntryPointNotFound(Felt252),
#[error("Ptr result diverges after calculating final stacks")]
OsContextPtrNotEqual,
#[error("Empty OS context")]
Expand Down
10 changes: 7 additions & 3 deletions src/transaction/invoke_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ mod tests {
assert!(expected_error.is_err());
assert_matches!(
expected_error.unwrap_err(),
TransactionError::EntryPointNotFound
TransactionError::EntryPointNotFound(_)
);
}

Expand Down Expand Up @@ -1402,9 +1402,11 @@ mod tests {

#[test]
fn test_reverted_transaction_wrong_entry_point() {
let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"factorial_"));

let internal_invoke_function = InvokeFunction {
contract_address: Address(0.into()),
entry_point_selector: Felt252::from_bytes_be(&calculate_sn_keccak(b"factorial_")),
entry_point_selector,
entry_point_type: EntryPointType::External,
calldata: vec![],
tx_type: TransactionType::InvokeFunction,
Expand Down Expand Up @@ -1466,7 +1468,9 @@ mod tests {
assert!(result.call_info.is_none());
assert_eq!(
result.revert_error,
Some("Requested entry point was not found".to_string())
Some(format!(
"Requested entry point with selector {entry_point_selector:#x} was not found"
))
);
assert_eq_sorted!(
state.cache.class_hash_writes,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ fn test_invoke_tx_wrong_entrypoint() {
);

// Assert error
assert_matches!(result, Err(TransactionError::EntryPointNotFound));
assert_matches!(result, Err(TransactionError::EntryPointNotFound(_)));
}

#[test]
Expand Down

0 comments on commit c90c46b

Please sign in to comment.