5

I want to run my tests on testnet, mainly because I need to test chainlink VRF. How can I do that?

this is my hardhat.config.js:

require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-waffle");
require('dotenv').config()

const INFURA_URL = "https://rinkeby.infura.io/v3/" + process.env.INFURA_API_KEY;
const owner = process.env.PK;
const alice = process.env.ALICE;
const bob = process.env.BOB;

module.exports = {
  networks: {
    hardhat:{},
    rinkeby: {
      url: INFURA_URL,
      accounts: [`0x${owner}`, `0x${alice}`, `0x${bob}`]
    }
  },
  solidity: {
    version: "0.8.4",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
};

I'm having this error after running npx hardhat test --network rinkeby:

      "before each" hook for "Should set the right owner":
    Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

This is the code part where is the error: nft.test.js

beforeEach(async () => {
    NFT = await ethers.getContractFactory("NFT");
    nft = await NFT.deploy(
      initURI,
      secretURI,
      linkToken,
      vrfCoordinator,
      keyHash,
      linkFee
    );
    await nft.deployed();
    [owner, alice, bob, _] = await ethers.getSigners();
  });

1 Answer 1

2

Make sure your accounts have balances. And you can config the timeout depends on each network by adding a timeout property in milliseconds (https://hardhat.org/config/#json-rpc-based-networks)

example:

rinkeby: {
  url: INFURA_URL,
  accounts: [`0x${owner}`, `0x${alice}`, `0x${bob}`],
  timeout: 60000
}
1
  • I have already funded the wallets but forgot about the timeout. Thanks!
    – n3n3
    Dec 3, 2021 at 13:47

Your Answer

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

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