1) Raffle Unit Test fulfillRandomWords can only be called after performUpkeep: TypeError: vrfCoordinatorV2Mock.fullfillRandomWords is not a function #4753
SurajPoddar02
started this conversation in
General
Replies: 2 comments
-
please help i am stuck there.... |
Beta Was this translation helpful? Give feedback.
0 replies
-
You have misspelled the function. Change |
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
-
describe (" fulfillRandomWords", function () {
beforeEach(async function () {
await raffle.enterRaffle({ value: raffleEntranceFee })
await network.provider.send("evm_increaseTime", [interval.toNumber() + 1])
await network.provider.request({ method: "evm_mine", params: [] })
})
it("can only be called after performUpkeep",async function () {
await expect(
vrfCoordinatorV2Mock.fullfillRandomWords(0, raffle.address).to.be.revertedWith("nonexistant request")
)
await expect(
vrfCoordinatorV2Mock.fullfillRandomWords(1, raffle.address).to.be.revertedWith("nonexistant request")
)
})
})
function fulfillRandomWords(
uint256 /requestId/,
uint256[] memory randomWords) internal override
{
uint256 indexOfWinner = randomWords[0]%s_players.length;
address payable recentWinner = s_players[indexOfWinner];
s_recentWinner = recentWinner;
s_raffleState = RaffleState.OPEN;
s_players = new address payable;// reset of s_players.
s_lastTimeStamp = block.timestamp;
(bool success, ) = recentWinner.call{value : address(this).balance}("");
if(!success) {
revert Raffle_TransferFailed();
}
emit WinnerPicked(recentWinner);
}
Beta Was this translation helpful? Give feedback.
All reactions