Skip to content
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

Meta: Unbundling the cheats from the assertions (leg 2) #127

Closed
PaulRBerg opened this issue Jul 15, 2022 · 1 comment
Closed

Meta: Unbundling the cheats from the assertions (leg 2) #127

PaulRBerg opened this issue Jul 15, 2022 · 1 comment

Comments

@PaulRBerg
Copy link
Contributor

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.

  1. The API is inconsistent. Users need to remember that certain cheats are available only via the vm variable, while others are to be found in the default namespace of Test. For example, vm.startPrank and changePrank.
  2. Namespace pollution. Users may prefer to implement their own versions of, say, the bound function. This is what happened in refactor: make bound internal virtual #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.

@PaulRBerg
Copy link
Contributor Author

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.

@ZeroEkkusu ZeroEkkusu mentioned this issue Jul 26, 2022
7 tasks
@ZeroEkkusu ZeroEkkusu closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants