[Ethereum] Solidity Exceeds block gas limit during Mocha Tests with Ganache-cli

ganachegas-limitmochasolidity

How can I increase the gas limit in this case? The error message is "n: Exceeds block gas limit" or "base fee exceeds gas limit".

I think there is some kind of api I need to set the block gas limit here.

Are my contracts too large? Should I test each contract one by one instead?
Please advise. Thank you.

Best Answer

The error message

"n: Exceeds block gas limit"

means your transaction has declared a gas value greater that the maximum allowed in the network. A client will reject such transaction.

With ganache-cli you can launch with a larger amount of gas available with the -l parameter:

ganache-cli -l 8000000

Will launch ganache with a block gas limit of 8M.


From the readme documentation it has a mode where you pass extra options in a parameter when you launch ganache. There you can set gasLimit.

const ganache = require("ganache-cli");
const options = { gasLimit: 8000000 };
const server = ganache.server(options);
server.listen(port, (err, blockchain) => {
    /* */
});