foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Solidity Test that can run multiple solidity versions at once.

Open karmabadger opened this issue 1 year ago • 7 comments

Component

Forge

Describe the feature you would like

Solidity Test that can run multiple solidity versions at once. From time to time, you might need to test new code against/with old code such as UniswapV2 which require completely incompatible versions. Currently this is not possible to do as it wouldn't even compile. (is there even a work around)?

Additional context

No response

karmabadger avatar Sep 02 '22 00:09 karmabadger

A somewhat cumbersome workaround is to compile it and to vm.etch the runtime code. You can also manually deploy it (with some args) and copy the code to etch (see https://github.com/0xPhaze/paradigm-ctf-2021-foundry/blob/master/src/ParadigmSetup.sol as an example). Or you can get the creation code and concatenate with your constructorArgs.

0xPhaze avatar Sep 02 '22 08:09 0xPhaze

related #2704

rkrasiuk avatar Sep 02 '22 12:09 rkrasiuk

A somewhat cumbersome workaround is to compile it and to vm.etch the runtime code. You can also manually deploy it (with some args) and copy the code to etch (see https://github.com/0xPhaze/paradigm-ctf-2021-foundry/blob/master/src/ParadigmSetup.sol as an example). Or you can get the creation code and concatenate with your constructorArgs.

ok I'll try that. Ultimately the best way to fix this would a fix for backwards compatibility in solc directly. but yeah anything is appreciated rn

karmabadger avatar Sep 04 '22 17:09 karmabadger

Just noting this is related to #3062 which proposes a config format for supporting multiple solc versions/settings

mds1 avatar Sep 04 '22 17:09 mds1

Just noting this is related to #3062 which proposes a config format for supporting multiple solc versions/settings

well it is a bit but this problem is more than just a config problem rn. SOLC itself cannot mix and max sol versions together in the same file. foundry can actually deal with multiple solidity versions in the project but cannot deal with multiple in the same file.

karmabadger avatar Sep 06 '22 15:09 karmabadger

Oh maybe I misunderstood then. I interpreted the issue as being for different test files. You want to have two different solc versions uses in the same file? If solc doesn't support that, it seems more like a solidity issue than a foundry issue IIUC

mds1 avatar Sep 06 '22 16:09 mds1

Oh maybe I misunderstood then. I interpreted the issue as being for different test files. You want to have two different solc versions uses in the same file? If solc doesn't support that, it seems more like a solidity issue than a foundry issue IIUC

yes it is preferrably fixed with solc but there should be a good supported work around tbh. This is a pretty common issue imo.

karmabadger avatar Sep 07 '22 04:09 karmabadger

Would it be feasible to come up with a cheatcode that produces sth. like 0xPhaze/paradigm-ctf-2021-foundry@master/src/ParadigmSetup.sol without that cumbersome manual initialization?

Especially for large code bases that grow and migrate through several versions over time this would be a big deal.

EDIT: Whoops, nevermind... Just realized that that already exists (deployCode) :-)

fubhy avatar Jan 04 '23 15:01 fubhy

I'd like the ability to have multiple solc versions configured like Hardhat allows to do with the compilers filed in hardhat.config This is closest I found for foundry on that https://github.com/hbarcelos/forge-multi-version

stevyhacker avatar Jul 06 '23 14:07 stevyhacker