When I run yarn hardhat test I get below error:

  1) "before each" hook for "sets the aggregator addresses correctly"
0 passing (1m)
1 failing

"before each" hook for "sets the aggregator addresses correctly":
Error: Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/blockchain-javascript/hh-blockchain-js-solidity/hardhat-fund-me-fcc/test/unit/FundMe.test.js)
at listOnTimeout (node:internal/timers:564:17)
at processTimers (node:internal/timers:507:7)

I have tried following things:

  • Changing timeout
  • Adding done()
  • Literally copy pasting patrick's code and it still does not work
  • Tried removing async and added done
  • Tried chatGPT :). gave the code to it asked for correction the suggestion it comes with is something which takes me to same state.

My code is below.

const { deployments, ethers, getNamedAccounts } = require("hardhat")

//const { getNamedAccounts } = require("@nomiclabs/hardhat-ethers/helpers") // Fixed typo here
const { assert } = require("chai")

describe("FundMe", async function() {
let fundMe
let deployer
let mockV3Aggregator

beforeEach(async function() {
    deployer = (await getNamedAccounts()).deployer
    await deployments.fixture(["all"])
    fundMe = await ethers.getContract("FundMe", deployer)
    mockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer)

describe("constructor", async function() {
    it("sets the aggregator addresses correctly", async function(done) {
        // Added async here
        const response = await fundMe.priceFeed()
        assert.equal(response, mockV3Aggregator.address)
  • Edit your post please its not clear
    – forexmp45
    Mar 20, 2023 at 1:33

2 Answers 2


To specify the gas limit for a transaction in Hardhat, you can use the gasLimit parameter when sending the transaction.

Here's an example of how to set the gas limit when calling a contract method using ethers:

const { ethers } = require('hardhat')

// Assume `contract` is an instance of your contract
const tx = await contract.someMethod(arg1, arg2, {
gasLimit: 1000000 // Set gas limit to 1 million wei

// You can also set the gas limit when deploying a contract
const factory = await ethers.getContractFactory('MyContract', signer)
const contract = await factory.deploy({
  gasLimit: 2000000 // Set gas limit to 2 million wei

In this example, gasLimit is set to 1000000 when calling the someMethod method on an instance of your contract. You can replace this with the desired gas limit value in wei. You can also set the gas limit when deploying a contract using deploy() method.

Note that the actual gas cost of a transaction may vary depending on the current gas price and network conditions, so you may need to experiment with different gas limit values to find the optimal value for your use case.


Iw as able to figure out the answer for this problem and it was because of the amount of block confirmations I provided in my deploy-fund-me.js

excerpt of the code const fundMe = await deploy("FundMe", { from: deployer, args: [ethUsdPriceFeedAddress], //args: [address], log: true, // we need to wait if on a live network so we can verify properly waitConfirmations: network.config.blockConfirmations || 1, })

I changed it from 5 to 1 and it moved. I also noticed one more issue with the fundme.test.js

the unit test kept failing with + expected - actual


I change the conditional check to //assert.equal(response, mockV3Aggregator.address) expect(mockV3Aggregator.address).to.exist

as the comparative address was not equal so i just checked if it exist.

Thanks for your guidance all this while.

~Cheers Sameer Varpe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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