-
the code returns a timeout error error:
code: await new Promise(async (resolve, reject) => {
raffle.once("Winner Picked", async () => {
console.log("Found the event!")
try {
console.log(recentWinner)
console.log(accounts[0].address)
console.log(accounts[1].address)
console.log(accounts[2].address)
console.log(accounts[3].address)
const recentWinner = await raffle.getRecentWinner()
const raffleState = await raffle.getRaffleState()
const endingTimestamp = await raffle.getLastTimeStamp()
const numPlayers = await raffle.getNumberOfPlayers()
assert.equal(numPlayers.toString(), "0")
assert.equal(raffleState.toString(), "0")
assert(endingTimestamp > startingTimeStamp)
resolve()
} catch (e) {
reject(e)
}
})
//setting up the listener
//the code below will fire the event, listener will pick it up and resolve
const tx = await raffle.performUpkeep([])
const txReceipt = await tx.wait(1)
await vrfCoordinatorV2Mock.fulfillRandomWords(
txReceipt.events[1].args.requestId,
raffle.address
)
}) |
Beta Was this translation helpful? Give feedback.
Answered by
ghost
Jul 31, 2022
Replies: 2 comments
-
console.log(recentWinner)
console.log(accounts[0].address)
console.log(accounts[1].address)
console.log(accounts[2].address)
console.log(accounts[3].address)
const recentWinner = await raffle.getRecentWinner() Here you are loggin recent winner before decleration |
Beta Was this translation helpful? Give feedback.
0 replies
-
I could not figure out the problem but the copied code from GitHub works |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I could not figure out the problem but the copied code from GitHub works