Skip to content

Commit

Permalink
fix: updated test script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohsen-T committed Feb 23, 2024
1 parent f4e81dc commit 8dfb5d7
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions .echidna.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
const { execSync } = require('child_process');
const contract = process.argv[2];
const util = require('util');
const asyncExec = util.promisify(require('child_process').exec);

const exec = commands => {
async function getBrewPrefixPath() {
try {
execSync(commands, { stdio: 'inherit', shell: true }); // Specify the shell if needed
} catch (error) {}
};
const { stdout } = await asyncExec('brew --prefix');
console.log(`Homebrew prefix path: ${stdout.trim()}`);
fuzzTestByEchidna(stdout.trim());
} catch (error) {
console.error(`Error: ${error}`);
}
}

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 = '/usr/local/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>');
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>');
}
}

0 comments on commit 8dfb5d7

Please sign in to comment.