Failed to move tests outside contracts folder
0xneves opened this issue · 2 comments
I'm trying to move my test file out of the contracts
folder (hardhat) and I'm finding a strange behavior.
When trying to run echidna with the following command, this strange behavior happens:
echidna . echidna/TestSwapFactory.sol --contract TestSwapFactory
[2023-11-30 16:12:45.73] Compiling .... Done! (9.966298s)
[2023-11-30 16:12:55.75] Compiling echidna/TestSwapFactory.sol... Done! (0.335921s)
WARNING: more than one SourceCaches was found after compile. Only the first one will be used.
echidna: Given contract "TestSwapFactory" not found in given file
When running without the folder being specified as echidna . TestSwapFactory.sol --contract TestSwapFactory
:
[2023-11-30 15:59:44.10] Compiling .... Done! (8.794308s)
[2023-11-30 15:59:52.94] Compiling TestSwapFactory.sol... Done! (0.109293s)
echidna: Couldn't compile given file
stdout:
stderr:
Traceback (most recent call last):
File "/opt/homebrew/bin/crytic-compile", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/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 "/opt/homebrew/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
We get NotImplementedError.
Although the cryptic-compile is working fine when specifying the folder as crytic-compile echidna/TestSwapFactory.sol
, if I remove the �echdina folder by using�crytic-compile TestSwapFactory.sol
, we receive a similar error just like echidna:
Traceback (most recent call last):
File "/opt/homebrew/bin/crytic-compile", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/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 "/opt/homebrew/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
The current file struct:
...
import "../contracts/SwapFactory.sol";
contract TestSwapFactory is SwapFactory {
...
}
I've seen the example on the Balancer repository and they managed to do it. I can only manage to work this out by putting the tests inside the contracts folder...
Even the minimal contract such as:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Test {}
Will reproduce the same problem described above.
Since you're using hardhat, I'd recommend configuring such that the hardhat build command detects your contracts and fuzz tests. Then, you should be able to just run echidna . --contract TestSwapFactory
in the root of the repo and not pass multiple directories/files. Lmk if this isn't enough to unblock you and we can get some help from the echidna maintainers
You're hitting the NotImplementedError
bc of a regression (#531) which should be fixed shortly, but this means the arguments you're passing are not a file or subdirectory in the current working directory.