fn expect_call(
state: &mut Cheatcodes,
target: &Address,
calldata: &Bytes,
value: Option<&U256>,
gas: Option<u64>,
min_gas: Option<u64>,
count: u64,
call_type: ExpectedCallType,
) -> ResultExpand description
Handles expected calls specified by the expectCall cheatcodes.
It can handle calls in two ways:
- If the cheatcode was used with a
countargument, it will expect the call to be made exactlycounttimes. e.g.vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)will expect the call to address(0xc4f3) with selector0xd34db33fto be made exactly 4 times. If the amount of calls is less or more than 4, the test will fail. Note that thecountargument cannot be overwritten with anothervm.expectCall. If this is attempted,expectCallwill revert. - If the cheatcode was used without a
countargument, it will expect the call to be made at least the amount of times the cheatcode was called. This means thatvm.expectCallwithout a count argument can be called many times, but cannot be called with acountargument after it was called without one. If the latter happens,expectCallwill revert. e.gvm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f))will expect the call to address(0xc4f3) and selector0xd34db33fto be made at least once. If the amount of calls is 0, the test will fail. If the call is made more than once, the test will pass.