Custom Error 'InvalidSubscription()' at Lesson 9 during test #1840
-
Hiii everyone, just got an error at lesson 9 "lottery-contract" while testing it("doesn't allow entrance when raffle is calculating", async () => {
await raffle.enterRaffle({ value: raffleEntranceFee })
await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
await network.provider.send({ method: "evm_mine", params: [] })
await raffle.performUpkeep([])
await expect(raffle.enterRaffle({ value: raffleEntranceFee })).to.be.revertedWith(
"Raffle__NotOpen"
)
}) The error is
my deploy scripts 00-deploy-mock.js const { 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 function({getNamedAccounts, deployments}) {
const {deploy, log} = deployments;
const {deployer} = await getNamedAccounts();
const args = [BASE_FEE, GAS_PRICE_LINK]
const chainId = network.config.chainId
if(chainId == 31337){
log("Local Network Detected! Deploying mocks.......");
await deploy("VRFCoordinatorV2Mock",{
from: deployer,
log: true,
args: args,
});
log("MOCK DEPLOYED")
log("-------------------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"]; 01-deploy-raffle.js const { network, ethers, getNamedAccounts, run, deployments } = require("hardhat");
const { developmentChains, networkConfig} = require("../helper-hardhat-config");
const {verify} = require("../utils/verify");
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("30");
module.exports = async function({getNamedAccounts, deployments}) {
const {deploy, log} = deployments;
const {deployer} = await getNamedAccounts();
const chainId = network.config.chainId;
let vrfCoordinatorV2Address, subscriptionId;
if(chainId == 31337){
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock");
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address;
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription();
const transactionReceipt = await transactionResponse.wait();
subscriptionId = transactionReceipt.events[0].args.subId;
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
}
else{
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"];
subscriptionId = network[chainId]["subscriptionId"];
}
const entranceFee = networkConfig[chainId]["entranceFee"];
const gasLane = networkConfig[chainId]["gasLane"];
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"];
const interval = networkConfig[chainId]["interval"];
const args = [vrfCoordinatorV2Address ,entranceFee, gasLane, subscriptionId, callbackGasLimit, interval]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1
});
if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY){
log("Verifying........");
await verify(raffle.address, args)
}
log("-------------------------------------------------------------");
}
module.exports.tags = ["all", "raffle"] And my helper-hardhat-config.js const { ethers } = require("hardhat");
const networkConfig = {
4:{
name: "rinkeby",
vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId: "10645",
callbackGasLimit: "500000",
interval: "30",
},
31337: {
name:"hardhat",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callbackGasLimit: "500000",
interval: "30",
}
}
const developmentChains = ["hardhat", "localhost"];
module.exports = {
networkConfig,
developmentChains
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
@maadi7 Push the code to repo and leave a link here I will check the issue. |
Beta Was this translation helpful? Give feedback.
-
Could you push to a repo and link it here, thanks |
Beta Was this translation helpful? Give feedback.
-
The order of arguments is incorrect in accordance to constructor in your raffle.sol : const args = [vrfCoordinatorV2Address ,entranceFee, gasLane, subscriptionId, callbackGasLimit, interval] In 01-deploy-raffle.js try this instead: const args=[
vrfCoordinatorV2Address,
subscriptionId,
gasLane,
entranceFee,
callbackGasLimit,
interval
] |
Beta Was this translation helpful? Give feedback.
The order of arguments is incorrect in accordance to constructor in your raffle.sol :
In 01-deploy-raffle.js try this instead: