- Fixed issue on AaveProtocolTestHelpers.

- Migrated atoken-modifiers tests.
This commit is contained in:
eboado 2020-06-08 21:06:26 +02:00
parent 21e6697eda
commit 0453a49f8f
5 changed files with 38 additions and 43 deletions

View File

@ -1,5 +1,6 @@
pragma solidity ^0.6.8;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from "../interfaces/ILendingPoolAddressesProvider.sol";
import {LendingPoolCore} from "../lendingpool/LendingPool.sol";
import {AToken} from "../tokenization/AToken.sol";
@ -19,7 +20,7 @@ contract AaveProtocolTestHelpers {
function getAllATokens() external view returns(ATokenData[] memory) {
LendingPoolCore core = LendingPoolCore(ADDRESSES_PROVIDER.getLendingPoolCore());
address[] memory reserves = core.getReserves();
ATokenData[] memory aTokens;
ATokenData[] memory aTokens = new ATokenData[](reserves.length);
for (uint256 i = 0; i < reserves.length; i++) {
address aTokenAddress = core.getReserveATokenAddress(reserves[i]);
aTokens[i] = ATokenData({

View File

@ -12,6 +12,8 @@ import {
import BigNumber from "bignumber.js";
import {getParamPerPool} from "./contracts-helpers";
export const TEST_SNAPSHOT_ID = "0x1";
// ----------------
// MATH
// ----------------

View File

@ -614,16 +614,6 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
const testHelpers = await deployAaveProtocolTestHelpers(
addressesProvider.address
);
console.log(testHelpers.address);
console.log(
"Addresses provider on test helpers: ",
await testHelpers.ADDRESSES_PROVIDER()
);
try {
console.log(await testHelpers.getAllATokens());
} catch (error) {
console.log(error);
}
await insertContractAddressInDb(
eContractid.AaveProtocolTestHelpers,

View File

@ -1,46 +1,48 @@
import rawBRE from "@nomiclabs/buidler";
import {expect} from "chai";
import {MockProvider} from "ethereum-waffle";
import {BuidlerRuntimeEnvironment} from "@nomiclabs/buidler/types";
import {LendingPoolAddressesProvider} from "../types/LendingPoolAddressesProvider";
import {
getLendingPoolAddressesProvider,
getLendingPoolProxy,
getAToken,
getAaveProtocolTestHelpers,
} from "../helpers/contracts-helpers";
import {evmRevert} from "../helpers/misc-utils";
import {AToken} from "../types/AToken";
import {TEST_SNAPSHOT_ID} from "../helpers/constants";
describe("AToken: Modifiers", () => {
const wallets = new MockProvider().getWallets();
let BRE: BuidlerRuntimeEnvironment;
const [deployer, ...restWallets] = new MockProvider().getWallets();
let _aDAI = {} as AToken;
const NOT_LENDING_POOL_MSG =
"The caller of this function must be a lending pool";
before(async () => {
await evmRevert("0x1");
});
it("Tries to invoke mintOnDeposit", async () => {
await evmRevert(TEST_SNAPSHOT_ID);
const testHelpers = await getAaveProtocolTestHelpers();
console.log(await testHelpers.ADDRESSES_PROVIDER());
console.log(await testHelpers.getAllATokens())
// const aDAI = await getAToken(await lendingPool.getReserveConfigurationData())
// await expectRevert(
// _aDAI.mintOnDeposit(deployer, "1"),
// "The caller of this function must be a lending pool"
// );
const aDAIAddress = (await testHelpers.getAllATokens()).find(
(aToken) => aToken.symbol === "aDAI"
)?.aTokenAddress;
if (!aDAIAddress) {
console.log(`atoken-modifiers.spec: aDAI not correctly initialized`);
process.exit(1);
}
_aDAI = await getAToken(aDAIAddress);
});
// it("Tries to invoke burnOnLiquidation", async () => {
// await expectRevert(
// _aDAI.burnOnLiquidation(deployer, "1"),
// "The caller of this function must be a lending pool"
// );
// });
it("Tries to invoke mintOnDeposit not being the LendingPool", async () => {
await expect(_aDAI.mintOnDeposit(deployer.address, "1")).to.be.revertedWith(
NOT_LENDING_POOL_MSG
);
});
// it("Tries to invoke transferOnLiquidation", async () => {
// await expectRevert(
// _aDAI.transferOnLiquidation(deployer, users[1], "1"),
// "The caller of this function must be a lending pool"
// );
// });
it("Tries to invoke burnOnLiquidation not being the LendingPool", async () => {
await expect(
_aDAI.burnOnLiquidation(deployer.address, "1")
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
});
it("Tries to invoke transferOnLiquidation not being the LendingPool", async () => {
await expect(
_aDAI.transferOnLiquidation(deployer.address, restWallets[0].address, "1")
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
});
});

View File

@ -1,14 +1,14 @@
import {expect} from "chai";
import {MockProvider} from "ethereum-waffle";
import {BuidlerRuntimeEnvironment} from "@nomiclabs/buidler/types";
import {getLendingPoolAddressesProvider} from "../helpers/contracts-helpers";
import {createRandomAddress, evmRevert} from "../helpers/misc-utils";
import {TEST_SNAPSHOT_ID} from "../helpers/constants";
describe("LendingPoolAddressesProvider", () => {
const wallets = new MockProvider().getWallets();
before(async () => {
await evmRevert("0x1");
await evmRevert(TEST_SNAPSHOT_ID);
});
it("Test the accessibility of the LendingPoolAddressesProvider", async () => {