runCoverage out of gas using OpenZeppelin Test Environment

I am trying to get a solidity test coverage for my contracts. I tried solidity-coverage but I get an assembly invalid opcode error. I tried OpenZeppelin runCoverage and I get out of gas for all the tests.

:computer: Environment

Truffle v5.1.54 (core: 5.1.54)
Solidity - 0.6.6 (solc-js)
Node v10.23.0
Web3.js v1.2.9

:memo:Details

Here is test-environment-config.js:

    module.exports = {
      accounts: {
        ether: 1e6,
      },
      contracts: {
        type: 'truffle',
        defaultGas: 8e7
      }
    };

here is coverage.js

    #!/usr/bin/env node

    const { runCoverage } = require('@openzeppelin/test-environment');

    async function main () {
      await runCoverage(
        ['mock'],
        'npm run compile',
        './node_modules/.bin/mocha --exit --timeout 10000'.split(' '),
      );
    }

    main().catch(e => {
      console.error(e);
      process.exit(1);
    });

All of my tests output the following:

      7) UniswapIncentive
           "before each" hook for "reverts":
         Error: Returned error: VM Exception while processing transaction: out of gas
          at Context.<anonymous> (test/UniswapIncentive.test.js:19:31)

:1234: Code to reproduce

1 Like

Hi @Joey_Santoro,

Welcome to the community :wave:

I’m sorry that you are having this issue.

OpenZeppelin Contracts used coverage with OpenZeppelin Test Environment so you could look at that setup: https://github.com/OpenZeppelin/openzeppelin-contracts/commit/c7d99531a7d516d19f31a1f09e42c6d1aec44045

Are you able to share a repository?

@abcoathup turns out I had manually set gas on a few txs that was too low. When I removed that it passed. Closing this!

1 Like

Hi @Joey_Santoro,

Glad to hear that you resolved.