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

Allow to run tests even when contracts folder doesn't exist #2093

Closed
shekhirin opened this issue Jun 23, 2022 · 3 comments · Fixed by #2121
Closed

Allow to run tests even when contracts folder doesn't exist #2093

shekhirin opened this issue Jun 23, 2022 · 3 comments · Fixed by #2121
Labels
C-forge Command: forge Cmd-forge-build Command: forge build D-easy Difficulty: easy P-normal Priority: normal T-feature Type: feature

Comments

@shekhirin
Copy link
Contributor

Component

Forge

Describe the feature you would like

Allow to run tests even if no src folder present. I think, same can be applied to running scripts without src and test folders but I'm not sure whether it's already the case or not.

Additional context

I tried to run tests for https://github.com/siewchongche/mev-example/tree/curve20220521 but it didn't work because src folder wasn't created:

mev-example git:(curve20220521) forge test --fork-url $ETH_RPC_URL --fork-block-number 14811888 -vvv
Error:
no contracts to compile, contracts folder "/Users/shekhirin/Projects/mev-example/src" does not exist.
Check the configured workspace settings:
root: /Users/shekhirin/Projects/mev-example
contracts: /Users/shekhirin/Projects/mev-example/src
artifacts: /Users/shekhirin/Projects/mev-example/out
tests: /Users/shekhirin/Projects/mev-example/test
scripts: /Users/shekhirin/Projects/mev-example/script
libs:
    /Users/shekhirin/Projects/mev-example/lib
remappings:
    ds-test/=/Users/shekhirin/Projects/mev-example/lib/forge-std/lib/ds-test/src/
    forge-std/=/Users/shekhirin/Projects/mev-example/lib/forge-std/src/
    openzeppelin-contracts/=/Users/shekhirin/Projects/mev-example/lib/openzeppelin-contracts/contracts/
    src/=/Users/shekhirin/Projects/mev-example/src/
    test/=/Users/shekhirin/Projects/mev-example/test/

If you are in a subdirectory in a Git repository, try adding `--root .`

I created an empty src folder and then it worked well:

mev-example git:(curve20220521) mkdir srcmev-example git:(curve20220521) forge test --fork-url $ETH_RPC_URL --fork-block-number 14811888 -vvv
[⠊] Compiling...
[⠊] installing solc version "0.8.14"
[⠆] Successfully installed solc 0.8.14
[⠘] Compiling 16 files with 0.8.14
[⠃] Solc 0.8.14 finished in 1.37s
Compiler run successful

Running 1 test for test/MEV.t.sol:MEVSimulation
[PASS] testMEV() (gas: 2043432)
Test result: ok. 1 passed; 0 failed; finished in 22.72s
@shekhirin shekhirin added the T-feature Type: feature label Jun 23, 2022
@onbjerg onbjerg added C-forge Command: forge P-normal Priority: normal D-easy Difficulty: easy Cmd-forge-build Command: forge build labels Jun 23, 2022
@mattsse
Copy link
Member

mattsse commented Jun 23, 2022

supportive of this, so let's just get rid of the bail!s?

@ayushm2003
Copy link
Contributor

these - 1, 2?

@mattsse
Copy link
Member

mattsse commented Jun 23, 2022

yes, I think ethers-solc can handle it if the paths don't exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build D-easy Difficulty: easy P-normal Priority: normal T-feature Type: feature
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants