mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: added helper to setHardhatBalance
This commit is contained in:
parent
4e3701c196
commit
95e80e26dc
|
|
@ -3,7 +3,7 @@ import BN = require('bn.js');
|
|||
import low from 'lowdb';
|
||||
import FileSync from 'lowdb/adapters/FileSync';
|
||||
import { WAD } from './constants';
|
||||
import { Wallet, ContractTransaction } from 'ethers';
|
||||
import { Wallet, ContractTransaction, BigNumberish } from 'ethers';
|
||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
||||
import { BuidlerRuntimeEnvironment } from '@nomiclabs/buidler/types';
|
||||
import { tEthereumAddress } from './types';
|
||||
|
|
@ -46,6 +46,16 @@ export const increaseTime = async (secondsToIncrease: number) => {
|
|||
await DRE.ethers.provider.send('evm_mine', []);
|
||||
};
|
||||
|
||||
export const setHardhatBalance = async (addresses: string[], balances: BigNumberish[]) => {
|
||||
for (const [index, address] of addresses.entries()) {
|
||||
const hexBalance = DRE.ethers.BigNumber.from(balances[index]).toHexString();
|
||||
// ethers big number .toHexString adds a 0x0 that hardhat can't remove.
|
||||
// from 0x0Deb12312 to 0xDeb123112
|
||||
const hexBalanceWithoutZero = hexBalance.slice(0, 2) + hexBalance.slice(3);
|
||||
await DRE.ethers.provider.send('hardhat_setBalance', [address, hexBalanceWithoutZero]);
|
||||
}
|
||||
};
|
||||
|
||||
// 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();
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@
|
|||
"ethereumjs-util": "7.0.2",
|
||||
"ethers": "^5.0.19",
|
||||
"globby": "^11.0.1",
|
||||
"hardhat": "^2.2.0",
|
||||
"hardhat": "^2.4.0",
|
||||
"hardhat-gas-reporter": "^1.0.0",
|
||||
"hardhat-typechain": "^0.3.3",
|
||||
"husky": "^4.2.5",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user