Replies: 2 comments
-
I run into the same error in the "returns false if lottery isn't open" test with the following code: it("returns false if lottery isn't open", async function () {
await Lottery.enterLottery({ value: entranceFee })
await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
await network.provider.send("evm_mine", [])
await Lottery.performUpkeep("0x")
const lotteryState = await Lottery.getLotteryState()
const { upkeepNeeded } = Lottery.callStatic.checkUpkeep([])
assert.equal(lotteryState.toString(), "1")
assert.equal(upkeepNeeded, false)
}) This error could be occuring due to a error in the logic of my contract. if (!upkeepNeeded) {
revert Lottery__UpkeepNotNeeded(
address(this).balance,
s_players.length,
uint256(s_LotteryState)
); to if (upkeepNeeded) {
revert Lottery__UpkeepNotNeeded(
address(this).balance,
s_players.length,
uint256(s_LotteryState)
); I get one error or the other |
Beta Was this translation helpful? Give feedback.
-
Finally after some hourse investigating i was able to make it work for those who have the same issue as me here are the steps that i took:
- if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
await vrfCoordinatorV2Mock.addConsumer(subscriptionId, lottery.address)
} (if you get errors try moving these lines after the declarations of variables) After checking these steps you should be able to run the test correctly, if not continue checking your code and reading the discussion tabs. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Hello I am getting the same error as many people in the discussion tab but I can't find the soultion even with the given answers.
Here is the reposatory of current code when running into this error:
https://github.com/pirqqs/Repo-for-ERROR-in-LESSON-9/tree/main/contracts
The error occurs when testing the "doesn't allow entrance when Lottery is caluclating" test here is the code:
As well here is my solidity code for the performUpkeep function:
Here is the error:
Any help would be highly appriciated, let me know if you need to me provide anything else.
Beta Was this translation helpful? Give feedback.
All reactions