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;
|
||||
let fuzzMap = {};
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
fuzzMap[i] = {};
|
||||
contract.abiDefinition.filter((x) => x.inputs && x.inputs.length != 0).forEach((abiMethod) => {
|
||||
let name = abiMethod.type === "constructor" ? "constructor" : abiMethod.name;
|
||||
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');
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -9,17 +9,19 @@ class GasEstimator {
|
|||
}
|
||||
|
||||
estimateGas(contractName) {
|
||||
const self = this;
|
||||
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.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);
|
||||
tempGasMap = {};
|
||||
fuzzMap.forEach((name) => {
|
||||
for (let i in fuzzMap[name]) {
|
||||
tempGasMap[name][i] = contract.methods[name].apply(contract.methods[name], fuzzMap[name][i]).estimateGas();
|
||||
let tempGasMap = {};
|
||||
for (let i = 0; i < 3; i++) {
|
||||
tempGasMap[i] = {}
|
||||
for (let name in fuzzMap[i]) {
|
||||
tempGasMap[i][name] = contract.methods[name].apply(contract.methods[name], fuzzMap[i][name]).estimateGas();
|
||||
}
|
||||
});
|
||||
};
|
||||
tempGasMap.forEach((name) => {
|
||||
if (name === "constructor") {
|
||||
gasMap[name] = contract.gasEstimates.creation.totalCost;
|
||||
|
|
Loading…
Reference in New Issue