Lesson 9 : TypeError: Cannot read properties of undefined (reading 'args') #5871
Unanswered
MrPositive0709
asked this question in
Q&A
Replies: 1 comment
-
Hey @MrPositive0709, you have to emit the event, emit RequestedRaffleWinner(requestId); and change event RequestedRaffleWinner(uint256 indexed requestId); and will run a new issue 1) Raffle Unit Tests
fulfillRandomWords
picks a winner, resets, and sends money:
ReferenceError: startingBalance is not defined I don't know why, but you can move this line outside of const startingBalance = await accounts[2].getBalance(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is my repo link : https://github.com/MrPositive0709/hardhat-smartcontract-lottery-fcc
When I use
hh test
to run the test , it returns me 2 failure tests with the similar reason :`hh test
Raffle Unit Tests
constructor
✔ initializes the raffle correctly
enterRaffle
✔ reverts when you don't pay enough
✔ records players when they enter
✔ emits event on enter
✔ doesn't allow entrance when raffle is calculating (47ms)
checkUpkeep
✔ returns false if people haven't sent any ETH
✔ returns false if raffle isn't open (41ms)
performUpkeep
✔ can only run if checkupkeep is true
✔ reverts if checkup is false
1) updates the raffle state and emits a requestId
fulfillRandomWords
✔ can only be called after performupkeep
2) picks a winner, resets, and sends money
10 passing (2s)
2 failing
Raffle Unit Tests
performUpkeep
updates the raffle state and emits a requestId:
TypeError: Cannot read properties of undefined (reading 'args')
at Context. (test/unit/Raffle.test.js:117:49)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
Raffle Unit Tests
fulfillRandomWords
picks a winner, resets, and sends money:
TypeError: Cannot read properties of undefined (reading 'args')
at /root/hh-fcc/hardhat-smartcontract-lottery-fcc/test/unit/Raffle.test.js:201:37
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)`
this is the snippet code of those 2 in my unit-test.js :
const requestId = txReceipt.events[1].args.requestId;
Beta Was this translation helpful? Give feedback.
All reactions