-
Notifications
You must be signed in to change notification settings - Fork 20
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
[DRAFT] Test using vault compiled with Hardhat in Forge tests #558
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked for me! I even deleted the artifacts, node modules, etc., and tried running test:forge only, to make sure hardhat didn't have to be run first. And the dramatic snap file reduction indicates it's functioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Well let's keep this in mind; maybe let's not merge it yet. It's great to know that it's not that hard to move away from the current pipeline.
If we wanted to have coverage tests, we'd need to deploy the vault in the regular way and compile with a different profile like the project referenced in #539 does right?
"test:forge": "forge test -vvv --no-match-test Fork", | ||
"test:fork": "forge test -vvv --match-test Fork", | ||
"test:forge": "yarn build; FOUNDRY_PROFILE=test forge test -vvv --no-match-test Fork", | ||
"test:fork": "yarn build; FOUNDRY_PROFILE=test forge test -vvv --match-test Fork", | ||
"test:stress": "FOUNDRY_PROFILE=intense forge test -vvv", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably needs to be updated right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.. We need to specify the test profile, so src is set to 'test/foundry' and the Vault binaries are not compiled by the forge test, which would trigger the "Stack too deep" error
@jubeira We'd need to rewrite VaultMockDeployer, deploying the VaultMock with the actual contract instead of using the compiled json. |
Description
Complex contracts, such as BatchRouter and Vault, often trigger 'stack too deep' errors upon modification. These errors, coupled with the need for workarounds, result in difficult-to-understand code.
If we compile the code with the
via-ir
flag, we can avoid "stack too deep". However, when we develop tests with Forge, they're also compiled with thevia-ir
flag and take forever to compile. Currently, there's no way to natively use thecontracts
folder compiled withvia-ir
and thetest
folder compiled without it.To bypass this issue, as mentioned by @elshan-eth, we can import the JSON file that was generated from hardhat/forge build using --via-ir, and with modifications in the foundry.toml file we prevent forge from compiling all contracts from
contracts
folder when runningforge test
.NOTE: This PR breaks the coverage tests in forge, but they're already broken in hardhat since the code is compiled with via-ir too.
Type of change
Checklist:
main
, or there's a description of how to merge