Added startPrank()
and stopPrank()
cheatcodes to hevm.
#495
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added
startPrank()
andstopPrank()
cheatcodes to hevm.This should assist in testing smart contracts when using tools that rely on
hevm
such as Echidna or Medusa.Auditors are creating complex proxy patterns to do external testing of contracts using tools such as Echidna / Medusa: How to set up Multi Actor Invariant Testing
Note Alex The Entrepenerd's response in Discord stating
startPrank()
would eliminate the need for this testing pattern: link to discord conversationTesting
Tested locally with
Look for tests
prove_startPrank(address)
andprove_startPrank_val()
Checklist
Additional Notes
Edge cases such as stacks of startPrank() were not tested/considered.
For example, this code will not work - although I am unsure how this operates in Foundry anyway.
While untested, I would expect:
code 1
to havemsg.sender = default
code 2
to havemsg.sender = address1
code 3
to havemsg.sender = address2
code 4
to havemsg.sender = default
code 5
to havemsg.sender = default
I have never written code in Haskell before nor do I have experience with this codebase, please let me know if there are edge cases to consider or any other styling I should do to conform to this repo's standards.