1

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?

2 Answers 2

1

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.

Some examples of deploying Uniswap for testing.

2
  • Thanks for your answer but How can I get fake AAVE token locally? Jun 21, 2022 at 2:20
  • You deploy any ERC-20 token and call it Aave. Jun 21, 2022 at 3:32
0

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!

Your Answer

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

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