mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 22:44:45 +00:00
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 utils = require('web3-utils');
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
@ -14,11 +13,11 @@ class ContractFuzzer {
|
|||||||
this.registerConsoleCommand();
|
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) {
|
generateFuzz(iterations, contract) {
|
||||||
let fuzzMap = {};
|
let fuzzMap = {};
|
||||||
for (let i = 0; i < iterations; i++)
|
for (let i = 0; i < iterations; i++) contract.abiDefinition.filter((x) => x.inputs && x.inputs.length != 0).forEach((abiMethod) => {
|
||||||
contract.abiDefinition.filter((x) => x.inputs && x.inputs.length != 0)
|
|
||||||
.forEach((abiMethod) => {
|
|
||||||
let name = abiMethod.type === "constructor" ? "constructor" : abiMethod.name;
|
let name = abiMethod.type === "constructor" ? "constructor" : abiMethod.name;
|
||||||
console.log("name");
|
console.log("name");
|
||||||
let inputTypes = abiMethod.inputs.map(input => input.type);
|
let inputTypes = abiMethod.inputs.map(input => input.type);
|
||||||
@ -55,11 +54,12 @@ class ContractFuzzer {
|
|||||||
let arraySize = regexObj[5];
|
let arraySize = regexObj[5];
|
||||||
console.log("array size:", arraySize);
|
console.log("array size:", arraySize);
|
||||||
switch(true) {
|
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
|
// 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;
|
let length = arraySize === undefined || arraySize === null || arraySize === '' ? Math.floor((Math.random() * 256) + 1) : arraySize;
|
||||||
console.log("LENGTH: ", length);
|
console.log("LENGTH: ", length);
|
||||||
return self.generateArrayOfType(length, type)
|
return self.generateArrayOfType(length, type);
|
||||||
|
}
|
||||||
case kind == "bool":
|
case kind == "bool":
|
||||||
return self.generateRandomBool();
|
return self.generateRandomBool();
|
||||||
case kind == "uint" || kind == "int":
|
case kind == "uint" || kind == "int":
|
||||||
@ -67,7 +67,7 @@ class ContractFuzzer {
|
|||||||
case kind === "bytes" && size !== undefined:
|
case kind === "bytes" && size !== undefined:
|
||||||
return self.generateRandomStaticBytes(size);
|
return self.generateRandomStaticBytes(size);
|
||||||
case kind === "string" || kind === "bytes":
|
case kind === "string" || kind === "bytes":
|
||||||
return self.generateRandomDynamicType()
|
return self.generateRandomDynamicType();
|
||||||
case kind === "address":
|
case kind === "address":
|
||||||
return self.generateRandomAddress();
|
return self.generateRandomAddress();
|
||||||
default:
|
default:
|
||||||
@ -114,7 +114,7 @@ class ContractFuzzer {
|
|||||||
if (cmdName === 'fuzz') {
|
if (cmdName === 'fuzz') {
|
||||||
self.events.request('contracts:contract', contractName, (contract) => {
|
self.events.request('contracts:contract', contractName, (contract) => {
|
||||||
self.logger.info("-- fuzzed vals for " + contractName);
|
self.logger.info("-- fuzzed vals for " + contractName);
|
||||||
this.generateFuzz(1, contract);
|
this.generateFuzz(iterations, contract);
|
||||||
});
|
});
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
const asciiTable = require('ascii-table');
|
const asciiTable = require('ascii-table');
|
||||||
const ethAbi = require('web3-eth-abi');
|
|
||||||
|
|
||||||
class Profiler {
|
class Profiler {
|
||||||
constructor(embark) {
|
constructor(embark) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user