Lesson 9. Trying to use assert.approximately #6010
Answered
by
Nlferu
NickoMenty
asked this question in
Q&A
-
I am trying to check the sum amount after the raffle, and it seems that it takes some sort of fee that I am lacking. raffleEntranceFee = await raffle.getEntranceFee()
const winnerEndingBalance = Number( await ethers.provider.getBalance(accounts[1]), )
const winnerStartingBalance = Number( await ethers.provider.getBalance(accounts[1]), )
assert.approximately( winnerEndingBalance, winnerStartingBalance + Number(raffleEntranceFee) * additionalEntrants + Number(raffleEntranceFee), 0.001, ) My 0.001 delta is big enough to manage this difference. however I still receive an error:
|
Beta Was this translation helpful? Give feedback.
Answered by
Nlferu
Aug 16, 2023
Replies: 1 comment 4 replies
-
Much better way to test this will be adding gas cost calculation and deducting those from proper balance :) You can calculate exact transaction cost like below: let txReceipt = await txResponse.wait()
const gas = txReceipt.gasUsed
const gasPrice = txReceipt.effectiveGasPrice
const gasCost = gas.mul(newGasPrice) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me know if it was helpful, but from my experience console.log's are best friends in such tests :D