Lesson 9: Quick question about performUpKeep test #1897
-
Hello guys, at 15:44:30, I just wanna know why the: describe("performUpKeep", function () {
it("it can only run if checkupkeep is true", async function () {
await raffle.enterRaffle({ value: raffleEntranceFee })
await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
await network.provider.send("evm_mine", [])
const tx = await raffle.performUpkeep([])
assert(tx)
})
}) code works when it seems like we are only passing in the entrance fee and the interval and maybe also hasPlayers since the deployer passed in the balance. I thought for upkeepNeeded to be true it was |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No worries, see: const tx = await raffle.performUpkeep([]) When the above gets called, the performUpkeep function of the Raffle contract is executed. And on further inspection, you will see that we further call checkUpkeep inside that function. Then, we use the conditionals you mentioned (for logic). Put simply, performUpkeep is already using the |
Beta Was this translation helpful? Give feedback.
No worries, see:
When the above gets called, the performUpkeep function of the Raffle contract is executed. And on further inspection, you will see that we further call checkUpkeep inside that function. Then, we use the conditionals you mentioned (for logic).
Put simply, performUpkeep is already using the
upkeepNeeded = (isOpen && timePassed && hasPlayers && hasBalance);
inside checkUpkeep.