smartcontractkit/full-blockchain-solidity-course-js

Leeson 9 - Timeout Error for doing Unit test(Raffle.test.js)

kds93419 opened this issue · 1 comments

Discussed in #6148

Originally posted by kds93419 September 21, 2023
Plz help me... i'cant find my mistake. i'm willing to test it(it("picks a winner, resets the lottery, and sends money")) but make a error(timeout)...

I've been struggling for several days.
image

https://github.com/kds93419/FCC-Lottery.git
here is my repo..thx

So after adding a try catch to your test file I found that the problem is that the "performUpkeep" function returns a "Raffle_UpkeepNotNeeded(30000000000000000, 3, 0)" error.

error_upkeepNeeded

The error is caused by the: bool timePassed = ((block.timestamp - s_lastTimeStamp) > i_interval); check inside of the checkUpkeep function - the i_interval set inside of the cunstructor is greater then the actual timestamp - the timestamps set in constructor.

The only way I found to make this code work was to decrease the "keepersUpdateInterval" inside of the helper-hardhat file from 30 seconds to like 2-3 seconds. But I am not sure how is it possible that the code from Patrick works with 30 seconds without increasing the time with evm_increaseTime.