mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Fixed typo on configurator.spec test name.
- Unified error messages for tests on types.ts. - Finished migration of core-modifiers.spec.ts.
This commit is contained in:
parent
57cc16e665
commit
99cbb5f0a4
|
@ -42,6 +42,21 @@ export enum eContractid {
|
|||
IERC20Detailed = "IERC20Detailed",
|
||||
}
|
||||
|
||||
export enum ProtocolErrors {
|
||||
INVALID_CONFIGURATOR_CALLER_MSG = "The caller must be a lending pool configurator contract",
|
||||
INVALID_POOL_CALLER_MSG = "The caller must be a lending pool contract",
|
||||
INVALID_POOL_CALLER_MSG_1 = "The caller of this function must be a lending pool",
|
||||
INVALID_POOL_MANAGER_CALLER_MSG = "The caller must be a lending pool manager",
|
||||
INVALID_FROM_BALANCE_AFTER_TRANSFER = "Invalid from balance after transfer",
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER = "Invalid from balance after transfer",
|
||||
INVALID_OWNER_REVERT_MSG = "Ownable: caller is not the owner",
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER = "Invalid redirected balance before transfer",
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER = "Invalid redirected balance after transfer",
|
||||
INVALID_REDIRECTION_ADDRESS = "Invalid redirection address",
|
||||
TRANSFERRED_AMOUNT_GT_ZERO = "Transferred amount needs to be greater than zero",
|
||||
ZERO_COLLATERAL = "The collateral balance is 0",
|
||||
}
|
||||
|
||||
export type tEthereumAddress = string;
|
||||
export type tStringTokenBigUnits = string; // 1 ETH, or 10e6 USDC or 10e18 DAI
|
||||
export type tBigNumberTokenBigUnits = BigNumber;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import {expect} from "chai";
|
||||
import {makeSuite, TestEnv} from "./helpers/make-suite";
|
||||
import {ProtocolErrors} from "../helpers/types";
|
||||
|
||||
makeSuite("AToken: Modifiers", (testEnv: TestEnv) => {
|
||||
const NOT_LENDING_POOL_MSG =
|
||||
"The caller of this function must be a lending pool";
|
||||
const {INVALID_POOL_CALLER_MSG_1} = ProtocolErrors;
|
||||
|
||||
it("Tries to invoke mintOnDeposit not being the LendingPool", async () => {
|
||||
const {deployer, aDai} = testEnv;
|
||||
await expect(aDai.mintOnDeposit(deployer.address, "1")).to.be.revertedWith(
|
||||
NOT_LENDING_POOL_MSG
|
||||
INVALID_POOL_CALLER_MSG_1
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -16,13 +16,13 @@ makeSuite("AToken: Modifiers", (testEnv: TestEnv) => {
|
|||
const {deployer, aDai} = testEnv;
|
||||
await expect(
|
||||
aDai.burnOnLiquidation(deployer.address, "1")
|
||||
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG_1);
|
||||
});
|
||||
|
||||
it("Tries to invoke transferOnLiquidation not being the LendingPool", async () => {
|
||||
const {deployer, users, aDai} = testEnv;
|
||||
await expect(
|
||||
aDai.transferOnLiquidation(deployer.address, users[0].address, "1")
|
||||
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG_1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,10 +8,20 @@ import {
|
|||
import {convertToCurrencyDecimals} from "../helpers/contracts-helpers";
|
||||
import {expect} from "chai";
|
||||
import {ethers} from "ethers";
|
||||
import {RateMode} from "../helpers/types";
|
||||
import {RateMode, ProtocolErrors} from "../helpers/types";
|
||||
import {makeSuite, TestEnv} from "./helpers/make-suite";
|
||||
|
||||
makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
||||
const {
|
||||
INVALID_FROM_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER,
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER,
|
||||
INVALID_REDIRECTION_ADDRESS,
|
||||
ZERO_COLLATERAL,
|
||||
TRANSFERRED_AMOUNT_GT_ZERO,
|
||||
} = ProtocolErrors;
|
||||
|
||||
it("User 0 deposits 1000 DAI, transfers to user 1", async () => {
|
||||
const {users, pool, core, dai, aDai} = testEnv;
|
||||
|
||||
|
@ -42,11 +52,11 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
|
||||
expect(fromBalance.toString()).to.be.equal(
|
||||
"0",
|
||||
"Invalid from balance after transfer"
|
||||
INVALID_FROM_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
expect(toBalance.toString()).to.be.equal(
|
||||
amountDAItoDeposit.toString(),
|
||||
"Invalid to balance after transfer"
|
||||
INVALID_TO_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -65,7 +75,7 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
);
|
||||
expect(user2RedirectedBalanceBefore.toString()).to.be.equal(
|
||||
aDAIRedirected,
|
||||
"Invalid redirected balance for user 2 before transfer"
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER
|
||||
);
|
||||
|
||||
await aDai
|
||||
|
@ -81,11 +91,11 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
|
||||
expect(user2RedirectedBalanceAfter.toString()).to.be.equal(
|
||||
aDAItoTransfer,
|
||||
"Invalid redirected balance for user 2 after transfer"
|
||||
INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER
|
||||
);
|
||||
expect(user1RedirectionAddress.toString()).to.be.equal(
|
||||
users[2].address,
|
||||
"Invalid redirection address for user 1"
|
||||
INVALID_REDIRECTION_ADDRESS
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -105,7 +115,7 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
|
||||
expect(user2RedirectedBalanceAfter.toString()).to.be.equal(
|
||||
user1BalanceAfter.toString(),
|
||||
"Invalid redirected balance for user 2 after transfer"
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -126,8 +136,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
RateMode.Stable,
|
||||
AAVE_REFERRAL
|
||||
),
|
||||
"The collateral balance is 0"
|
||||
).to.be.revertedWith("The collateral balance is 0");
|
||||
ZERO_COLLATERAL
|
||||
).to.be.revertedWith(ZERO_COLLATERAL);
|
||||
});
|
||||
|
||||
it("User 1 sets the DAI as collateral and borrows, tries to transfer everything back to user 0 (revert expected)", async () => {
|
||||
|
@ -157,8 +167,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
const {users, pool, aDai, dai} = testEnv;
|
||||
await expect(
|
||||
aDai.connect(users[0].signer).transfer(users[1].address, "0"),
|
||||
"Transferred amount needs to be greater than zero"
|
||||
).to.be.revertedWith("Transferred amount needs to be greater than zero");
|
||||
TRANSFERRED_AMOUNT_GT_ZERO
|
||||
).to.be.revertedWith(TRANSFERRED_AMOUNT_GT_ZERO);
|
||||
});
|
||||
|
||||
it("User 1 repays the borrow, transfers aDAI back to user 0", async () => {
|
||||
|
@ -188,12 +198,12 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
|
||||
expect(user2RedirectedBalanceAfter.toString()).to.be.equal(
|
||||
"0",
|
||||
"Invalid redirected balance for user 2 after transfer"
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
|
||||
expect(user1RedirectionAddress.toString()).to.be.equal(
|
||||
ZERO_ADDRESS,
|
||||
"Invalid redirected address for user 1"
|
||||
INVALID_REDIRECTION_ADDRESS
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -238,11 +248,11 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
|
||||
expect(user2RedirectedBalanceAfter.toString()).to.be.equal(
|
||||
expectedUser2Redirected,
|
||||
"Invalid redirected balance for user 2 after transfer"
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
expect(user3RedirectedBalanceAfter.toString()).to.be.equal(
|
||||
expectedUser3Redirected,
|
||||
"Invalid redirected balance for user 3 after transfer"
|
||||
INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,10 +5,13 @@ import {
|
|||
APPROVAL_AMOUNT_LENDING_POOL_CORE,
|
||||
} from "../helpers/constants";
|
||||
import {convertToCurrencyDecimals} from "../helpers/contracts-helpers";
|
||||
import {ProtocolErrors} from "../helpers/types";
|
||||
|
||||
const {expect} = require("chai");
|
||||
|
||||
makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
||||
makeSuite("LendingPoolConfigurator", (testEnv: TestEnv) => {
|
||||
const {INVALID_POOL_MANAGER_CALLER_MSG} = ProtocolErrors;
|
||||
|
||||
it("Deactivates the ETH reserve", async () => {
|
||||
const {configurator, core} = testEnv;
|
||||
await configurator.deactivateReserve(MOCK_ETH_ADDRESS);
|
||||
|
@ -28,16 +31,16 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
const {configurator, users} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).deactivateReserve(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on activateReserve ", async () => {
|
||||
const {configurator, users} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).activateReserve(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Freezes the ETH reserve", async () => {
|
||||
|
@ -59,16 +62,16 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
const {configurator, users} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).freezeReserve(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on unfreezeReserve ", async () => {
|
||||
const {configurator, users} = testEnv;
|
||||
await expect(
|
||||
configurator.connect(users[2].signer).unfreezeReserve(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Deactivates the ETH reserve for borrowing", async () => {
|
||||
|
@ -95,8 +98,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.disableBorrowingOnReserve(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on enableBorrowingOnReserve ", async () => {
|
||||
|
@ -105,8 +108,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.enableBorrowingOnReserve(MOCK_ETH_ADDRESS, true),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Deactivates the ETH reserve as collateral", async () => {
|
||||
|
@ -139,8 +142,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.disableReserveAsCollateral(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on enableReserveAsCollateral ", async () => {
|
||||
|
@ -149,8 +152,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.enableReserveAsCollateral(MOCK_ETH_ADDRESS, "75", "80", "105"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Disable stable borrow rate on the ETH reserve", async () => {
|
||||
|
@ -177,8 +180,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.disableReserveStableBorrowRate(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on enableReserveStableBorrowRate", async () => {
|
||||
|
@ -187,8 +190,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.enableReserveStableBorrowRate(MOCK_ETH_ADDRESS),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Changes LTV of the reserve", async () => {
|
||||
|
@ -204,8 +207,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.setReserveBaseLTVasCollateral(MOCK_ETH_ADDRESS, "75"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Changes liquidation threshold of the reserve", async () => {
|
||||
|
@ -226,8 +229,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.setReserveLiquidationThreshold(MOCK_ETH_ADDRESS, "80"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Changes liquidation bonus of the reserve", async () => {
|
||||
|
@ -248,8 +251,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.setReserveLiquidationBonus(MOCK_ETH_ADDRESS, "80"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Check the onlyLendingPoolManager on setReserveDecimals", async () => {
|
||||
|
@ -258,8 +261,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.setReserveDecimals(MOCK_ETH_ADDRESS, "80"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Removes the last added reserve", async () => {
|
||||
|
@ -284,8 +287,8 @@ makeSuite("AToken: Transfer", (testEnv: TestEnv) => {
|
|||
configurator
|
||||
.connect(users[2].signer)
|
||||
.setReserveLiquidationBonus(MOCK_ETH_ADDRESS, "80"),
|
||||
"The caller must be a lending pool manager"
|
||||
).to.be.revertedWith("The caller must be a lending pool manager");
|
||||
INVALID_POOL_MANAGER_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_MANAGER_CALLER_MSG);
|
||||
});
|
||||
|
||||
it("Reverts when trying to disable the DAI reserve with liquidity on it", async () => {
|
||||
|
|
|
@ -1,284 +1,258 @@
|
|||
// import {ITestEnvWithoutInstances, iAssetsWithoutETH, RateMode} from '../utils/types';
|
||||
// import {
|
||||
// LendingPoolCoreInstance,
|
||||
// MintableERC20Instance,
|
||||
// } from '../utils/typechain-types/truffle-contracts';
|
||||
// import {testEnvProviderWithoutInstances} from '../utils/truffle/dlp-tests-env';
|
||||
// import { ETHEREUM_ADDRESS} from '../utils/constants';
|
||||
import {expect} from "chai";
|
||||
import {TestEnv, makeSuite} from "./helpers/make-suite";
|
||||
import {RateMode, ProtocolErrors} from "../helpers/types";
|
||||
import {MOCK_ETH_ADDRESS} from "../helpers/constants";
|
||||
|
||||
// const expectRevert = require('@openzeppelin/test-helpers').expectRevert;
|
||||
makeSuite("LendingPoolCore: Modifiers", (testEnv: TestEnv) => {
|
||||
const {
|
||||
INVALID_CONFIGURATOR_CALLER_MSG,
|
||||
INVALID_POOL_CALLER_MSG,
|
||||
} = ProtocolErrors;
|
||||
|
||||
// contract('LendingPoolCore: Modifiers', async ([deployer, ...users]) => {
|
||||
// let _testEnvProvider: ITestEnvWithoutInstances;
|
||||
// let _lendingPoolCoreInstance: LendingPoolCoreInstance;
|
||||
// let _tokenInstances: iAssetsWithoutETH<MintableERC20Instance>;
|
||||
it("Tries invoke updateStateOnDeposit ", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnDeposit(dai.address, deployer.address, "0", false),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// before('Initializing tests', async () => {
|
||||
// _testEnvProvider = await testEnvProviderWithoutInstances(artifacts, [deployer, ...users]);
|
||||
it("Tries invoke updateStateOnRedeem", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnRedeem(dai.address, deployer.address, "0", false),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// const {getAllAssetsInstances, getLendingPoolCoreInstance} = _testEnvProvider;
|
||||
// const instances = await Promise.all([getLendingPoolCoreInstance(), getAllAssetsInstances()]);
|
||||
// _lendingPoolCoreInstance = instances[0];
|
||||
// _tokenInstances = instances[1];
|
||||
// });
|
||||
it("Tries invoke updateStateOnBorrow", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnBorrow(
|
||||
dai.address,
|
||||
deployer.address,
|
||||
"0",
|
||||
"0",
|
||||
RateMode.Stable
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnDeposit ', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke updateStateOnRepay", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnRepay(
|
||||
dai.address,
|
||||
deployer.address,
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
false
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnDeposit(daiInstance.address, deployer, '0', false),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke updateStateOnSwapRate", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnSwapRate(
|
||||
dai.address,
|
||||
deployer.address,
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
RateMode.Stable
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnRedeem', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke updateStateOnRebalance", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnRebalance(dai.address, deployer.address, "0"),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnRedeem(daiInstance.address, deployer, '0', false),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke updateStateOnLiquidation", async () => {
|
||||
const {dai, deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.updateStateOnLiquidation(
|
||||
MOCK_ETH_ADDRESS,
|
||||
dai.address,
|
||||
deployer.address,
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
false
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnBorrow', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke setUserUseReserveAsCollateral", async () => {
|
||||
const {deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.setUserUseReserveAsCollateral(
|
||||
MOCK_ETH_ADDRESS,
|
||||
deployer.address,
|
||||
false
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnBorrow(
|
||||
// daiInstance.address,
|
||||
// deployer,
|
||||
// '0',
|
||||
// '0',
|
||||
// RateMode.Stable
|
||||
// ),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke transferToUser", async () => {
|
||||
const {deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.transferToUser(MOCK_ETH_ADDRESS, deployer.address, "0"),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnRepay', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke transferToReserve", async () => {
|
||||
const {deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.transferToReserve(MOCK_ETH_ADDRESS, deployer.address, "0"),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnRepay(
|
||||
// daiInstance.address,
|
||||
// deployer,
|
||||
// '0',
|
||||
// '0',
|
||||
// '0',
|
||||
// false
|
||||
// ),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke transferToFeeCollectionAddress", async () => {
|
||||
const {deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.transferToFeeCollectionAddress(
|
||||
MOCK_ETH_ADDRESS,
|
||||
deployer.address,
|
||||
"0",
|
||||
deployer.address
|
||||
),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnSwapRate', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke liquidateFee", async () => {
|
||||
const {deployer, core} = testEnv;
|
||||
await expect(
|
||||
core.liquidateFee(MOCK_ETH_ADDRESS, "0", deployer.address),
|
||||
INVALID_POOL_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnSwapRate(
|
||||
// daiInstance.address,
|
||||
// deployer,
|
||||
// '0',
|
||||
// '0',
|
||||
// '0',
|
||||
// RateMode.Stable
|
||||
// ),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke initReserve", async () => {
|
||||
const {deployer, core, dai} = testEnv;
|
||||
await expect(
|
||||
core.initReserve(dai.address, dai.address, "18", deployer.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnRebalance', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke refreshConfiguration", async () => {
|
||||
const {core} = testEnv;
|
||||
await expect(
|
||||
core.refreshConfiguration(),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnRebalance(daiInstance.address, deployer, '0'),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke enableBorrowingOnReserve, disableBorrowingOnReserve", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.enableBorrowingOnReserve(dai.address, false),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
await expect(
|
||||
core.refreshConfiguration(),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke updateStateOnLiquidation', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke freezeReserve, unfreezeReserve", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.freezeReserve(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
await expect(
|
||||
core.unfreezeReserve(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.updateStateOnLiquidation(
|
||||
// ETHEREUM_ADDRESS,
|
||||
// daiInstance.address,
|
||||
// deployer,
|
||||
// '0',
|
||||
// '0',
|
||||
// '0',
|
||||
// '0',
|
||||
// '0',
|
||||
// false
|
||||
// ),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke enableReserveAsCollateral, disableReserveAsCollateral", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.enableReserveAsCollateral(dai.address, 0, 0, 0),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
await expect(
|
||||
core.disableReserveAsCollateral(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke setUserUseReserveAsCollateral', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setUserUseReserveAsCollateral(ETHEREUM_ADDRESS, deployer, false),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke enableReserveStableBorrowRate, disableReserveStableBorrowRate", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.enableReserveStableBorrowRate(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
await expect(
|
||||
core.disableReserveStableBorrowRate(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke transferToUser', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.transferToUser(ETHEREUM_ADDRESS, deployer, '0'),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke setReserveDecimals", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.setReserveDecimals(dai.address, "0"),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke transferToReserve', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.transferToReserve(ETHEREUM_ADDRESS, deployer, '0'),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke removeLastAddedReserve", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.removeLastAddedReserve(dai.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke transferToFeeCollectionAddress', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.transferToFeeCollectionAddress(
|
||||
// ETHEREUM_ADDRESS,
|
||||
// deployer,
|
||||
// '0',
|
||||
// deployer
|
||||
// ),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke setReserveBaseLTVasCollateral", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.setReserveBaseLTVasCollateral(dai.address, "0"),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke liquidateFee', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.liquidateFee(ETHEREUM_ADDRESS, '0', deployer),
|
||||
// 'The caller must be a lending pool contract'
|
||||
// );
|
||||
// });
|
||||
it("Tries invoke setReserveLiquidationBonus", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.setReserveLiquidationBonus(dai.address, "0"),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// it('Tries invoke initReserve', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
it("Tries invoke setReserveLiquidationThreshold", async () => {
|
||||
const {core, dai} = testEnv;
|
||||
await expect(
|
||||
core.setReserveLiquidationThreshold(dai.address, "0"),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.initReserve(
|
||||
// daiInstance.address,
|
||||
// daiInstance.address,
|
||||
// '18',
|
||||
// deployer
|
||||
// ),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke refreshConfiguration', async () => {
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.refreshConfiguration(),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke enableBorrowingOnReserve, disableBorrowingOnReserve', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.enableBorrowingOnReserve(daiInstance.address, false),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.refreshConfiguration(),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke freezeReserve, unfreezeReserve', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.freezeReserve(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.unfreezeReserve(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke enableReserveAsCollateral, disableReserveAsCollateral', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.enableReserveAsCollateral(daiInstance.address, 0, 0, 0),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.disableReserveAsCollateral(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke enableReserveStableBorrowRate, disableReserveStableBorrowRate', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.enableReserveStableBorrowRate(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.disableReserveStableBorrowRate(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke setReserveDecimals', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setReserveDecimals(daiInstance.address, '0'),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke removeLastAddedReserve', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.removeLastAddedReserve(daiInstance.address),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke setReserveBaseLTVasCollateral', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setReserveBaseLTVasCollateral(daiInstance.address, '0'),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke setReserveLiquidationBonus', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setReserveLiquidationBonus(daiInstance.address, '0'),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke setReserveLiquidationThreshold', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setReserveLiquidationThreshold(daiInstance.address, '0'),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
|
||||
// it('Tries invoke setReserveInterestRateStrategyAddress', async () => {
|
||||
// const {DAI: daiInstance} = _tokenInstances;
|
||||
|
||||
// await expectRevert(
|
||||
// _lendingPoolCoreInstance.setReserveInterestRateStrategyAddress(daiInstance.address, deployer),
|
||||
// 'The caller must be a lending pool configurator contract'
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
it("Tries invoke setReserveInterestRateStrategyAddress", async () => {
|
||||
const {core, deployer, dai} = testEnv;
|
||||
await expect(
|
||||
core.setReserveInterestRateStrategyAddress(dai.address, deployer.address),
|
||||
INVALID_CONFIGURATOR_CALLER_MSG
|
||||
).to.be.revertedWith(INVALID_CONFIGURATOR_CALLER_MSG);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import {expect} from "chai";
|
||||
import {createRandomAddress} from "../helpers/misc-utils";
|
||||
import {makeSuite, TestEnv} from "./helpers/make-suite";
|
||||
import {ProtocolErrors} from "../helpers/types";
|
||||
|
||||
makeSuite("LendingPoolAddressesProvider", (testEnv: TestEnv) => {
|
||||
it("Test the accessibility of the LendingPoolAddressesProvider", async () => {
|
||||
const {addressesProvider, users} = testEnv;
|
||||
const mockAddress = createRandomAddress();
|
||||
const INVALID_OWNER_REVERT_MSG = "Ownable: caller is not the owner";
|
||||
const {INVALID_OWNER_REVERT_MSG} = ProtocolErrors;
|
||||
|
||||
await addressesProvider.transferOwnership(users[1].address);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user