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

Commit c90c46b

Browse files
authored
include entry point selector in error (#1251)
1 parent d011ebe commit c90c46b

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src/execution/execution_entry_point.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ impl ExecutionEntryPoint {
269269
entry_point
270270
.or(default_entry_point)
271271
.cloned()
272-
.ok_or(TransactionError::EntryPointNotFound)
272+
.ok_or(TransactionError::EntryPointNotFound(
273+
self.entry_point_selector,
274+
))
273275
}
274276

275277
// Returns the entry point with selector corresponding with self.entry_point_selector, or the
@@ -302,7 +304,9 @@ impl ExecutionEntryPoint {
302304
entry_point
303305
.or(default_entry_point)
304306
.cloned()
305-
.ok_or(TransactionError::EntryPointNotFound)
307+
.ok_or(TransactionError::EntryPointNotFound(
308+
self.entry_point_selector,
309+
))
306310
}
307311

308312
/// Constructs a CallInfo object for deprecated contract classes.

src/transaction/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ pub enum TransactionError {
8080
NotDeployedContract(ClassHash),
8181
#[error("Non-unique entry points are not possible in a ContractClass object")]
8282
NonUniqueEntryPoint,
83-
#[error("Requested entry point was not found")]
84-
EntryPointNotFound,
83+
#[error("Requested entry point with selector {0:#x} was not found")]
84+
EntryPointNotFound(Felt252),
8585
#[error("Ptr result diverges after calculating final stacks")]
8686
OsContextPtrNotEqual,
8787
#[error("Empty OS context")]

src/transaction/invoke_function.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ mod tests {
950950
assert!(expected_error.is_err());
951951
assert_matches!(
952952
expected_error.unwrap_err(),
953-
TransactionError::EntryPointNotFound
953+
TransactionError::EntryPointNotFound(_)
954954
);
955955
}
956956

@@ -1402,9 +1402,11 @@ mod tests {
14021402

14031403
#[test]
14041404
fn test_reverted_transaction_wrong_entry_point() {
1405+
let entry_point_selector = Felt252::from_bytes_be(&calculate_sn_keccak(b"factorial_"));
1406+
14051407
let internal_invoke_function = InvokeFunction {
14061408
contract_address: Address(0.into()),
1407-
entry_point_selector: Felt252::from_bytes_be(&calculate_sn_keccak(b"factorial_")),
1409+
entry_point_selector,
14081410
entry_point_type: EntryPointType::External,
14091411
calldata: vec![],
14101412
tx_type: TransactionType::InvokeFunction,
@@ -1466,7 +1468,9 @@ mod tests {
14661468
assert!(result.call_info.is_none());
14671469
assert_eq!(
14681470
result.revert_error,
1469-
Some("Requested entry point was not found".to_string())
1471+
Some(format!(
1472+
"Requested entry point with selector {entry_point_selector:#x} was not found"
1473+
))
14701474
);
14711475
assert_eq_sorted!(
14721476
state.cache.class_hash_writes,

tests/integration_tests/internals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ fn test_invoke_tx_wrong_entrypoint() {
22082208
);
22092209

22102210
// Assert error
2211-
assert_matches!(result, Err(TransactionError::EntryPointNotFound));
2211+
assert_matches!(result, Err(TransactionError::EntryPointNotFound(_)));
22122212
}
22132213

22142214
#[test]

0 commit comments

Comments
 (0)