-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(cheatcodes
): add ability to exclude certain custom errors and revert reason strings from failing tests
#4271
Comments
For the time being, PSA: The general request is still relevant so leaving the ticket open |
cheatcodes
): add ability to exclude certain custom errors and revert reason strings from failing tests
Interested in take a stab at this! |
assigned! |
@PaulRBerg have you run into the scenario where you might want to toss-out multiple kinds of reverts for the same external call (while surfacing others)? Considering adding that functionality. |
@emo-eth I have. I think this is what I was trying to get at with the OP — reverts due to USDC blacklisted addresses should be ignored. |
@PaulRBerg Sorry, to be more specific, I mean multiple kinds of errors with different data, to cover a set of anticipated & acceptable revert reasons that might arise from one specific call. Think I have that working either way, but curious if you've run into that scenario. |
I don't think I have. |
@PaulRBerg @mds1 as proposed in PR #9179 here are the cheatcodes planned to be added, mind to review / share thoughts? thanks /// Discard this run's fuzz inputs and generate new ones if next call reverted with data starting with the given revert data. Call more than once to add multiple reasons.
#[cheatcode(group = Testing, safety = Safe)]
function assumeNoRevert(bytes4 revertData) external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverted with the given revert data. Call more than once to add multiple reasons.
#[cheatcode(group = Testing, safety = Safe)]
function assumeNoRevert(bytes calldata revertData) external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverted with data starting with the given revert data. Call more than once to add multiple reasons.
#[cheatcode(group = Testing, safety = Safe)]
function assumeNoRevert(bytes4 revertData, address reverter) external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverted with the given revert data. Call more than once to add multiple reasons.
#[cheatcode(group = Testing, safety = Safe)]
function assumeNoRevert(bytes calldata revertData, address reverter) external pure; |
looks good for me, tagging for @andreivladbrg and @smol-ninja for additional feedback |
Looks good to me as well. |
Component
Forge
Describe the feature you would like
The use case is fork + fuzz tests - certain tokens like USDC have blacklists that prevent the transfer of assets between certain accounts (see lines 837 and 838 here). When Foundry fuzzes a blacklisted account, the Forge test will fail because of the following error:
However, this is a false negative. The user's test should not have failed.
It would be great if there were two config options for filtering revert reason strings and custom errors.
The text was updated successfully, but these errors were encountered: