echidna: Couldn't compile given file
Hello I am trying to run echidna on a single contract file that's not in any framework foundry or hardhat
I am facing this issue when I run crytic-compile Soln.sol
$ crytic-compile Soln.sol
Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/bin/crytic-compile", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/linuxbrew/.linuxbrew/Cellar/crytic-compile/0.3.5_1/libexec/lib/python3.12/site-packages/crytic_compile/__main__.py", line 221, in main
compilations = compile_all(**vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/linuxbrew/.linuxbrew/Cellar/crytic-compile/0.3.5_1/libexec/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 740, in compile_all
raise NotImplementedError()
NotImplementedError
and this is when I run echidna solution.sol TestToken
[2023-11-14 20:01:22.70] Compiling solution.sol... Done! (0.627279468s)
echidna: Couldn't compile given file
stdout:
stderr:
Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/bin/crytic-compile", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/linuxbrew/.linuxbrew/Cellar/crytic-compile/0.3.5_1/libexec/lib/python3.12/site-packages/crytic_compile/__main__.py", line 221, in main
compilations = compile_all(**vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/linuxbrew/.linuxbrew/Cellar/crytic-compile/0.3.5_1/libexec/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 740, in compile_all
raise NotImplementedError()
NotImplementedError
and when I use echidna-test . --contract TestToken it says
echidna-test: command not found
I have checked various issues on github but theres no fix
Hi!,
The correct command is echidna, not echidna-test. Besides that, the crytic-compile issue should be reported in their issue tracker. Let's close this one.
Hi! You should also specify the contract name with --contract, e.g. echidna solution.sol --contract TestToken
The first error is unintuitive, but it's usually seen when the specified file does not exist. Check that you are in the correct directory and that you can see your file with ls
The echidna command seems to only work when you are in the folder of the test file and having solc-select installed and using the correct version is a must.
Although using this method will still find errors when importing solidity files from other folders
echidna TestSwapFactory.sol --contract TestSwapFactory
[2023-11-29 17:23:37.81] Compiling TestSwapFactory.sol... Done! (0.337096s)
echidna: Couldn't compile given file
stdout:
stderr:
INFO:CryticCompile:'solc --version' running
INFO:CryticCompile:'solc TestSwapFactory.sol --combined-json abi,ast,bin,bin-runtime,srcmap,srcmap-runtime,userdoc,devdoc,hashes --allow-paths .,/Users/redacted/Documents/Solidity/redacted/swaplace-contracts/contracts/audit' running
ERROR:CryticCompile:Invalid solc compilation Error: Source "SwapFactory.sol" not found: File not found. Searched the following locations: "".
--> TestSwapFactory.sol:4:1:
|
4 | import "../SwapFactory.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "../SwapFactory.sol";
contract TestSwapFactory is SwapFactory {
function echidna_alwaystrue() public returns (bool) {
return (true);
}
function echidna_revert_always() public returns (bool) {
revert();
}
}
When using the following command on the main hardhat folder, I manage to run the tests above. But notice that the contract file with .sol extension was not mentioned...
echidna . --contract TestSwapFactory
@0xneves, thank you brother)