mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	WIP change implementation of increaseTime
This commit is contained in:
		
							parent
							
								
									f48c8d7395
								
							
						
					
					
						commit
						a4a6d3d437
					
				|  | @ -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) => | ||||
|  |  | |||
|  | @ -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 { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 David Racero
						David Racero