Lesson 9: Error Timeout of 200000ms exceeded (in the promise test) #3166
-
Hi all I have been trying to debug this all morning. So far I have tried increasing the timeout in hardhat.config (all the way to 900000). Checked for spelling mistakes and read through several github discussion posts with a similar title. If anybody could shed some light on this, I would really appreciate it. I put the whole describe in below, the first "it" works fine. describe("fulfill random words", function () {
beforeEach(async function () {
await lottery.enterLottery({ value: lotteryEntranceFee })
await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
await network.provider.send("evm_mine", [])
})
it("can only be called after performupkeep", async function () {
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(0, lottery.address)
).to.be.revertedWith("nonexistent request")
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(1, lottery.address)
).to.be.revertedWith("nonexistent request")
})
it("picks a winner, resets the lottery and sends money", async function () {
const additionalEntrants = 3
const startingAccountIndex = 1 // deployer = 0
const accounts = await ethers.getSigners()
for (
let i = startingAccountIndex;
i < startingAccountIndex + additionalEntrants;
i++
) {
const accountConnectedLottery = lottery.connect(accounts[i])
await accountConnectedLottery.enterLottery({ value: lotteryEntranceFee })
}
const startingTimeStamp = await lottery.getLatestTimeStamp()
// performUpkeep (mock being chainlink keepers)
// fulfillRandomWords (mock being chainlink VRF)
// have to wait for fulfillRandomWords to be called
await new Promise(async (resolve, reject) => {
lottery.once("WinnerPicked", async () => {
console.log("Found the event!")
try {
const recentWinner = await lottery.getRecentWinner()
console.log(recentWinner)
console.log(accounts[2])
console.log(accounts[0])
console.log(accounts[1])
console.log(accounts[3])
const lotteryState = await lottery.getLotteryState()
const endingTimeStamp = await lottery.getLatestTimeStamp()
const numPlayers = await lottery.getNumberOfPlayers()
const winnerEndingBalance = await accounts[1].getBalance()
assert.equal(numPlayers.toString(), "0")
assert.equal(lotteryState.toString(), "0")
assert(endingTimeStamp > startingTime)
assert.equal(
winnerEndingBalance.toString(),
winnerStartingBalance.add(
lotteryEntranceFee
.mul(additionalEntrants)
.add(lotteryEntranceFee)
.toString()
)
)
resolve()
} catch (e) {
reject(e)
}
})
// setting up listener
// below we fire the event, listener will pick it up and resolve
const tx = await lottery.performUpkeep([])
const txReceipt = await tx.wait(1)
const winnerStartingBalance = await accounts[1].getBalance()
await vrfCoordinatorV2Mock.fulfillRandomWords(
txReceipt.events[1].args.requestId,
lottery.address
)
})
})
}) link to the repo - https://github.com/SimSimButDifferent/hardhat-smartcontract-lottery-fcc Any help much appreciated as always. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Still trying to debug this one, any suggestions? |
Beta Was this translation helpful? Give feedback.
-
@SimSimButDifferent : I have made PRs in your repo, Merge them and try them out! After Merging, It should work just fine! Let me know, If it resolves your issue! |
Beta Was this translation helpful? Give feedback.
@SimSimButDifferent : I have made PRs in your repo, Merge them and try them out!
After Merging, It should work just fine!
Let me know, If it resolves your issue!