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: smarter getCode validation #7597

Merged
merged 7 commits into from
Apr 8, 2024
Merged

fix: smarter getCode validation #7597

merged 7 commits into from
Apr 8, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Apr 8, 2024

Motivation

One more fix after #7334

If we've found multiple matching artifacts for vm.getCode and exactly one of them matches version of the currently running test/script source, return that.

Ref https://t.me/foundry_support/52016

Solution

This changes test runner flow a bit so we now create executor for each ContractRunner to alter cheatcodes config with running contract version

@klkvr klkvr changed the title fix: smarter getCode validation fix: smarter getCode validation Apr 8, 2024
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.

I see, this check makes sense to me,

can we add a test for this as well?

@klkvr
Copy link
Member Author

klkvr commented Apr 8, 2024

@mattsse created a separate profile for tests in multi-version environment

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 @DaniPopes

@klkvr
Copy link
Member Author

klkvr commented Apr 8, 2024

As we're already here, also added more input options for getCode/getDeployedCode cheats. It now can parse all of those formats:

vm.getCode("Counter.sol");
vm.getCode("Counter");
vm.getCode("Counter:0.X.X");
vm.getCode("Counter.sol:0.X.X");
vm.getCode("Counter.sol:Counter:0.X.X")`

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

lgtm

@klkvr klkvr merged commit 04e2263 into master Apr 8, 2024
19 checks passed
@klkvr klkvr deleted the klkvr/smarter-get-code branch April 8, 2024 15:13
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.

3 participants