Skip to content

Raffle Staging Test Assertion Error. #348

Answered by knoori
Abhisek0x asked this question in Q&A
Discussion options

You must be logged in to vote

The transaction await raffle.enterRaffle({ value: raffleEntranceFee }) transfers the raffleEntranceFee to the Raffle contract and also costs some gas. Since const winnerStartingBalance = await accounts[0].getBalance() is executed after the transaction, in principle winnerStartingBalance should already include the gas cost.

However, in my case, winnerStartingBalance was not reflecting the updated account balance - possibly because the enterRaffle transaction wasn't being mined fast enough (?) - leading the to the same starting/ending balance assertion error that you're seeing.

I fixed the issue by modifying the code

console.log("Entering Raffle...")
const tx = await raffle.enterRaffle({ value

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Equious
Comment options

@PatrickAlphaC
Comment options

@PatrickAlphaC
Comment options

@SlothXGreaver
Comment options

@knoori
Comment options

Answer selected by PatrickAlphaC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants