From bd652b276a67c42c30eb9bb43f3e5269ad476ac7 Mon Sep 17 00:00:00 2001 From: Mick de Graaf Date: Mon, 7 Dec 2020 17:34:12 +0100 Subject: [PATCH] Throw error when lending pool is zero address --- contracts/callManagers/LendingManager/LendingLogicAave.sol | 1 + test/lendingLogicAave.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/contracts/callManagers/LendingManager/LendingLogicAave.sol b/contracts/callManagers/LendingManager/LendingLogicAave.sol index 3b3f59d..76a8d46 100644 --- a/contracts/callManagers/LendingManager/LendingLogicAave.sol +++ b/contracts/callManagers/LendingManager/LendingLogicAave.sol @@ -13,6 +13,7 @@ contract LendingLogicAave is ILendingLogic { uint16 public referralCode; constructor(address _lendingPool, uint16 _referralCode) { + require(_lendingPool != address(0), "LENDING_POOL_INVALID"); lendingPool = IAaveLendingPool(_lendingPool); referralCode = _referralCode; } diff --git a/test/lendingLogicAave.ts b/test/lendingLogicAave.ts index beb72a3..9458db8 100644 --- a/test/lendingLogicAave.ts +++ b/test/lendingLogicAave.ts @@ -53,6 +53,11 @@ describe("LendingLogicAave", function() { await timeTraveler.revertSnapshot(); }); + it("Deploying with lendingPool set to the zero address should fail", async() => { + const promise = deployContract(signers[0], LendingLogicAaveArtifact, [constants.AddressZero, 0]); + await expect(promise).to.be.revertedWith("LENDING_POOL_INVALID"); + }); + it("lend()", async() => { const calls = await lendingLogic.lend(token.address, mintAmount);