mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
tests: fixed tests to support latest changes
This commit is contained in:
parent
95e9c3588c
commit
4b217fff84
|
@ -39,7 +39,11 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
|||
case ConfigNames.Commons:
|
||||
return CommonsConfig;
|
||||
default:
|
||||
throw new Error(`Unsupported pool configuration: ${Object.values(ConfigNames)}`);
|
||||
throw new Error(
|
||||
`Unsupported pool configuration: ${configName} is not one of the supported configs ${Object.values(
|
||||
ConfigNames
|
||||
)}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -14793,7 +14793,7 @@
|
|||
}
|
||||
},
|
||||
"ethereumjs-abi": {
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#1a27c59c15ab1e95ee8e5c4ed6ad814c49cc439e",
|
||||
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0",
|
||||
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
deployLendingPoolConfigurator,
|
||||
deployLendingPool,
|
||||
deployPriceOracle,
|
||||
deployAaveOracle,
|
||||
deployAaveOracleV2,
|
||||
deployLendingPoolCollateralManager,
|
||||
deployMockFlashLoanReceiver,
|
||||
deployWalletBalancerProvider,
|
||||
|
@ -28,8 +28,8 @@ import {
|
|||
deployUniswapRepayAdapter,
|
||||
deployFlashLiquidationAdapter,
|
||||
authorizeWETHGateway,
|
||||
deployATokenImplementations,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { eEthereumNetwork } from '../../helpers/types';
|
||||
import { Signer } from 'ethers';
|
||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||
import { MintableERC20 } from '../../types/MintableERC20';
|
||||
|
@ -49,7 +49,7 @@ import {
|
|||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||
import AaveConfig from '../../markets/aave';
|
||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
||||
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||
import {
|
||||
getLendingPool,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
|
@ -60,7 +60,6 @@ import { WETH9Mocked } from '../../types/WETH9Mocked';
|
|||
const MOCK_USD_PRICE_IN_WEI = AaveConfig.ProtocolGlobalParams.MockUsdPriceInWei;
|
||||
const ALL_ASSETS_INITIAL_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
||||
const USD_ADDRESS = AaveConfig.ProtocolGlobalParams.UsdAddress;
|
||||
const MOCK_CHAINLINK_AGGREGATORS_PRICES = AaveConfig.Mocks.AllAssetsInitialPrices;
|
||||
const LENDING_RATE_ORACLE_RATES_COMMON = AaveConfig.LendingRateOracleRatesCommon;
|
||||
|
||||
const deployAllMockTokens = async (deployer: Signer) => {
|
||||
|
@ -96,9 +95,13 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
|||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||
console.time('setup');
|
||||
const aaveAdmin = await deployer.getAddress();
|
||||
const config = loadPoolConfig(ConfigNames.Aave);
|
||||
|
||||
const mockTokens = await deployAllMockTokens(deployer);
|
||||
console.log('Deployed mocks');
|
||||
const mockTokens: {
|
||||
[symbol: string]: MockContract | MintableERC20 | WETH9Mocked;
|
||||
} = {
|
||||
...(await deployAllMockTokens(deployer)),
|
||||
};
|
||||
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||
|
||||
|
@ -196,8 +199,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
fallbackOracle
|
||||
);
|
||||
|
||||
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
|
||||
console.log('Mock aggs deployed');
|
||||
const mockAggregators = await deployAllMockAggregators(ALL_ASSETS_INITIAL_PRICES);
|
||||
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
||||
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
||||
...accum,
|
||||
|
@ -213,9 +215,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
{}
|
||||
);
|
||||
|
||||
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
||||
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||
allTokenAddresses,
|
||||
allAggregatorsAddresses,
|
||||
config.OracleQuoteCurrency
|
||||
);
|
||||
|
||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
||||
await deployAaveOracleV2([
|
||||
tokens,
|
||||
aggregators,
|
||||
fallbackOracle.address,
|
||||
mockTokens.WETH.address,
|
||||
oneEther.toString(),
|
||||
]);
|
||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||
|
||||
const lendingRateOracle = await deployLendingRateOracle();
|
||||
|
@ -232,23 +244,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
aaveAdmin
|
||||
);
|
||||
|
||||
const reservesParams = getReservesConfigByPool(AavePools.proto);
|
||||
// Reserve params from AAVE pool + mocked tokens
|
||||
const reservesParams = {
|
||||
...config.ReservesConfig,
|
||||
};
|
||||
|
||||
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
||||
|
||||
await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
|
||||
await deployATokenImplementations(ConfigNames.Aave, reservesParams, false);
|
||||
|
||||
const admin = await deployer.getAddress();
|
||||
|
||||
console.log('Initialize configuration');
|
||||
|
||||
const config = loadPoolConfig(ConfigNames.Aave);
|
||||
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
SymbolPrefix,
|
||||
} = config;
|
||||
const { ATokenNamePrefix, StableDebtTokenNamePrefix, VariableDebtTokenNamePrefix, SymbolPrefix } =
|
||||
config;
|
||||
const treasuryAddress = await getTreasuryAddress(config);
|
||||
|
||||
await initReservesByHelper(
|
||||
|
@ -261,6 +269,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
admin,
|
||||
treasuryAddress,
|
||||
ZERO_ADDRESS,
|
||||
ConfigNames.Aave,
|
||||
false
|
||||
);
|
||||
|
||||
|
@ -298,7 +307,7 @@ before(async () => {
|
|||
const FORK = process.env.FORK;
|
||||
|
||||
if (FORK) {
|
||||
await rawBRE.run('aave:mainnet');
|
||||
await rawBRE.run('aave:mainnet', { skipRegistry: true });
|
||||
} else {
|
||||
console.log('-> Deploying test environment...');
|
||||
await buildTestEnv(deployer, secondaryWallet);
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
deployLendingPoolConfigurator,
|
||||
deployLendingPool,
|
||||
deployPriceOracle,
|
||||
deployAaveOracle,
|
||||
deployAaveOracleV2,
|
||||
deployLendingPoolCollateralManager,
|
||||
deployMockFlashLoanReceiver,
|
||||
deployWalletBalancerProvider,
|
||||
|
@ -28,6 +28,7 @@ import {
|
|||
deployUniswapRepayAdapter,
|
||||
deployFlashLiquidationAdapter,
|
||||
authorizeWETHGateway,
|
||||
deployATokenImplementations,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { Signer } from 'ethers';
|
||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||
|
@ -48,7 +49,7 @@ import {
|
|||
import { DRE, waitForTx } from '../../helpers/misc-utils';
|
||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||
import AmmConfig from '../../markets/amm';
|
||||
import { ZERO_ADDRESS } from '../../helpers/constants';
|
||||
import { oneEther, ZERO_ADDRESS } from '../../helpers/constants';
|
||||
import {
|
||||
getLendingPool,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
|
@ -95,6 +96,14 @@ const deployAllMockTokens = async (deployer: Signer) => {
|
|||
const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||
console.time('setup');
|
||||
const aaveAdmin = await deployer.getAddress();
|
||||
const config = loadPoolConfig(ConfigNames.Amm);
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
SymbolPrefix,
|
||||
ReservesConfig,
|
||||
} = config;
|
||||
|
||||
const mockTokens = await deployAllMockTokens(deployer);
|
||||
|
||||
|
@ -189,6 +198,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
WMATIC: mockTokens.WMATIC.address,
|
||||
USD: USD_ADDRESS,
|
||||
STAKE: mockTokens.STAKE.address,
|
||||
xSUSHI: ZERO_ADDRESS,
|
||||
},
|
||||
fallbackOracle
|
||||
);
|
||||
|
@ -210,9 +220,19 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
{}
|
||||
);
|
||||
|
||||
const [tokens, aggregators] = getPairsTokenAggregator(allTokenAddresses, allAggregatorsAddresses);
|
||||
const [tokens, aggregators] = getPairsTokenAggregator(
|
||||
allTokenAddresses,
|
||||
allAggregatorsAddresses,
|
||||
config.OracleQuoteCurrency
|
||||
);
|
||||
|
||||
await deployAaveOracle([tokens, aggregators, fallbackOracle.address, mockTokens.WETH.address]);
|
||||
await deployAaveOracleV2([
|
||||
tokens,
|
||||
aggregators,
|
||||
fallbackOracle.address,
|
||||
mockTokens.WETH.address,
|
||||
oneEther.toString(),
|
||||
]);
|
||||
await waitForTx(await addressesProvider.setPriceOracle(fallbackOracle.address));
|
||||
|
||||
const lendingRateOracle = await deployLendingRateOracle();
|
||||
|
@ -228,8 +248,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
lendingRateOracle,
|
||||
aaveAdmin
|
||||
);
|
||||
|
||||
const reservesParams = getReservesConfigByPool(AavePools.amm);
|
||||
await deployATokenImplementations(ConfigNames.Amm, ReservesConfig);
|
||||
|
||||
const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address);
|
||||
|
||||
|
@ -238,18 +257,10 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
|
||||
console.log('Initialize configuration');
|
||||
|
||||
const config = loadPoolConfig(ConfigNames.Amm);
|
||||
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
SymbolPrefix,
|
||||
} = config;
|
||||
const treasuryAddress = await getTreasuryAddress(config);
|
||||
|
||||
await initReservesByHelper(
|
||||
reservesParams,
|
||||
ReservesConfig,
|
||||
allReservesAddresses,
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
|
@ -258,9 +269,10 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
admin,
|
||||
treasuryAddress,
|
||||
ZERO_ADDRESS,
|
||||
ConfigNames.Amm,
|
||||
false
|
||||
);
|
||||
await configureReservesByHelper(reservesParams, allReservesAddresses, testHelpers, admin);
|
||||
await configureReservesByHelper(ReservesConfig, allReservesAddresses, testHelpers, admin);
|
||||
|
||||
const collateralManager = await deployLendingPoolCollateralManager();
|
||||
await waitForTx(
|
||||
|
@ -294,7 +306,7 @@ before(async () => {
|
|||
const FORK = process.env.FORK;
|
||||
|
||||
if (FORK) {
|
||||
await rawBRE.run('amm:mainnet');
|
||||
await rawBRE.run('amm:mainnet', { skipRegistry: true });
|
||||
} else {
|
||||
console.log('-> Deploying test environment...');
|
||||
await buildTestEnv(deployer, secondaryWallet);
|
||||
|
|
Loading…
Reference in New Issue
Block a user