feat: add count to expectCall cheatcodes#4833
Conversation
696a99b to
2e85835
Compare
|
Adding cheatcodes to |
| /// The number of times the call is expected to be made | ||
| pub count: u64, |
There was a problem hiding this comment.
I can see how this could be useful
|
Yep in favor of this, per #509 (comment). We should also add a similar overload for Also @reubenr0d two questions:
|
|
It looks like the regular I'm not sure if this was intentional, but personally I'm ok with this change. Curious to hear your thoughts here @reubenr0d @mattsse. If we keep it, @reubenr0d do you mind getting another PR in to forge-std to update the code comments in |
|
Just to chime in: we were using expectCall to generically verify all functions from our ABI had been called in a test with code similar to: With the new API we cannot do this entirely generically since some functions will be invoked multiple times. I am OK with the change, just wanted to mention it :) |
|
Hmm, on second thought and on seeing that other might have issues with this, I think it's best we preserve compatibility. I'll push a fix for this shortly. |
|
If I put 10 expectCalls, would it expect 10 calls? I.e. do they sum up if I add more expectCall lines? Cause that's what I was thinking how it works and had several expectCalls lines if I expected several (identical) calls. But now it fails after I've upgraded. So should I just leave one expectCall put a number there now? |
It should definitely work like this. See @reubenr0d's comment here: |
Closes #4513
Motivation
Currently we can only assert that a call is made to a function using expectCall(), it would be nice to have another cheatcode to check the number of time a call was made, which can also be useful to assert if a call is not made.
Solution
Overriding the
expectCallcheatcodes to also accept the number of times it is expected to be called and enforce the same.