2

I have seen similar questions using the chainlink VRF v1 but I don't manage to make them work.

I have tried to:

  • create a subscription on rinkeby chainlink
  • add the address of my locally deployed contract
  • add some LINK to the subscription
  • fork rinkeby for testing

This somehow worked (not always, not sure why) ; but I don't understand how to test the callback function because no chainlink node is listening to my events...

2 Answers 2

2

Here's an article I wrote on this which might help: https://dev.to/abhikbanerjee99/testing-your-chainlink-vrf-powered-smart-contract-m3i

Chainlink provides mocks for data feeds aggregator and VRF (v1 and v2) which you can use for testing your smart contract.

0

Unit tests can be achieved via mock responses. This will keep each test independent and the responses from the oracle network are mocked. To see an example of how to do this take a look at the hardhat starter kit. Currently, it is in the process of being updated to include VRFv2 and tests for them. This PR has the relevant files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.