solidity-coverage: Error: while migrating Migrations (Exceeds block gas limit)

I am trying to use solidity-coverage to evaluate my tests scripts. The thing is, my smart contracts are pretty big before adding all extra stuff needed for coverage evaluation, and I got out of gas issues at migration.

I’ve increassed the gas value in my truffle.js

coverage: { host: "localhost", network_id: "*", port: 8555, gas: 0xFFFFFFFFFFFFF, gasPrice: 0x01 }

and I also modified the testrpcOptions entry in .solcover.js

testrpcOptions: '-p 8555 -l 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -g 0x1',

Still, I get an error when running solidity-coverage:

Error: while migrating Migrations: Returned error: Exceeds block gas limit at /home/.../node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:361:1 at process._tickCallback (internal/process/next_tick.js:68:7)

Any idea what I am doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@GNSPS Are you using 0.6.4? And can you show the truffle config, launch commands etc?

The above solution almost worked for me if it wasn’t for the Number can only safely store up to 53 bits error that it was throwing.

After reading up on some other issues and how ethereumjs-vm might have a limit of 53 bits for the gas limit parameter that is provided what worked was starting testrpc with:

./node_modules/.bin/testrpc-sc -g 0x1 -l 9007199254740991 -p 8555

(The reason being that 9007199254740991 is equal to 2^53 - 1)

Running the testrpc outside of the solidity-coverage while setting norpc: true in .solcover.js worked for me.

My .solcover,js:

module.exports = {
  port: 8555,
  testrpcOptions: '-g 0x1 -l 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -p 8555',
  norpc: true,
  compileCommand: '../node_modules/.bin/truffle compile --network coverage',
  testCommand: '../node_modules/.bin/truffle test --network coverage',
  copyPackages: ['openzeppelin-solidity'],
};

Command to run testrpc:

./node_modules/.bin/testrpc-sc -g 0x1 -l 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -p 8555