-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Investigation]: expect_call
-like Assertion(s)
#36
Comments
Why we cannot test it with current setup? Check that transaction failed and assert that balance hasn't changed more than expected? |
This was an idea I had at the time that I wanted to document. I don't see it as a "must have" in motsu, but a "nice to have", a utility to be used by devs who wanted to ensure certain function calls are called or that they cannot be called some number of times. Anyway, maybe instead of testing for reentrancy directly, motsu could provide an assertion that a specific contract function call has occurred? This would be a general assert method and reentrant calls would be covered by it, so that we wouldn't need reentrant-specific assertions 🤔 Solidity Foundry has expectCall that does this. I think even this more general Though because implementing this would require yet a new refactor of motsu (*sarcasticly* yippee), we could leave the issue in the backlog and on low priority until:
|
Yeah. If I understand correctly we're checking, that re-entrant call would fail. In case of e2e tests we would implement it with deployed mock attacker contract. That is not an actual attacker, but it contains assertion (will change state) in case it can successfully perform reentrant call and drain funds. We can do same in motsu. Also I see the whole "practical" problem with reentrancy is cause vulnerable contract can lose funds. So asserting that no fund loss happened after reentrant call seems reasonable to me. |
expect_call
-like Pattern Assertions
expect_call
-like Pattern Assertionsexpect_call
-like Assertion(s)
Considering the low priority of this feature, I'd say we should leave it in the backlog just for tracking, but focus on it if there's actual interest from motsu users |
What is the feature you would like to see?
Something similar to Foundry's expectCall.
Contribution Guidelines
The text was updated successfully, but these errors were encountered: