Fix fuzzer while profiling
This commit is contained in:
parent
33666bd030
commit
f0f9840757
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue