Skip to content

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

Merged
DaniPopes merged 2 commits into
foundry-rs:masterfrom
grandizzy:4178
Apr 8, 2024
Merged

fix(invariant): decode custom error with target contract abis#7559
DaniPopes merged 2 commits into
foundry-rs:masterfrom
grandizzy:4178

Conversation

@grandizzy

@grandizzy grandizzy commented Apr 4, 2024

Copy link
Copy Markdown
Collaborator

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

@mattsse mattsse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm
pending @klkvr

@klkvr klkvr left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
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