From a7629d2ac047ac03158f788beacc2ecbfd45fbf7 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 5 Jun 2018 13:54:43 -0500 Subject: [PATCH] fix linting Signed-off-by: VoR0220 --- lib/modules/fuzzer/index.js | 16 ++++++++-------- lib/modules/profiler/index.js | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/modules/fuzzer/index.js b/lib/modules/fuzzer/index.js index a0e3a88ec..f2f6f2ab1 100644 --- a/lib/modules/fuzzer/index.js +++ b/lib/modules/fuzzer/index.js @@ -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 ""; } diff --git a/lib/modules/profiler/index.js b/lib/modules/profiler/index.js index 6f5ce2aa2..f86ad9952 100644 --- a/lib/modules/profiler/index.js +++ b/lib/modules/profiler/index.js @@ -1,5 +1,4 @@ const asciiTable = require('ascii-table'); -const ethAbi = require('web3-eth-abi'); class Profiler { constructor(embark) {