Given contract not found in given file
Hello!
Fuzzing contracts from damn-vulnerable-defi-echidna fails with message Given contract not found in given file, if there is any invalid contract in project.
To reproduce:
Project are clean, fuzzing works:
$ cd damn-vulnerable-defi-echidna && \
echidna-test_v2.0.5 . --contract NaiveReceiverEchidna --config naivereceiver.yaml
echidna_test_contract_balance: failed!💥
Call sequence:
flashLoan(0x62d69f6867a0a084c6d313943dc22023bc263691,33)
Add invalid contract at contracts/unstoppable/123.sol:
pragma solidity ^0.8.0;
contract UnstoppableEchidna {
constructor() payable {
123
}
}
And run fuzzer again:
$ echidna-test_v2.0.5 . --contract NaiveReceiverEchidna --config naivereceiver.yaml
echidna-test_v2.0.5: Given contract "NaiveReceiverEchidna" not found in given file
Remove contracts/unstoppable/123.sol and run again:
$ rm contracts/unstoppable/123.sol && \
echidna-test_v2.0.5 . --contract NaiveReceiverEchidna --config naivereceiver.yaml
echidna_test_contract_balance: failed!💥
Call sequence:
flashLoan(0x62d69f6867a0a084c6d313943dc22023bc263691,4369999)
Add invalid contract at contracts/unstoppable/123.sol
We don't support compilations that are invalid. If this happens by accident it should warn it, but in general, you should be doing this.
Hello,
I am experiencing this same error while trying to run Echidna on a Foundry project on the CI, although I don't have any invalid contracts, since I can compile without issues, and can run on local without issues.
My ci.yaml is
invariants:
strategy:
matrix:
mode: [assertion, property]
name: Echidna
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install Crytic-compile
run: |
pip install crytic-compile
- name: Install Echidna
run: |
wget https://github.com/crytic/echidna/releases/download/v2.2.1/echidna-2.2.1-Linux.zip -O echidna.zip
unzip echidna.zip
tar -xvkf echidna.tar.gz
rm echidna.zip echidna.tar.gz
./echidna --version
- name: Echidna ${{ matrix.mode }}
run: |
./echidna . --contract CryticTester --config echidna.yaml --test-mode ${{ matrix.mode }} --test-limit 100000 --corpus-dir corpus
Do you have any ideas of what's wrong?
Hi @aviggiano, is your CryticTester contract on Foundry's test or script directory by any chance? I believe crytic-compile skips building those to improve compilation speeds.
Hi @aviggiano, is your
CryticTestercontract on Foundry'stestorscriptdirectory by any chance? I believecrytic-compileskips building those to improve compilation speeds.
Yes, that was the issue, thank you for the answer.
It seems this is already fixed. Closing it.