fix linting
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
ffe26d052a
commit
a7629d2ac0
|
@ -1,4 +1,3 @@
|
|||
const ethAbi = require('web3-eth-abi');
|
||||
const utils = require('web3-utils');
|
||||
const _ = require('underscore');
|
||||
|
||||
|
@ -14,11 +13,11 @@ class ContractFuzzer {
|
|||
this.registerConsoleCommand();
|
||||
}
|
||||
|
||||
// main function to call, takes in iteration number and a contract and returns a map object
|
||||
// composed of method names -> fuzzed inputs.
|
||||
generateFuzz(iterations, contract) {
|
||||
let fuzzMap = {};
|
||||
for (let i = 0; i < iterations; i++)
|
||||
contract.abiDefinition.filter((x) => x.inputs && x.inputs.length != 0)
|
||||
.forEach((abiMethod) => {
|
||||
for (let i = 0; i < iterations; i++) contract.abiDefinition.filter((x) => x.inputs && x.inputs.length != 0).forEach((abiMethod) => {
|
||||
let name = abiMethod.type === "constructor" ? "constructor" : abiMethod.name;
|
||||
console.log("name");
|
||||
let inputTypes = abiMethod.inputs.map(input => input.type);
|
||||
|
@ -55,11 +54,12 @@ class ContractFuzzer {
|
|||
let arraySize = regexObj[5];
|
||||
console.log("array size:", arraySize);
|
||||
switch(true) {
|
||||
case (array !== undefined):
|
||||
case array !== undefined: {
|
||||
// if it's a dynamic array pick a number between 1 and 256 for length of array
|
||||
let length = arraySize === undefined || arraySize === null || arraySize === '' ? Math.floor((Math.random() * 256) + 1) : arraySize;
|
||||
console.log("LENGTH: ", length);
|
||||
return self.generateArrayOfType(length, type)
|
||||
return self.generateArrayOfType(length, type);
|
||||
}
|
||||
case kind == "bool":
|
||||
return self.generateRandomBool();
|
||||
case kind == "uint" || kind == "int":
|
||||
|
@ -67,7 +67,7 @@ class ContractFuzzer {
|
|||
case kind === "bytes" && size !== undefined:
|
||||
return self.generateRandomStaticBytes(size);
|
||||
case kind === "string" || kind === "bytes":
|
||||
return self.generateRandomDynamicType()
|
||||
return self.generateRandomDynamicType();
|
||||
case kind === "address":
|
||||
return self.generateRandomAddress();
|
||||
default:
|
||||
|
@ -114,7 +114,7 @@ class ContractFuzzer {
|
|||
if (cmdName === 'fuzz') {
|
||||
self.events.request('contracts:contract', contractName, (contract) => {
|
||||
self.logger.info("-- fuzzed vals for " + contractName);
|
||||
this.generateFuzz(1, contract);
|
||||
this.generateFuzz(iterations, contract);
|
||||
});
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const asciiTable = require('ascii-table');
|
||||
const ethAbi = require('web3-eth-abi');
|
||||
|
||||
class Profiler {
|
||||
constructor(embark) {
|
||||
|
|
Loading…
Reference in New Issue