mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
added stable and variable debt tokens tests
This commit is contained in:
parent
a3326fc86d
commit
529115dd98
|
@ -30,7 +30,7 @@ abstract contract DebtTokenBase is IERC20 {
|
||||||
* @dev only lending pool can call functions marked by this modifier
|
* @dev only lending pool can call functions marked by this modifier
|
||||||
**/
|
**/
|
||||||
modifier onlyLendingPool {
|
modifier onlyLendingPool {
|
||||||
require(msg.sender == address(pool), 'INVALID_CALLER');
|
require(msg.sender == address(pool), 'The caller of this function must be a lending pool');
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
import {expect} from "chai";
|
import {expect} from "chai";
|
||||||
import {makeSuite, TestEnv} from "./helpers/make-suite";
|
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;
|
const {INVALID_POOL_CALLER_MSG_1} = ProtocolErrors;
|
||||||
|
|
||||||
it("Tries to invoke mintOnDeposit not being the LendingPool", async () => {
|
it("Tries to invoke mint not being the LendingPool", async () => {
|
||||||
const {deployer, aDai} = testEnv;
|
|
||||||
await expect(aDai.mintOnDeposit(deployer.address, "1")).to.be.revertedWith(
|
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
|
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;
|
it("Tries to invoke burn not being the LendingPool", async () => {
|
||||||
await expect(
|
const {deployer, pool, dai} = testEnv;
|
||||||
aDai.transferOnLiquidation(deployer.address, users[0].address, "1")
|
|
||||||
).to.be.revertedWith(INVALID_POOL_CALLER_MSG_1);
|
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
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
37
test/variable-debt-token.spec.ts
Normal file
37
test/variable-debt-token.spec.ts
Normal 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
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user