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

View File

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

View File

@ -614,16 +614,6 @@ const buildTestEnv = async (deployer: Wallet, secondaryWallet: Wallet) => {
const testHelpers = await deployAaveProtocolTestHelpers( const testHelpers = await deployAaveProtocolTestHelpers(
addressesProvider.address 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( await insertContractAddressInDb(
eContractid.AaveProtocolTestHelpers, eContractid.AaveProtocolTestHelpers,

View File

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