0

This is aave protocol v2: https://github.com/aave/protocol-v2

They have a built-in test suite. Running npm run test runs all the tests cases properly. But this runs on hardhat node. I need to change the network to ganache. Can't find the configuration codes to run on ganache.

Any idea where or on which file I can change the network configuration? Any hint would save my day. Thanks a lot.

1 Answer 1

0

Option 1

If you don't want to manually start and stop Ganache every time, you can use the hardhat-ganache plugin.

This plugin creates a network called ganache, and automatically starts and stops Ganache before and after running your tests and scripts.

o use it, you have to install it with npm

npm install --save-dev @nomiclabs/hardhat-ganache

and add this line at the beginning of your hardhat.config.js

require("@nomiclabs/hardhat-ganache");

Finally, you can run your tests with

npx hardhat --network ganache test

Option 2 In your hardhat.config file include the ganache info in the networks part:

module.exports = {
  defaultNetwork: "ganache",
  networks: {
    ganache: {
      gasLimit: 6000000000,
      defaultBalanceEther: 10,
    },
  },
};

Finally, you can run your tests with

npx hardhat test --network ganache
3
  • Thanks a lot for the response. But I am getting this error on Option 1. Error in plugin @nomiclabs/hardhat-ganache: Ganache network only works with localhost. Aug 10, 2022 at 9:33
  • Getting this error on option 2: Error in plugin @nomiclabs/hardhat-ganache: Ganache network config is invalid: value.accounts is not an array Can you have a look at this config file and provide me a direction? I am out of ideas. github.com/aave/protocol-v2/blob/master/hardhat.config.ts Aug 10, 2022 at 10:03
  • There seems to be an issue with naming the network as ganache. When I changed it to ganache_local it deployed properly without that error.
    – rosendin
    Oct 17, 2022 at 19:22

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.