switch the keys around and make a few logical changes to the way things are structured. Currently stuck at method calling
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
fedbe0d2bc
commit
311ec7d9cb
|
@ -18,13 +18,16 @@ class ContractFuzzer {
|
||||||
const self = this;
|
const self = this;
|
||||||
let fuzzMap = {};
|
let fuzzMap = {};
|
||||||
for (let i = 0; i < iterations; i++) {
|
for (let i = 0; i < iterations; i++) {
|
||||||
|
fuzzMap[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;
|
||||||
let inputTypes = abiMethod.inputs.map(input => input.type);
|
let inputTypes = abiMethod.inputs.map(input => input.type);
|
||||||
fuzzMap[name][i] = inputTypes.map(input => this.getTypeFuzz(input));
|
self.logger.debug("input method:", name);
|
||||||
|
self.logger.debug("iteration:", i);
|
||||||
|
fuzzMap[i][name] = inputTypes.map(input => this.getTypeFuzz(input));
|
||||||
});
|
});
|
||||||
self.logger.info('\n');
|
self.logger.info('\n');
|
||||||
for (let key in fuzzMap) self.logger.info(key + ":" + fuzzMap[key][i]);
|
for (let key in fuzzMap[i]) self.logger.info(key + ":" + fuzzMap[i][key]);
|
||||||
}
|
}
|
||||||
return fuzzMap;
|
return fuzzMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,19 @@ class GasEstimator {
|
||||||
}
|
}
|
||||||
|
|
||||||
estimateGas(contractName) {
|
estimateGas(contractName) {
|
||||||
|
const self = this;
|
||||||
let gasMap = {};
|
let gasMap = {};
|
||||||
this.logger.info("Generating three rounds of fuzz for contract -- ", contractName);
|
|
||||||
let fuzzMap = this.fuzzer.generateFuzz(3, contractName);
|
|
||||||
self.events.request('contracts:contract', contractName, (contract) => {
|
self.events.request('contracts:contract', contractName, (contract) => {
|
||||||
|
self.logger.info("Generating three rounds of fuzz for contract -- ", contractName);
|
||||||
|
let fuzzMap = self.fuzzer.generateFuzz(3, contract);
|
||||||
self.logger.info("-- Beginning gastimation for contract -- " + contractName);
|
self.logger.info("-- Beginning gastimation for contract -- " + contractName);
|
||||||
tempGasMap = {};
|
let tempGasMap = {};
|
||||||
fuzzMap.forEach((name) => {
|
for (let i = 0; i < 3; i++) {
|
||||||
for (let i in fuzzMap[name]) {
|
tempGasMap[i] = {}
|
||||||
tempGasMap[name][i] = contract.methods[name].apply(contract.methods[name], fuzzMap[name][i]).estimateGas();
|
for (let name in fuzzMap[i]) {
|
||||||
|
tempGasMap[i][name] = contract.methods[name].apply(contract.methods[name], fuzzMap[i][name]).estimateGas();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
tempGasMap.forEach((name) => {
|
tempGasMap.forEach((name) => {
|
||||||
if (name === "constructor") {
|
if (name === "constructor") {
|
||||||
gasMap[name] = contract.gasEstimates.creation.totalCost;
|
gasMap[name] = contract.gasEstimates.creation.totalCost;
|
||||||
|
|
Loading…
Reference in New Issue