refactor: adapted tests to new way of pausing LendingPool through pausing all reserves

This commit is contained in:
Hadrien Charlanes 2021-07-01 16:53:06 +02:00
parent 79a8d2bba6
commit 8d020df60c
4 changed files with 26 additions and 25 deletions

View File

@ -17,7 +17,6 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
INVALID_HF,
LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER,
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED,
LP_IS_PAUSED,
} = ProtocolErrors;
it('Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => {

View File

@ -12,8 +12,11 @@ const { expect } = require('chai');
makeSuite('Pausable Pool', (testEnv: TestEnv) => {
let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
const { LP_IS_PAUSED, INVALID_FROM_BALANCE_AFTER_TRANSFER, INVALID_TO_BALANCE_AFTER_TRANSFER } =
ProtocolErrors;
const {
VL_RESERVE_PAUSED,
INVALID_FROM_BALANCE_AFTER_TRANSFER,
INVALID_TO_BALANCE_AFTER_TRANSFER,
} = ProtocolErrors;
before(async () => {
_mockFlashLoanReceiver = await getMockFlashLoanReceiver();
@ -41,7 +44,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// User 0 tries the transfer to User 1
await expect(
aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit)
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
const pausedFromBalance = await aDai.balanceOf(users[0].address);
const pausedToBalance = await aDai.balanceOf(users[1].address);
@ -88,7 +91,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await configurator.connect(users[1].signer).setPoolPause(true);
await expect(
pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0')
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
// Configurator unpauses the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -113,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// user tries to burn
await expect(
pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit, users[0].address)
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
// Configurator unpauses the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -129,7 +132,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to execute liquidation
await expect(
pool.connect(user.signer).borrow(dai.address, '1', '1', '0', user.address)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -144,7 +147,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to execute liquidation
await expect(pool.connect(user.signer).repay(dai.address, '1', '1', user.address)).revertedWith(
LP_IS_PAUSED
VL_RESERVE_PAUSED
);
// Unpause the pool
@ -175,7 +178,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
'0x10',
'0'
)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -256,7 +259,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Do liquidation
await expect(
pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -285,7 +288,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to repay
await expect(
pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -299,7 +302,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await expect(
pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -319,7 +322,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await expect(
pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);

View File

@ -17,7 +17,6 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
INVALID_HF,
LPCM_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER,
LPCM_COLLATERAL_CANNOT_BE_LIQUIDATED,
LP_IS_PAUSED,
} = ProtocolErrors;
it('Deposits WETH, borrows DAI/Check liquidation fails because health factor is above 1', async () => {

View File

@ -13,7 +13,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
const {
LP_IS_PAUSED,
VL_RESERVE_PAUSED,
INVALID_FROM_BALANCE_AFTER_TRANSFER,
INVALID_TO_BALANCE_AFTER_TRANSFER,
} = ProtocolErrors;
@ -44,7 +44,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// User 0 tries the transfer to User 1
await expect(
aDai.connect(users[0].signer).transfer(users[1].address, amountDAItoDeposit)
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
const pausedFromBalance = await aDai.balanceOf(users[0].address);
const pausedToBalance = await aDai.balanceOf(users[1].address);
@ -91,7 +91,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await configurator.connect(users[1].signer).setPoolPause(true);
await expect(
pool.connect(users[0].signer).deposit(dai.address, amountDAItoDeposit, users[0].address, '0')
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
// Configurator unpauses the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -116,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// user tries to burn
await expect(
pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit, users[0].address)
).to.revertedWith(LP_IS_PAUSED);
).to.revertedWith(VL_RESERVE_PAUSED);
// Configurator unpauses the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -132,7 +132,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to execute liquidation
await expect(
pool.connect(user.signer).borrow(dai.address, '1', '2', '0', user.address)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause the pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -147,7 +147,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to execute liquidation
await expect(pool.connect(user.signer).repay(dai.address, '1', '2', user.address)).revertedWith(
LP_IS_PAUSED
VL_RESERVE_PAUSED
);
// Unpause the pool
@ -178,7 +178,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
'0x10',
'0'
)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -259,7 +259,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Do liquidation
await expect(
pool.liquidationCall(weth.address, usdc.address, borrower.address, amountToLiquidate, true)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -288,7 +288,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
// Try to repay
await expect(
pool.connect(user.signer).swapBorrowRateMode(usdc.address, RateMode.Stable)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -302,7 +302,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await expect(
pool.connect(user.signer).rebalanceStableBorrowRate(dai.address, user.address)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);
@ -322,7 +322,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
await expect(
pool.connect(user.signer).setUserUseReserveAsCollateral(weth.address, false)
).revertedWith(LP_IS_PAUSED);
).revertedWith(VL_RESERVE_PAUSED);
// Unpause pool
await configurator.connect(users[1].signer).setPoolPause(false);