Lesson 9[15:37:00] : Error: VM Exception while processing transaction: reverted with custom error 'InvalidConsumer()' #5242
Answered
by
alymurtazamemon
mrtechnostart
asked this question in
Q&A
-
unit-test.jsconst { assert, expect } = require("chai");
const { getNamedAccounts, deployments, ethers, network } = require("hardhat");
const { networkConfig } = require("../../helper-hardhat-config");
describe("Raffle", async () => {
const chainId = network.config.chainId;
let deployer, interval;
let Raffle;
const minEth = ethers.utils.parseEther("0.21");
let VRFCoordinatorV2Mock;
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
Raffle = await ethers.getContract("Raffle", deployer);
VRFCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock");
interval = await Raffle.getInterval();
});
describe("constructor", async () => {
it("Checking If Everything Is Set Properly ", async () => {
assert.equal(
interval,
networkConfig[chainId]["interval"]
);
assert.equal(
await Raffle.getEntranceFee(),
ethers.utils.parseEther("0.2").toString()
);
assert.equal(await Raffle.getRaffleState(), "0");
assert.equal(
await Raffle.getVRFCoordinatorAddress(),
VRFCoordinatorV2Mock.address
);
});
});
describe("enterRaffle", async () => {
it("Must get reverted when less ETH is paid", async () => {
await expect(Raffle.enterRaffle()).to.be.revertedWith(
"Raffle__SendMoreToEnterRaffle"
);
});
it("Must allow user to enter if minimum amount of ETH is paid & amount is credited to Contract Wallet", async () => {
await Raffle.enterRaffle({ value: ethers.utils.parseEther("0.21") });
assert.equal(
ethers.utils.parseEther("0.21").toString(),
await ethers.provider.getBalance(Raffle.address)
);
});
it("Records player when they participates in Lottery", async () => {
await Raffle.enterRaffle({ value: minEth });
const playerArray = await Raffle.getPlayer(0);
assert.equal(playerArray,deployer)
});
it("Must emit Raffle Enter Event", async ()=>{
// const event = await Raffle.enterRaffle({value:minEth});
// const response =await event.wait(1);
// assert.equal(response.events[0].args.player,deployer);
await expect(Raffle.enterRaffle({value:minEth})).to.emit(Raffle,"RaffleEnter");
})
it("Must Not Allow Participants When In Calculating Stage",async ()=>{
await Raffle.enterRaffle({value:minEth});
await network.provider.send("evm_increaseTime",[interval.toNumber()+1])
await network.provider.send("evm_mine",[])
await Raffle.performUpkeep([]);
await expect(Raffle.enterRaffle({value:minEth})).to.be.revertedWith("Raffle__RaffleNotOpen")
})
});
}); Error
00-deploy-mocks.jsconst { network, ethers } = require("hardhat");
const { developmentChains } = require("../helper-hardhat-config");
const BASE_FEE = ethers.utils.parseEther("0.25");
const GAS_PRICE_LINK = 1e9;
module.exports = async ({ deployments, getNamedAccounts }) => {
const { deployer } = await getNamedAccounts();
const { deploy, log } = deployments;
if (developmentChains.includes(network.name)) {
log("Deploying Mocks Now!, Local Chains Detected");
await deploy("VRFCoordinatorV2Mock", {
from: deployer,
args: [BASE_FEE, GAS_PRICE_LINK],
log: true,
});
log("Mocks Deployed!");
}
};
module.exports.tags = ["all","mocks"]
|
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Apr 6, 2023
Replies: 1 comment 1 reply
-
@mrtechnostart Please Check this #1375 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
alymurtazamemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mrtechnostart Please Check this #1375