Error: Timeout of 200000ms exceeded. For async tests and hooks, ensure "done()" #1586
Answered
by
alymurtazamemon
AwaisTahseencode
asked this question in
Q&A
-
describe("fullfilRandomWords",()=>{
beforeEach(async()=>{
await raffle.enterRaffle({value:entranceFee})
await network.provider.send("evm_increaseTime",[interval.toNumber() + 1])
await network.provider.send("evm_mine",[])
})
it("it can only be called after performUpkeep",async()=>{
await expect(vrfCoordinatorV2.fulfillRandomWords(0,raffle.address)).to.be.revertedWith("nonexistent request")
await expect(vrfCoordinatorV2.fulfillRandomWords(1,raffle.address)).to.be.revertedWith("nonexistent request")
})
it("picks the winner,reset the array, send the money",async()=>{
const accounts=await ethers.getSigners()
const startingIndex=1
const endingIndex=3
// let raffleContract
for(let i=startingIndex;i<=endingIndex;i++){
const accountConnectedRaffle=raffle.connect(accounts[i])
await accountConnectedRaffle.enterRaffle({value:entranceFee})
}
const startingTimeStamp=await raffle.getLastTimeStamp()
await new Promise (async(resolve,reject)=>{
raffle.once("winnerPicked",async()=>{
try {
console.log("Winner has been picked")
const recentWinner=await raffle.getRecentWinner()
console.log(recentWinner)
console.log(accounts[1])
console.log(accounts[2])
console.log(accounts[3])
console.log(accounts[1])
const endingBalance=await raffle.getBalance()
const winnerBalance=await accounts[1].getBalance()
const lastTimeStamp=await raffle.lastTimeStamp()
const raffleState=await raffle.getRaffleState()
// await expect(raffleContract.getPlayer(0)).to.be.reverted
assert.equal(recentWinner.toString(),accounts[1].address)
assert.equal(raffleState,0)
assert.equal(winnerBalance.toString(),startingBalance.add(entranceFee.mul(endingIndex).add(entranceFee)).toString())
assert.equal(endingBalance.toNumber(),0)
assert(lastTimeStamp>startingTimeStamp)
// done()
resolve()
} catch (error) {
reject(error)
}//end of try catch
})
await network.provider.send("eth_increaseTime",[interval.toNumber() + 1])
await network.provider.send("evm_mine",[])
const transactionResponse=await raffle.performUpkeep([])
const transactionReceipt=await transactionResponse.wait(1)
const startingBalance=await accounts[1].getBalance()
await vrfCoordinatorV2Mock.fulfillRandomWords(
transactionReceipt.events[1].args.requestId,
raffle.address
)
})//end of Promise
})//end of it
}) I have also set the moch timout 30000 but no use |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Aug 7, 2022
Replies: 1 comment 10 replies
-
@AwaisTahseencode set your mocha time to 50000, and make sure your event name is |
Beta Was this translation helpful? Give feedback.
10 replies
Answer selected by
alymurtazamemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AwaisTahseencode set your mocha time to 50000, and make sure your event name is
winnerPicked
.