Getting Error: Timeout of 200000ms exceeded in the promise test of Lesson 9 #637
-
I am trying to do the unit testing of the it("can only be called after performUpkeep", async function () {
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(0, raffle.address) //we have not called perform upkeep and with this request id (which is random and invalid requestId) we are expecting to get reverted.
).to.be.revertedWith("nonexistent request")
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(1, raffle.address)
).to.be.revertedWith("nonexistent request")
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(2, raffle.address)
).to.be.revertedWith("nonexistent request")
await expect(
vrfCoordinatorV2Mock.fulfillRandomWords(3, raffle.address)
).to.be.revertedWith("nonexistent request")
}) But, this test is not passing and I am getting a Timeout Error. it("picks a winner, resets the lottery, and sends money", async function () {
//we want to add some more people before we pick a winner
const additionalEntrants = 3
const startingAccountIndex = 1 //as deployer = 0
const accounts = await ethers.getSigners()
for (
let i = startingAccountIndex;
i < startingAccountIndex + additionalEntrants;
i++
) {
//connecting raffle to these new accounts and then entering these new accounts enter the raffle
const accountConnectedRaffle = await raffle.connect(accounts[i])
await accountConnectedRaffle.enterRaffle({ value: raffleEntranceFees })
}
const startingTimestamp = await raffle.getLatestTimeStamp()
//performUpkeep(mock being chainlink keepers)
//fulfillRandomWords(mock being chainlink vrf)
//we will have to wait for the fulfillRandomWords to be called.
//To simulate the waiting on the local chain, we will have to setup a listener.
console.log("##############################333333333333")
await new Promise(async (resolve, reject) => {
raffle.once("WinnerPicked", async () => {
console.log("Found the event!")
try {
//checking if the changes are properly done to the variables
//Our assert statements reside here.
const recentWinner = await raffle.getRecentWinner()
console.log(`Recent Winner --> ${recentWinner}`)
console.log(accounts[0].address)
console.log(accounts[1].address)
console.log(accounts[2].address)
console.log(accounts[3].address)
const raffleState = await raffle.getRaffleState()
const endingTimeStamp = await raffle.getLatestTimeStamp()
const numPlayers = await raffle.getNumerOfPlayers()
assert.equal(numPlayers.toString(), "0")
assert.equal(raffleState.toString(), "0")
assert(endingTimeStamp > startingTimestamp)
resolve()
} catch (e) {
reject(e)
}
//listening for the event to be emitted and then doing something //this is the listener
})//setting up listener
//below we will fire the event, and the listener will pick it up, and resolve.
const tx = await raffle.performUpkeep([]) //mocking the chainlink keepers
const txReceipt = await tx.wait()
await vrfCoordinatorV2Mock.fulfillRandomWords(
//mocking the chainlink vrf
txReceipt.events[1].args.requestId,
raffle.address
)
})
}) Patrick recommended the I have tried copy-pasting the code for this testing scenario from the GitHub repo of this lesson but I am getting the same timeout error. I would really appreciate if you guys can help be get unstuck! Edit: Even for 300s I am getting timeout error. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 16 replies
-
I am facing this problem too, I've seen some solution which was increasing the timeout and also increasing the compiler version, but they still don't work for me. You should give this a try and let me know if it works. And if you figure out something else, don't hesitate to share it here. I am stuck with this too. Thanks. |
Beta Was this translation helpful? Give feedback.
-
This means something is off with your keepers or vrf setup as they are not firing properly. Please see the troubleshooting guide: https://github.com/smartcontractkit/full-blockchain-solidity-course-js/blob/main/chronological-updates.md#keepers-not-kicking-off-troubleshooting |
Beta Was this translation helpful? Give feedback.
This means something is off with your keepers or vrf setup as they are not firing properly.
Please see the troubleshooting guide: https://github.com/smartcontractkit/full-blockchain-solidity-course-js/blob/main/chronological-updates.md#keepers-not-kicking-off-troubleshooting