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

fix(invariant): decode custom error with target contract abis #7559

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented Apr 4, 2024

Motivation

Closes #4178

Solution

  • atm failed invariant case revert reason with custom error is decoded only with Invariant contract ABIs, hence showing reason as FAIL. Reason: custom error d14cf5d4:]
  • fix by using also target contracts abis to decode revert reason

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
pending @klkvr

Copy link
Member

@klkvr klkvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 122 to 123
let mut abis: Vec<&JsonAbi> = targets.iter().map(|contract| &contract.1 .1).collect();
abis.push(invariant_contract.abi);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to collect

Suggested change
let mut abis: Vec<&JsonAbi> = targets.iter().map(|contract| &contract.1 .1).collect();
abis.push(invariant_contract.abi);
let abis = targets.iter().map(|contract| &contract.1 .1).chain(std::iter::once(invariant_contract.abi));

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated with 816615d

@DaniPopes DaniPopes merged commit 14daacf into foundry-rs:master Apr 8, 2024
19 checks passed
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

Successfully merging this pull request may close these issues.

bug(forge): custom errors are not decoded in invariant test traces
4 participants