added stable and variable debt tokens tests

This commit is contained in:
emilio 2020-07-09 16:46:49 +02:00
parent a3326fc86d
commit 529115dd98
3 changed files with 64 additions and 17 deletions

View File

@ -30,7 +30,7 @@ abstract contract DebtTokenBase is IERC20 {
* @dev only lending pool can call functions marked by this modifier
**/
modifier onlyLendingPool {
require(msg.sender == address(pool), 'INVALID_CALLER');
require(msg.sender == address(pool), 'The caller of this function must be a lending pool');
_;
}

View File

@ -1,28 +1,38 @@
import {expect} from "chai";
import {makeSuite, TestEnv} from "./helpers/make-suite";
import {ProtocolErrors} from "../helpers/types";
import {ProtocolErrors, TokenContractId, eContractid} from "../helpers/types";
import { getContractAddress } from "ethers/utils";
import { getContract } from "../helpers/contracts-helpers";
import { StableDebtToken } from "../types/StableDebtToken";
makeSuite("AToken: Modifiers", (testEnv: TestEnv) => {
makeSuite("Stable debt token tests", (testEnv: TestEnv) => {
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(
it("Tries to invoke mint not being the LendingPool", async () => {
const {deployer, pool, dai} = testEnv;
const daiStableDebtTokenAddress = (await pool.getReserveTokensAddresses(dai.address)).stableDebtTokenAddress;
const stableDebtContract = await getContract<StableDebtToken>(eContractid.StableDebtToken, daiStableDebtTokenAddress);
await expect(stableDebtContract.mint(deployer.address, "1", "1")).to.be.revertedWith(
INVALID_POOL_CALLER_MSG_1
);
});
it("Tries to invoke burnOnLiquidation not being the LendingPool", async () => {
const {deployer, aDai} = testEnv;
await expect(
aDai.burnOnLiquidation(deployer.address, "1")
).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(INVALID_POOL_CALLER_MSG_1);
it("Tries to invoke burn not being the LendingPool", async () => {
const {deployer, pool, dai} = testEnv;
const daiStableDebtTokenAddress = (await pool.getReserveTokensAddresses(dai.address)).stableDebtTokenAddress;
const stableDebtContract = await getContract<StableDebtToken>(eContractid.StableDebtToken, daiStableDebtTokenAddress);
await expect(stableDebtContract.burn(deployer.address, "1")).to.be.revertedWith(
INVALID_POOL_CALLER_MSG_1
);
});
});

View File

@ -0,0 +1,37 @@
import {expect} from "chai";
import {makeSuite, TestEnv} from "./helpers/make-suite";
import {ProtocolErrors, TokenContractId, eContractid} from "../helpers/types";
import { getContract } from "../helpers/contracts-helpers";
import { VariableDebtToken } from "../types/VariableDebtToken";
makeSuite("Variable debt token tests", (testEnv: TestEnv) => {
const {INVALID_POOL_CALLER_MSG_1} = ProtocolErrors;
it("Tries to invoke mint not being the LendingPool", async () => {
const {deployer, pool, dai} = testEnv;
const daiVariableDebtTokenAddress = (await pool.getReserveTokensAddresses(dai.address)).variableDebtTokenAddress;
const variableDebtContract = await getContract<VariableDebtToken>(eContractid.VariableDebtToken, daiVariableDebtTokenAddress);
await expect(variableDebtContract.mint(deployer.address, "1")).to.be.revertedWith(
INVALID_POOL_CALLER_MSG_1
);
});
it("Tries to invoke burn not being the LendingPool", async () => {
const {deployer, pool, dai} = testEnv;
const daiVariableDebtTokenAddress = (await pool.getReserveTokensAddresses(dai.address)).variableDebtTokenAddress;
const variableDebtContract = await getContract<VariableDebtToken>(eContractid.VariableDebtToken, daiVariableDebtTokenAddress);
await expect(variableDebtContract.burn(deployer.address, "1")).to.be.revertedWith(
INVALID_POOL_CALLER_MSG_1
);
});
});