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,
) -> Result
Expand description
Handles expected calls specified by the expectCall
cheatcodes.
It can handle calls in two ways:
- If the cheatcode was used with a
count
argument, it will expect the call to be made exactlycount
times. e.g.vm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f), 4)
will expect the call to address(0xc4f3) with selector0xd34db33f
to be made exactly 4 times. If the amount of calls is less or more than 4, the test will fail. Note that thecount
argument cannot be overwritten with anothervm.expectCall
. If this is attempted,expectCall
will revert. - If the cheatcode was used without a
count
argument, it will expect the call to be made at least the amount of times the cheatcode was called. This means thatvm.expectCall
without a count argument can be called many times, but cannot be called with acount
argument after it was called without one. If the latter happens,expectCall
will revert. e.gvm.expectCall(address(0xc4f3), abi.encodeWithSelector(0xd34db33f))
will expect the call to address(0xc4f3) and selector0xd34db33f
to 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.