Fix fuzzer while profiling

This commit is contained in:
Anthony Laibe 2018-08-09 13:52:41 +01:00 committed by Iuri Matias
parent 33666bd030
commit f0f9840757
1 changed files with 7 additions and 8 deletions

View File

@ -1,5 +1,4 @@
const utils = require('web3-utils');
const u = require('../../utils/utils.js');
// generates random inputs based on the inputs of an ABI
@ -11,7 +10,7 @@ class ContractFuzzer {
}
// main function to call, takes in iteration number and a contract and returns a map object
// composed of method names -> fuzzed inputs.
// composed of method names -> fuzzed inputs.
generateFuzz(iterations, contract) {
const self = this;
let fuzzMap = {};
@ -52,10 +51,10 @@ class ContractFuzzer {
case kind == "bool":
return self.generateRandomBool();
case kind == "uint" || kind == "int":
return self.generateRandomInt(size);
case kind === "bytes" && size !== undefined:
return self.generateRandomStaticBytes(size);
case kind === "string" || kind === "bytes":
return self.generateRandomInt(size || 256);
case kind === "bytes":
return self.generateRandomStaticBytes(size || 32);
case kind === "string":
return self.generateRandomDynamicType();
case kind === "address":
return self.generateRandomAddress();
@ -79,11 +78,11 @@ class ContractFuzzer {
}
generateRandomStaticBytes(size) {
return utils.randomHex(size);
return utils.randomHex(parseInt(size, 10));
}
generateRandomInt(size) {
return utils.toBN(utils.randomHex(size / 8));
return utils.toBN(utils.randomHex(parseInt(size, 10) / 8));
}
generateRandomAddress() {