Skip to content

Commit

Permalink
Add empty calldata when no constructor validation (#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnordelo authored Jul 16, 2023
1 parent ceef655 commit 5134fd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion crates/cairo-lang-runner/src/casm_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,10 @@ impl<'a> CairoHintProcessor<'a> {
fail_syscall!(revert_reason, b"CONSTRUCTOR_FAILED");
}
}
} else {
} else if calldata.is_empty() {
(Relocatable::from((0, 0)), Relocatable::from((0, 0)))
} else {
fail_syscall!(b"INVALID_CALLDATA_LEN");
};

// Set the class hash of the deployed contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,23 @@ mod contract_failed_entrypoint {

#[test]
#[available_gas(30000000)]
#[should_panic(expected: ('Failure', 'ENTRYPOINT_FAILED', ))]
fn test_entrypoint_failed() {
let (address0, _) = deploy_syscall(
fn test_non_empty_calldata_unexistent_constructor() {
let mut err = deploy_syscall(
contract_failed_entrypoint::TEST_CLASS_HASH.try_into().unwrap(),
0,
array![100].span(),
false
)
.unwrap_err();
assert_eq(@err.pop_front().unwrap(), @'INVALID_CALLDATA_LEN', 'err == "INVALID_CALLDATA_LEN"');
}

#[test]
#[available_gas(30000000)]
#[should_panic(expected: ('Failure', 'ENTRYPOINT_FAILED', ))]
fn test_entrypoint_failed() {
let (address0, _) = deploy_syscall(
contract_failed_entrypoint::TEST_CLASS_HASH.try_into().unwrap(), 0, array![].span(), false
)
.unwrap();
let mut contract = IContractDispatcher { contract_address: address0 };
Expand Down

0 comments on commit 5134fd1

Please sign in to comment.