Skip to content

Lesson: 9 || Unit testing for "returns false if enough time hasn't passed" fails [AssertionError: Unspecified AssertionError] #5915

Answered by Chevy3000
MohammadRokib asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you can do

const lotteryInitTimestamp = await lottery.getLatestTimeStamp()
console.log(lotteryInitTimestamp)

and

let blockTimestamp = (await ethers.provider.getBlock('latest')).timestamp
console.log(blockTimestamp)

in your test scripts to find out what the actual timestamps are and what's going wrong.

I was having the same issue, and I found that when my contract was deployed it saved s_lastTimeStamp as 1691781702 but when I called console.log(blockTimestamp) before running that test I got back 1691781703
then after running the enterLottery function I ran console.log(blockTimestamp) again and it had again increased by one to 1691781704.

Which means that the time had increased by 2 sin…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@mikechaban
Comment options

Answer selected by MohammadRokib
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants