Skip to content

fix: smarter getCode validation#7597

Merged
klkvr merged 7 commits into
masterfrom
klkvr/smarter-get-code
Apr 8, 2024
Merged

fix: smarter getCode validation#7597
klkvr merged 7 commits into
masterfrom
klkvr/smarter-get-code

Conversation

@klkvr

@klkvr klkvr commented Apr 8, 2024

Copy link
Copy Markdown
Member

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

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

I see, this check makes sense to me,

can we add a test for this as well?

@klkvr

klkvr commented Apr 8, 2024

Copy link
Copy Markdown
Member Author

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

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

@klkvr

klkvr commented Apr 8, 2024

Copy link
Copy Markdown
Member Author

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")`

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

@klkvr klkvr merged commit 04e2263 into master Apr 8, 2024
@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