mock_call
Mocks contract call to a function_selector
of a contract at the given address, for n_times
first calls that are made to the contract.
A call to function function_selector
will return data provided in ret_data
argument.
An address with no contract can be mocked as well.
An entrypoint that is not present on the deployed contract is also possible to mock.
Note that the function is not meant for mocking internal calls - it works only for contract
entry points.
contract_address
- target contract addressfunction_selector
- hashed name of the target function (can be obtained withselector!
macro)ret_data
- data to return by the functionfunction_selector
n_times
- number of calls to mock the function for
Fully qualified path: snforge_std::cheatcodes::mock_call
pub fn mock_call<T, impl TSerde: Serde<T>, impl TDestruct: Destruct<T>>(
contract_address: ContractAddress, function_selector: felt252, ret_data: T, n_times: u32,
)