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
- 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?