diff --git a/test/unit/CompoundModel/CompoundModel.ts b/test/unit/CompoundModel/CompoundModel.ts index b1ec6eb..eadc028 100644 --- a/test/unit/CompoundModel/CompoundModel.ts +++ b/test/unit/CompoundModel/CompoundModel.ts @@ -1,9 +1,45 @@ -import { initialBehavior } from "./initialize.behavior" -import { setUpBehavior } from "./setup.behavior" - -export function unitTestCompoundModel(): void { - describe("CompoundModel", function() { - initialBehavior() - setUpBehavior() - }) +import { initialBehavior } from "./initialize.behavior"; +import { setUpBehavior } from "./setup.behavior"; +import { expect } from "chai"; +import { ethers } from "hardhat"; +import { ModelStorage } from "../../typechain/ModelStorage"; +import { AaveYieldStrategy } from "../../typechain/AaveYieldStrategy"; +import { AaveLendingPool } from "../../typechain/AaveLendingPool"; + +export function unitTestAaveYieldStrategy(): void { + describe("AaveYieldStrategy", function () { + let modelStorage: ModelStorage; + let aaveYieldStrategy: AaveYieldStrategy; + let aaveLendingPool: AaveLendingPool; + + before(async function () { + const [owner] = await ethers.getSigners(); + modelStorage = await ethers.deployContract(owner, ModelStorage); + aaveYieldStrategy = await ethers.deployContract(owner, AaveYieldStrategy, modelStorage.address); + aaveLendingPool = await ethers.deployContract(owner, AaveLendingPool); + }); + + initialBehavior(); + + setUpBehavior(); + + it("should deposit to Aave Lending Pool", async function () { + const depositAmount = ethers.utils.parseEther("100"); + await aaveYieldStrategy.deposit(depositAmount); + expect(await aaveLendingPool.balanceOf(aaveYieldStrategy.address)).to.be.equal(depositAmount); + }); + + it("should withdraw from Aave Lending Pool", async function () { + const withdrawAmount = ethers.utils.parseEther("50"); + await aaveYieldStrategy.withdraw(withdrawAmount); + expect(await aaveLendingPool.balanceOf(aaveYieldStrategy.address)).to.be.equal(ethers.utils.parseEther("50")); + }); + + it("should earn interest from Aave Lending Pool", async function () { + const interestRate = ethers.utils.parseEther("0.05"); + await aaveLendingPool.setInterestRate(interestRate); + await aaveYieldStrategy.earnInterest(); + expect(await aaveYieldStrategy.balanceOf()).to.be.gt(ethers.utils.parseEther("100")); + }); + }); } \ No newline at end of file