From 08e14b7565b4502e84cd4fac1c1d3045887d20f4 Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Fri, 30 Apr 2021 11:02:28 +0200 Subject: [PATCH] test: added more precised cap test --- test-suites/test-aave/borrow-cap.spec.ts | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test-suites/test-aave/borrow-cap.spec.ts b/test-suites/test-aave/borrow-cap.spec.ts index 43dfd314..1d72c8a9 100644 --- a/test-suites/test-aave/borrow-cap.spec.ts +++ b/test-suites/test-aave/borrow-cap.spec.ts @@ -113,9 +113,9 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { usdcBorrowCap = await helpersContract.getReserveBorrowCap(usdc.address); daiBorrowCap = await helpersContract.getReserveBorrowCap(dai.address); }); - it('Sets the borrow cap for usdc and DAI to 100 Units', async () => { + it('Sets the borrow cap for usdc and DAI to 110 Units', async () => { const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; - const newCap = '100'; + const newCap = '110'; let usdcBorrowCap = await helpersContract.getReserveBorrowCap(usdc.address); let daiBorrowCap = await helpersContract.getReserveBorrowCap(dai.address); @@ -151,7 +151,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { deployer.address ); }); - it('should fail to borrow 100 variable dai and 100 stable usdc', async () => { + it('should fail to borrow 100 variable dai and 100 stable usdc (interests accrued)', async () => { const { usdc, pool, dai, deployer, helpersContract } = testEnv; const borrowedAmount = 100; const borrowedMilimount = (borrowedAmount * 1000).toString(); @@ -176,6 +176,26 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => { ) ).to.be.revertedWith(VL_BORROW_CAP_EXCEEDED); }); + it('Should succeed to borrow 99 variable dai and 99 stable usdc', async () => { + const { usdc, pool, dai, deployer, helpersContract } = testEnv; + const borrowedAmount = 99; + const borrowedMilimount = (borrowedAmount * 1000).toString(); + await pool.borrow( + usdc.address, + await miliUnitToPrecision(usdc, borrowedMilimount), + 2, + 0, + deployer.address + ); + + await pool.borrow( + dai.address, + await miliUnitToPrecision(dai, borrowedMilimount), + 1, + 0, + deployer.address + ); + }); it('Raises the borrow cap for usdc and DAI to 1000 Units', async () => { const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv; const newCap = '1000';