Revert on `evm_increaseTime` when running test on mainnet fork

hardhathardhat-deploytesting

I am trying to run the test on mainnet fork using hardhat-deploy example template, particularly the for-test branch example.

https://github.com/wighawag/template-ethereum-contracts/tree/examples/fork-test/

After providing the .env variables. I ran yarn fork:test mainnet

But I kept getting stuck at this particular error on the aToken_Dai test. I thought maybe the ABI was outdated and tried updating it from the mainnet contract but still doesn't work. Test kept getting reverted when running evm_increaseTime. Am I missing anything that needs to pass the test?

aave.test.ts

   ...
    await network.provider.request({
      method: 'evm_increaseTime',
      params: [3600 * 24 * 365],
    });
   ...

$ node ./_scripts.js fork:test mainnet


  GreetingsRegistry
Nothing to compile
No need to generate any newer typings.
    ✔ setMessage works (7855ms)

  SimpleERC20
    ✔ transfer fails
    ✔ transfer succeed

  aToken_Dai
    1) aToken_Dai works


  3 passing (43s)
  1 failing

  1) aToken_Dai
       aToken_Dai works:
     Error: VM Exception while processing transaction: revert SafeERC20: low-level call failed
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at <UnrecognizedContract>.<unknown> (0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at HardhatNode._mineBlockWithPendingTxs (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:1154:23)
    at HardhatNode.mineBlock (node_modules/hardhat/src/internal/hardhat-network/provider/node.ts:377:16)
    at EthModule._sendTransactionAndReturnHash (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:1377:18)
    at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:101:18)
    at EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

Best Answer

The .env.example provided by the project seems to be missing a few environment variables that are being used in hardhat.config.ts.

In your .env, make sure to set HARDHAT_FORK to mainnet. Also, make sure to set HARDHAT_FORK_NUMBER to a block number where all dependent contracts already exist on mainnet.

Related Topic