Testing
在主網分叉上執行測試時恢復“evm_increaseTime”
我正在嘗試使用 hardhat-deploy 範例模板在主網分叉上執行測試,特別是
for-test
分支範例。https://github.com/wighawag/template-ethereum-contracts/tree/examples/fork-test/
提供
.env
變數後。我跑了yarn fork:test mainnet
但是我一直在測試中遇到這個特定的錯誤
aToken_Dai
。我認為 ABI 可能已經過時,並嘗試從主網合約更新它,但仍然無法正常工作。執行時測試不斷恢復evm_increaseTime
。我錯過了什麼需要通過測試的東西嗎?
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)
該
.env.example
項目提供的似乎缺少一些正在使用的環境變數hardhat.config.ts
。在您的
.env
中,確保設置HARDHAT_FORK
為主網。此外,請確保設置HARDHAT_FORK_NUMBER
為所有依賴合約都已存在於主網上的區塊編號。