1
const { deployments, getNamedAccounts, ethers, network } = require("hardhat")
const { assert, expect } = require("chai")

const {
  developmentChains,
  networkConfig,
} = require("../../helper-hardhat-config.js")


developmentChains.includes(network.name)
  ? describe("Lottery", async function () {
      let lottery, vrfCoordinatorV2Mock, deployer, lotteryEnterenceFee, interval
      const chainId = network.config.chainId

      beforeEach(async function () {
        deployer = (await getNamedAccounts()).deployer
        await deployments.fixture(["all"])
        lottery = await ethers.getContract("Lottery", deployer)
        vrfCoordinatorV2Mock = await ethers.getContract(
          "VRFCoordinatorV2Mock",
          deployer
        )
        lotteryEnterenceFee = await lottery.getEnterenceFee()
        interval = await lottery.getInterval()
      })
      describe("enterRaffle", async function () {
        it("doesn't allow enterence when lottery is calculating...  ", async function () {
          await lottery.enterLottery({ value: lotteryEnterenceFee })
          await network.provider.request({
            method: "evm_increaseTime",
            params: [interval.toNumber() + 1],
          })
          await network.provider.request({
            method: "evm_mine",
            params: [],
          })
          await lottery.performUpkeep([])

          const getState = await lottery.getLotteryState()
          console.log(getState)
          await expect(lottery.enterLottery({ value: lotteryEnterenceFee })).to.be.reverted
        })
      })
    })
  : describe.skip

Error: 1 failing

  1. Lottery enterRaffle doesn't allow enterence when lottery is calculating... : Error: VM Exception while processing transaction: reverted with custom error 'InvalidConsumer()' at VRFCoordinatorV2Mock.onlyValidConsumer (@chainlink/contracts/src/v0.8/mocks/VRFCoordinatorV2Mock.sol:72) at VRFCoordinatorV2Mock.requestRandomWords (@chainlink/contracts/src/v0.8/mocks/VRFCoordinatorV2Mock.sol:147) at Lottery.performUpkeep (contracts/Lottery.sol:135)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) at runNextTicks (node:internal/process/task_queues:65:3) at listOnTimeout (node:internal/timers:528:9) at processTimers (node:internal/timers:502:7) at HardhatNode._mineBlockWithPendingTxs (node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:1819:23)
    at HardhatNode.mineBlock (node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:508:16) at EthModule._sendTransactionAndReturnHash (node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:1522:18)

I am not able to figure out what mistake I am making. Can someone help me out with this bug?

1
  • 1
    Check VRFCoordinatorV2Mock.sol, line no. 72 Feb 13 at 14:18

1 Answer 1

0

Check this out if you are running with same error: https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/1565

Your just need to install @chainlink/contracts by running:

npm install --save-dev @chainlink/[email protected]

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.