2020-06-08 12:03:40 +00:00
|
|
|
import {expect} from "chai";
|
2020-06-10 15:01:32 +00:00
|
|
|
import {getAToken} from "../helpers/contracts-helpers";
|
2020-06-08 19:06:26 +00:00
|
|
|
import {AToken} from "../types/AToken";
|
2020-06-10 15:01:32 +00:00
|
|
|
import {makeSuite, TestEnv} from "./helpers/make-suite";
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-06-10 15:01:32 +00:00
|
|
|
makeSuite("AToken: Modifiers", (testEnv: TestEnv) => {
|
2020-06-08 19:06:26 +00:00
|
|
|
let _aDAI = {} as AToken;
|
|
|
|
const NOT_LENDING_POOL_MSG =
|
|
|
|
"The caller of this function must be a lending pool";
|
2020-06-08 12:03:40 +00:00
|
|
|
|
|
|
|
before(async () => {
|
2020-06-10 15:01:32 +00:00
|
|
|
const {helpersContract} = testEnv;
|
2020-06-08 19:06:26 +00:00
|
|
|
|
2020-06-10 15:01:32 +00:00
|
|
|
const aDAIAddress = (await helpersContract.getAllATokens()).find(
|
2020-06-08 19:06:26 +00:00
|
|
|
(aToken) => aToken.symbol === "aDAI"
|
2020-06-09 09:11:19 +00:00
|
|
|
)?.tokenAddress;
|
2020-06-08 19:06:26 +00:00
|
|
|
if (!aDAIAddress) {
|
|
|
|
console.log(`atoken-modifiers.spec: aDAI not correctly initialized`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
_aDAI = await getAToken(aDAIAddress);
|
2020-06-08 12:03:40 +00:00
|
|
|
});
|
|
|
|
|
2020-06-08 19:06:26 +00:00
|
|
|
it("Tries to invoke mintOnDeposit not being the LendingPool", async () => {
|
2020-06-10 15:01:32 +00:00
|
|
|
const {deployer} = testEnv;
|
2020-06-08 19:06:26 +00:00
|
|
|
await expect(_aDAI.mintOnDeposit(deployer.address, "1")).to.be.revertedWith(
|
|
|
|
NOT_LENDING_POOL_MSG
|
|
|
|
);
|
2020-06-08 15:36:40 +00:00
|
|
|
});
|
2020-06-08 12:03:40 +00:00
|
|
|
|
2020-06-08 19:06:26 +00:00
|
|
|
it("Tries to invoke burnOnLiquidation not being the LendingPool", async () => {
|
2020-06-10 15:01:32 +00:00
|
|
|
const {deployer} = testEnv;
|
2020-06-08 19:06:26 +00:00
|
|
|
await expect(
|
|
|
|
_aDAI.burnOnLiquidation(deployer.address, "1")
|
|
|
|
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
|
|
|
|
});
|
2020-06-08 15:36:40 +00:00
|
|
|
|
2020-06-08 19:06:26 +00:00
|
|
|
it("Tries to invoke transferOnLiquidation not being the LendingPool", async () => {
|
2020-06-10 15:01:32 +00:00
|
|
|
const {deployer, users} = testEnv;
|
2020-06-08 19:06:26 +00:00
|
|
|
await expect(
|
2020-06-10 15:01:32 +00:00
|
|
|
_aDAI.transferOnLiquidation(deployer.address, users[0].address, "1")
|
2020-06-08 19:06:26 +00:00
|
|
|
).to.be.revertedWith(NOT_LENDING_POOL_MSG);
|
|
|
|
});
|
2020-06-08 15:36:40 +00:00
|
|
|
});
|