Hook to run functions after invariant test run
- Dominant language
- Haskell
- Stars
- 3.2k
- Forks
- 432
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 5
Description
### Describe the desired feature
Foundry allows defining a function `afterInvariant` that runs after invariant tests. It's briefly mentioned in the docs on [this page](https://getfoundry.sh/forge/advanced-testing/invariant-testing/).
We're [using ](https://github.com/EspressoSystems/espresso-network/blob/c66c977dbc5dc2f40156d40129b66725919c8c93/contracts/test/StakeTableV2.invariant.t.sol#L31) it to run print some stats, run some extra asserts that are slow to run and to withdraw all funds from a contract to ensure all users can withdraw what they own.
I couldn't find such functionality in echidna so currently I'm skipping it for [our echidna test](https://github.com/EspressoSystems/espresso-network/blob/29beb4e68ec59f342048454c9c8d0b5331d71b9f/contracts/test/StakeTableV2.echidna.sol#L33). Is it currently possible to do something along those lines? If not, is this a feature you could consider adding?
Contributor guide
Research direction
Start with the invariant-testing documentation and the linked StakeTableV2.invariant.t.sol and StakeTableV2.echidna.sol examples to understand the requested afterInvariant behavior. Then locate Echidna's invariant test execution path and determine where a post-run hook could be exposed. Done means documenting whether the behavior is possible or adding a tested hook that runs after invariant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell, solidity
- Domain
- security, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100