Meta: Unbundling the cheats from the assertions (leg 2)
Description
This is the 2nd leg of my proposal to unbundle the cheats from the assertions. Here I'll assume that you have read the 1st leg.
The fact that the custom cheats are added in the same namespace as the testing assertions has two inconveniences.
- The API is inconsistent. Users need to remember that certain cheats are available only via the
vmvariable, while others are to be found in the default namespace ofTest. For example,vm.startPrankandchangePrank. - Namespace pollution. Users may prefer to implement their own versions of, say, the bound function. This is what happened in https://github.com/foundry-rs/forge-std/pull/92.
Solution
Instead of inheriting from Cheats in Test, we create an instance of Cheats in Test:
contract Test {
Cheats internal cheats;
}
The vm would have to be re-instantiated in Test, but IMO that's a fair price to pay.
This way, users would know that all custom cheats offered by Forge Std are available only via cheats, and the namespace would be tidier.
I have begun working on this on the refactor-cheats-2 branch of my fork, but it's not done yet (I couldn't get the prank tests to pass). Happy to open a PR so we can discuss the issues I stumbled upon if there is interest for making this proposed change.