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

[Update]: Fuzz test using the Echidna #294

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .echidna.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { execSync } = require('child_process');
const util = require('util');
const asyncExec = util.promisify(require('child_process').exec);

async function getBrewPrefixPath() {
try {
const { stdout } = await asyncExec('brew --prefix');
console.log(`Homebrew prefix path: ${stdout.trim()}`);
fuzzTestByEchidna(stdout.trim());
} catch (error) {
console.error(`Please install brew and echidna.`);
}
}

getBrewPrefixPath();

function fuzzTestByEchidna(brewPrefix) {
const contract = process.argv[2];
const exec = commands => {
try {
execSync(commands, { stdio: 'inherit', shell: true }); // Specify the shell if needed
} catch (error) {}
};

const echidnaPath = brewPrefix + '/bin/echidna';
console.log(echidnaPath);
switch (contract) {
case 'Operators':
exec(echidnaPath + ' --config echidna.yaml --contract Operators contracts/echidna/Operators.sol');
break;
case 'Clusters':
exec(echidnaPath + ' --config echidna.yaml --contract Clusters contracts/echidna/Clusters.sol');
break;
case 'DAO':
exec(echidnaPath + ' --config echidna.yaml --contract DAO contracts/echidna/DAO.sol');
break;
default:
console.log('Invalid contract name. Use Operators, Clusters, or DAO.');
console.log('npm run echidna <Operators | Clusters | DAO>');
}
}
2 changes: 1 addition & 1 deletion .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
with:
node-version: 18
fail-on: high
slither-args: --exclude controlled-delegatecall
slither-args: --exclude controlled-delegatecall
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cache
coverage
coverage.json
artifacts
crytic-export
echidna-corpus
typechain-types/
.openzeppelin/*.json
.DS_Store
Expand Down
Loading
Loading