Error: Returned error: base fee exceeds gas limit when testing with OpenZeppelin Test Environment using Contracts.getFromLocal from Upgrades

When deploying a new contract in Mocha, I receive Error: Returned error: base fee exceeds gas limit.

const {accounts, contract, web3} = require("@openzeppelin/test-environment");
const {TestHelper} = require("@openzeppelin/cli");
const addresses = require("./helper/addresses");

const Store = Contracts.getFromLocal("Store");

describe("Store", () => {
    const [admin] = accounts;
    before(async function () {
        this.project = await TestHelper();
        store = await Store.new(addresses.ContractA, {
            from: admin,
        });
    }
}

My test-environment.config.js file:

module.exports = {
      accounts: {
        amount: 10, // Number of unlocked accounts
        ether: 100, // Initial balance of unlocked accounts (in ether)
      },

      contracts: {
        type: "truffle", // Contract abstraction to use: 'truffle' for @truffle/contract or 'web3' for web3-eth-contract
        defaultGas: 6e6, // Maximum gas for contract calls (when unspecified)

        // Options available since v0.1.2
        defaultGasPrice: 20e9, // Gas price for contract calls (when unspecified)
        artifactsDir: "build/contracts", // Directory where contract artifacts are stored
      },

      node: {
        // Options passed directly to Ganache client
        gasLimit: 8e6, // Maximum gas per block
        gasPrice: 20e9, // Sets the default gas price for transactions if not otherwise specified.
      },
    };

Store is deployed if I specify gasLimit: 8000000 in the transaction, but it seems like this should be done by TestHelper.

1 Like

Hi @dtp5,

I assume because you are using Contracts.getFromLocal from Upgrades it doesn’t pickup the Test Environment configuration unfortunately.

Hey @dtp5! I’m afraid neither the Contracts nor the TestHelper modules are picking up test-env settings automatically.

Nevertheless, you can specify the same defaults once in the Contracts module:

Contracts.setArtifactsDefaults({ gas: 8e6, gasPrice: 20e9 });

Let us know if this works for you!

1 Like

That worked. Thank you, @spalladino!

1 Like