Lesson 9: Assertion Error: + expected - actual #5676
-
OverviewI am trying to run the test for I am facing this error: Lottery Unit Test
fulfillRandomWords
Local network detected (Mock)! Deploying Mocks....
---------------------------------
Deploying Lottery: Local network detected (Mock)! Deploying Mocks....
vrfCoordinatorV2Address is 0x5FbDB2315678afecb367f032d93F642f64180aa3
✔ can only be called after performUpkeep (52ms)
Found the event!
0x70997970C51812dc3A010C7d01b50e0d17dc79C8
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
0x70997970C51812dc3A010C7d01b50e0d17dc79C8
0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
0x90F79bf6EB2c4f870365E785982E1f101E93b906
1) picks a winner and emits to a winner list, changes Lottery status to OPEN, resets the lottery array & timestamp, and send money or reverts error otherwise
1 passing (5s)
1 failing
1) Lottery Unit Test
fulfillRandomWords
picks a winner and emits to a winner list, changes Lottery status to OPEN, resets the lottery array & timestamp, and send money or reverts error otherwise:
AssertionError: expected '10000009929483662726540' to equal '10000029929483662726540'
+ expected - actual
-10000009929483662726540
+10000029929483662726540
at FragmentRunningEvent.<anonymous> (test\unit\Lottery.test.js:219:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at listOnTimeout (node:internal/timers:538:9)
at processTimers (node:internal/timers:512:7)
error Command failed with exit code 1. I have tried adding gasCost but I am facing the same error still. The gasCost code has been commented out from the function for the time-being. My Repo: https://github.com/Jatinkkalra/hardhat-smartcontract-lottery If anyone can help, it would be mean a lot. Thanks a ton in advance! 🙏 |
Beta Was this translation helpful? Give feedback.
Answered by
alfaqi
Jun 18, 2023
Replies: 1 comment 4 replies
-
@Jatinkkalra in your assert.equal(
winnerEndingBalance.toString(),
winnerStartingBalance
.add(
lotteryEntranceFee
.mul(additionalEntrants)
.add(lotteryEntranceFee)
// .add(gasCost) // Include gas cost in the calculation
)
.toString()
); with assert.equal(
winnerEndingBalance.toString(),
winnerStartingBalance
.add(
lotteryEntranceFee
.mul(additionalEntrants)
.add(lotteryEntranceFee)
.toString()
// .add(gasCost) // Include gas cost in the calculation
)
); |
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
1- issue with
BigNumber
musttoString()
be out ofadd
function, like thisthe issue of calculating the balance of winner was with closing
}
offor
loop, , like thisthen…