This is my repo if needed.
\nhttps://github.com/Glow-in-the-dark/Solidity-playground/tree/main/EtherJS_Hardhat/hardhat-smartcontract-lottery
Additionally I think you are missing adding consumer in your deploy script:
\nawait vrfCoordinatorV2Mock.addConsumer(subscriptionId, raffle.address)
Without this your subscriptionId will throw you invalidConsumer as it is not added to vrf list. You can additionally checkout my repo here for fully automated process for all networks.
","upvoteCount":0,"url":"https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/5695#discussioncomment-6210305"}}}-
Not sure how to debug/fix the "invalid Consumer()' Error This portion of my raffle.test.js failed. it("doesn't allow entrance when raffle is calculating", async function () {
await expect(raffle.enterRaffle({ value: raffleEntranceFee }));
await network.provider.send("evm_increaseTime", [
interval.toNumber() + 1,
]);
await network.provider.send("evm_mine", []); // we use [] empty array cause we just want to mine 1 empty block
// await network.provider.request({ method: "evm_mine", params: [] }); // same as above, but top one more succinct
// Since we enterRaffle, and it should be "isOpen", "timePassed", "hasPlayer", "hasBalance" all true,
// Then now we can PRETEND to be a chainlink keeper, to call performUpkeep().
await raffle.performUpkeep([]); // we pass an empty [], because it's an empty calldata.
// NOW, this should be in a "CALCULATING" state.
await expect(
raffle.enterRaffle({ value: raffleEntranceFee })
).to.be.revertedWith("Raffle__NotOpen");
}); This is my repo if needed. |
Beta Was this translation helpful? Give feedback.
-
Hello @Glow-in-the-dark The problem is with your deploy script I believe. } else {
// else if it is live Testnet's network instead,
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"];
subscriptionId = networkConfig[chainId]["subscriptionId"]; // In this case, we hardcoded it because we use the website UIUX to get it, but we can automate it like above too.
} Here you are getting subscriptionId from your 31337: {
name: "localhost",
subscriptionId: "0",
}, This should fix your problem, if not let me know |
Beta Was this translation helpful? Give feedback.
Additionally I think you are missing adding consumer in your deploy script:
Without this your subscriptionId will throw you invalidConsumer as it is not added to vrf list. You can additionally checkout my repo here for fully automated process for all networks.