I tried to test chainlink vrf at hardhat test with vrfcoordinatormock. test is work fine but random words and request id are always 0. is It correct that returning 0 from MockVRF?
const deployContract = async(vrfCoordinatorContract : "MockVRFCoordinator" | "MockVRFCoordinatorUnfulfillable" = "MockVRFCoordinator") => {
const Consumer = await ethers.getContractFactory("VRFv2Consumer");
vrfCoordFactory = await ethers.getContractFactory(vrfCoordinatorContract);
vrfCoordinatorV2Mock = await vrfCoordFactory.deploy();
return await Consumer.deploy(MOCK_SUBSCRIPTION_ID,keyHash,vrfCoordinatorV2Mock.address);
}
before(async () => {
const [owner] = await ethers.getSigners();
owner_wallet = owner.address;
const LotterPoly = await ethers.getContractFactory("LotterPoly");
})
it("Should successfully request a random number", async() => {
vrfv2Consumer = await deployContract();
let tx = await vrfv2Consumer.requestRandomness();
await tx.wait();
await new Promise(resolve => setTimeout(resolve, 30000));
const requestId = await vrfv2Consumer.s_requestId();
console.log(requestId);
const randomWord = await vrfv2Consumer.s_randomWords(0);
console.log(randomWord);
})