Lesson 09: Few questions reg. massive Unit test fulfillRandomWords() #2432
-
Hey everyone, 1). Why is there a need to mock the await vrfCoordinatorV2Mock.fulfillRandomWords(txReceipt.events[1].args.requestId, raffle.address) Usually, when we run Patrick says that it enables emitting the event 2). What exactly is the purpose of placing the asserts inside Patrick says that it helps us catching any error that happens when our test-code is running and the Is it because the 3). Staging Test: What does Blockchain moving fast has to do here ? I mean why below code is kept inside the // Then entering the raffle
console.log("Entering Raffle...")
const tx = await raffle.enterRaffle({ value: raffleEntranceFee }) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
I will check this later. PS do leave a reply for notification. |
Beta Was this translation helpful? Give feedback.
-
I have tried to clear as mush as possible hope it helps! |
Beta Was this translation helpful? Give feedback.
-
@ManuWeb3 : Tell me what your query is! or any doubts down below! |
Beta Was this translation helpful? Give feedback.
@ManuWeb3
See we want the Chainlink nodes to continuously check for the checkUpkeep functions and when all conditions get true, they should call the performUpkeep and fulfillRandomWords functions for us. But the unit tests run locally, which means they are not connected to internet/Chainlink nodes and in order to test the same functionality, we need to call these functions ourselves locally. That's what we are doing here.
First, we entered a couple of accounts/players into the lottery, then we call the enterRaffle function. Now inside the promise, we are doing two things, 1 listing for the WinnerPicked event, and 2 at the end calling the above-mentioned functions ourselfes (In the stagi…