-
Error got while testing test.staging.js file Error => Error: Timeout of 40000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. code describe("fulfillRandomWords",()=>{
it("works with live ChainLink Keepers and chainLink VRF, we get a random winner",
async ()=>{
const startingTimeStampe = await raffle.getLastTimeStamp();
const accounts = await ethers.getSigners();
await new Promise(async (resolve, reject) => {
// setup listener before we enter the raffle
// Just in case the blockchain moves REALLY fast
raffle.once("WinnerPicked", async () => {
console.log("WinnerPicked event fired!")
try {
// add our asserts here
const recentWinner = await raffle.getRecentWinner()
const raffleState = await raffle.getRaffleState()
const winnerEndingBalance = await accounts[0].getBalance()
const endingTimeStamp = await raffle.getLastTimeStamp()
await expect(raffle.getPlayer(0)).to.be.reverted
assert.equal(recentWinner.toString(), accounts[0].address)
assert.equal(raffleState, 0)
assert.equal(
winnerEndingBalance.toString(),
winnerStartingBalance.add(raffleEntranceFee).toString()
)
assert(endingTimeStamp > startingTimeStamp)
resolve()
} catch (error) {
console.log(error)
reject(error)
}
})
// Then entering the raffle
console.log("Entering Raffle...")
const tx = await raffle.enterRaffle({ value: raffleEntranceFee })
await tx.wait(1)
console.log("Ok, time to wait...")
const winnerStartingBalance = await accounts[0].getBalance()
// and this code WONT complete until our listener has finished listening!
})
})
}) github link for more code "https://github.com/kantoash/Raffle" |
Beta Was this translation helpful? Give feedback.
Answered by
pacelliv
Oct 23, 2022
Replies: 2 comments 20 replies
-
A. You have a typo in the name of this variable:
It should be B. In hardhat.config.js file make the mocha section look like this:
Using setTimeout like you currently have it is not giving enough time for the Promise to be resolved. |
Beta Was this translation helpful? Give feedback.
20 replies
Answer selected by
kantoash
-
here it is "0xdB6A64EB9C8E4DD02fA0C08cb70a33576485F48b" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A. You have a typo in the name of this variable:
It should be
startingTimeStamp
B. In hardhat.config.js file make the mocha section look like this:
Using setTimeout like you currently have it is not giving enough time for the Promise to be resolved.