mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'fix/hardhat-time-error' into 'master'
Fix master test suite at CI See merge request aave-tech/protocol-v2!226
This commit is contained in:
commit
776a6a4aae
|
@ -46,6 +46,26 @@ export const increaseTime = async (secondsToIncrease: number) => {
|
|||
await DRE.ethers.provider.send('evm_mine', []);
|
||||
};
|
||||
|
||||
// Workaround for time travel tests bug: https://github.com/Tonyhaenn/hh-time-travel/blob/0161d993065a0b7585ec5a043af2eb4b654498b8/test/test.js#L12
|
||||
export const advanceTimeAndBlock = async function (forwardTime: number) {
|
||||
const currentBlockNumber = await DRE.ethers.provider.getBlockNumber();
|
||||
const currentBlock = await DRE.ethers.provider.getBlock(currentBlockNumber);
|
||||
|
||||
if (currentBlock === null) {
|
||||
/* Workaround for https://github.com/nomiclabs/hardhat/issues/1183
|
||||
*/
|
||||
await DRE.ethers.provider.send('evm_increaseTime', [forwardTime]);
|
||||
await DRE.ethers.provider.send('evm_mine', []);
|
||||
//Set the next blocktime back to 15 seconds
|
||||
await DRE.ethers.provider.send('evm_increaseTime', [15]);
|
||||
return;
|
||||
}
|
||||
const currentTime = currentBlock.timestamp;
|
||||
const futureTime = currentTime + forwardTime;
|
||||
await DRE.ethers.provider.send('evm_setNextBlockTimestamp', [futureTime]);
|
||||
await DRE.ethers.provider.send('evm_mine', []);
|
||||
};
|
||||
|
||||
export const waitForTx = async (tx: ContractTransaction) => await tx.wait(1);
|
||||
|
||||
export const filterMapBy = (raw: { [key: string]: any }, fn: (key: string) => boolean) =>
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -15287,14 +15287,14 @@
|
|||
}
|
||||
},
|
||||
"hardhat": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.0.3.tgz",
|
||||
"integrity": "sha512-mDygAl+1qd5KBdXQBfc3R5XmC/rVdYYbEuOTSQY3rlncVu9gfockZVDsHtAMPw/FiBIRMApLcOceK7D1XQmHRw==",
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/hardhat/-/hardhat-2.0.8.tgz",
|
||||
"integrity": "sha512-2tDAtOfshrBzP103dx7PQrhTwv2sqjhQStZAPwkkQTic25o2EH6HYE2++LuOG98YwqSjr0WvhvdBvKl3dCSkYA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nomiclabs/ethereumjs-vm": "^4.1.1",
|
||||
"@sentry/node": "^5.18.1",
|
||||
"@solidity-parser/parser": "^0.7.1",
|
||||
"@solidity-parser/parser": "^0.11.0",
|
||||
"@types/bn.js": "^4.11.5",
|
||||
"@types/lru-cache": "^5.1.0",
|
||||
"abort-controller": "^3.0.0",
|
||||
|
@ -15339,9 +15339,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@solidity-parser/parser": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.7.1.tgz",
|
||||
"integrity": "sha512-5ma2uuwPAEX1TPl2rAPAAuGlBkKnn2oUKQvnhTFlDIB8U/KDWX77FpHtL6Rcz+OwqSCWx9IClxACgyIEJ/GhIw==",
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.11.1.tgz",
|
||||
"integrity": "sha512-H8BSBoKE8EubJa0ONqecA2TviT3TnHeC4NpgnAHSUiuhZoQBfPB4L2P9bs8R6AoTW10Endvh3vc+fomVMIDIYQ==",
|
||||
"dev": true
|
||||
},
|
||||
"commander": {
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
"ethereumjs-util": "7.0.2",
|
||||
"ethers": "^5.0.19",
|
||||
"globby": "^11.0.1",
|
||||
"hardhat": "^2.0.2",
|
||||
"hardhat": "^2.0.8",
|
||||
"hardhat-gas-reporter": "^1.0.0",
|
||||
"hardhat-typechain": "^0.3.3",
|
||||
"husky": "^4.2.5",
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from '../../helpers/contracts-getters';
|
||||
import { MAX_UINT_AMOUNT, ONE_YEAR } from '../../helpers/constants';
|
||||
import { SignerWithAddress, TestEnv } from './make-suite';
|
||||
import { DRE, increaseTime, timeLatest, waitForTx } from '../../helpers/misc-utils';
|
||||
import { advanceTimeAndBlock, DRE, timeLatest, waitForTx } from '../../helpers/misc-utils';
|
||||
|
||||
import chai from 'chai';
|
||||
import { ReserveData, UserReserveData } from './utils/interfaces';
|
||||
|
@ -361,7 +361,7 @@ export const borrow = async (
|
|||
if (timeTravel) {
|
||||
const secondsToTravel = new BigNumber(timeTravel).multipliedBy(ONE_YEAR).div(365).toNumber();
|
||||
|
||||
await increaseTime(secondsToTravel);
|
||||
await advanceTimeAndBlock(secondsToTravel);
|
||||
}
|
||||
|
||||
const {
|
||||
|
|
|
@ -34,7 +34,9 @@ fs.readdirSync(scenarioFolder).forEach((file) => {
|
|||
});
|
||||
|
||||
for (const story of scenario.stories) {
|
||||
it(story.description, async () => {
|
||||
it(story.description, async function () {
|
||||
// Retry the test scenarios up to 4 times if an error happens, due erratic HEVM network errors
|
||||
this.retries(4);
|
||||
await executeStory(story, testEnv);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user