1

Since I have to study the variation of the gasUsed of a function, using Truffle Test is it possible to do a test that runs n times the same function without going out of gas or exceding the block gas limit?

1
  1. Unless you configure your TestRPC/Ganache otherwise (auto-mining every X seconds), there will only be one transaction per block, so blockgas limit should not be the problem.

  2. To check the variations of used gas, you can do something like this (pseudocode):

arrayWithParameters[];

for (i=0; i<arrayWithParameters[].length; i++) {

let transaction = await yourContract.function(arrayWithParameters[i]);

checkGasOf(transaction);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.