foundry icon indicating copy to clipboard operation
foundry copied to clipboard

forge: Set --fork-block-number in the source code; different block numbers for different tests

Open SheldonHolmgren opened this issue 1 year ago • 1 comments

Component

Forge

Describe the feature you would like

Some way to specify the fork-block-number in the test source code file rather than the command line. Allowing for running different tests on different fork block numbers.

Rationale: In my fork tests I often want to run on a historical state that lasted for only one block. Currently I have to run the `forge test' command separately for each of my tests and I have to set a different --fork-block-number argument for each of them. I will probably end up creating a Makefile that does that. My tests would be much easier to maintain with this feature.

Additional context

No response

SheldonHolmgren avatar Feb 17 '24 06:02 SheldonHolmgren

If I am not missing something you can already do that by specifying the block number to fork in createSelectFork cheatcode https://book.getfoundry.sh/cheatcodes/create-select-fork#examples The block number can be read as an env var

grandizzy avatar Feb 17 '24 10:02 grandizzy

Yep, createSelectFork

DaniPopes avatar Feb 19 '24 15:02 DaniPopes