From 8d020df60c52bdaecd9dd54f460d9d3ac2f8f7b8 Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Thu, 1 Jul 2021 16:53:06 +0200 Subject: [PATCH] refactor: adapted tests to new way of pausing LendingPool through pausing all reserves --- .../test-aave/liquidation-atoken.spec.ts | 1 - .../test-aave/pausable-functions.spec.ts | 27 ++++++++++--------- .../test-amm/liquidation-atoken.spec.ts | 1 - .../test-amm/pausable-functions.spec.ts | 22 +++++++-------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/test-suites/test-aave/liquidation-atoken.spec.ts b/test-suites/test-aave/liquidation-atoken.spec.ts index 1b6f9911..00ad07be 100644 --- a/test-suites/test-aave/liquidation-atoken.spec.ts +++ b/test-suites/test-aave/liquidation-atoken.spec.ts @@ -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 () => { diff --git a/test-suites/test-aave/pausable-functions.spec.ts b/test-suites/test-aave/pausable-functions.spec.ts index 24bedb69..54b318e7 100644 --- a/test-suites/test-aave/pausable-functions.spec.ts +++ b/test-suites/test-aave/pausable-functions.spec.ts @@ -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); diff --git a/test-suites/test-amm/liquidation-atoken.spec.ts b/test-suites/test-amm/liquidation-atoken.spec.ts index 90296edb..775fe769 100644 --- a/test-suites/test-amm/liquidation-atoken.spec.ts +++ b/test-suites/test-amm/liquidation-atoken.spec.ts @@ -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 () => { diff --git a/test-suites/test-amm/pausable-functions.spec.ts b/test-suites/test-amm/pausable-functions.spec.ts index f42388a8..e5bd4637 100644 --- a/test-suites/test-amm/pausable-functions.spec.ts +++ b/test-suites/test-amm/pausable-functions.spec.ts @@ -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);