Getting error while running my staging test in lesson 9 #6019
-
Error: Timeout of 500000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/root/hardhat-fcc/hardhat-smartcontract-lottery-fcc/test/staging/Raffle.Staging.test.js)Staging test codeconst { network, getNamedAccounts, deployments, ethers } = require("hardhat")
const { developmentChain, networkConfig } = require("../../helper-hardhat-config")
const { assert, expect } = require('chai')
developmentChain.includes(network.name)
? describe.skip
: describe("Raffle Test", async () => {
let raffle, raffleEntranceFee, deployer
beforeEach(async () => {
deployer = (await getNamedAccounts()).deployer
raffle = await ethers.getContract("Raffle", deployer)
raffleEntranceFee = await raffle.getEnteranceFee()
})
describe("fullfillRandomWords", () => {
it("works with live chainlink keepers and chainlink VRF , we get a random winner", async () => {
// enter the raffle
const startingTimestamp = await raffle.getLatestTimeStamp()
const accounts = await ethers.getSigners()
let winnerStartingBal
await new Promise(async (resolve, reject) => {
raffle.once("WinnerPicked", async () => {
console.log("WinnerPicked event fired...")
try {
const recentWinner = await raffle.getRecentWinner()
const raffleState = await raffle.getRaffleState()
const winnerBalance = await accounts[0].provider.getBalance()
const endingTimestamp = await raffle.getLatestTimeStamp()
await expect(raffle.getPlayer(0)).to.be.reverted
assert.equal(recentWinner.toString(), accounts[0].address)
assert.equal(raffleState, 0)
assert(endingTimestamp > startingTimestamp)
// prize won by winner
const prizeWon = winnerBalance - winnerStartingBal
// prize money
// const winnerPirze = toNumber(raffleEntranceFee) * (additionalEntrace)
assert.equal(prizeWon.toString(), (toNumber(raffleEntranceFee)).toString())
resolve()
} catch (e) {
console.log(e)
reject(e)
}
})
await raffle.enterRaffle({ value: raffleEntranceFee })
await tx.wait(1)
console.log("Ok, time to wait...")
winnerStartingBal = await accounts[0].provider.getBalance()
})
// setup the listner before we enter the raffle
})
})
}) What i understand is that WinnerPicked event is not getting fired |
Beta Was this translation helpful? Give feedback.
Answered by
shikhar229169
Aug 18, 2023
Replies: 2 comments 14 replies
-
Can you provide your contract address. |
Beta Was this translation helpful? Give feedback.
13 replies
-
@Neftyr Thankyou Mate |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually you have not added the contract 0x126e8282a53A34fAEa5A1843CC2D5Bab578e3200 in your subscription.