I am trying to write a smart contract interacting with AAVE and Uniswap. Is there anyway to test my smart contract locally using Ganache or Hardhat node?
You can do it two ways
- Using mainnet forks: Super slow to, but needs less testing code to write. Prone to test failures becausing using live data.
- Deploying Uniswap and Aave locally using your test code and setting up tokens with fake balances: tests run 100x faster.
Another possible solution could be mocking the functionality that you will be interacting with.
The functions you will be using from Uniswap or Aave will have an input and provide you with an expected output. You can essentially mock these functions to behave in an expected way, to further test your code's behavior and interaction with Uniswap or Aave.
I would recommend this approach if there aren't many complicated interactions with the external code base. Good luck!