Skip to content

Commit

Permalink
Fixed tests now debt can become negative
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCambon committed Oct 18, 2024
1 parent 9b30332 commit 45d96fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/test-erc4626-cash-flow-lender.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe("ERC4626CashFlowLender contract tests", function () {
.withArgs(lp2, erc4626cfl, _A(50));

// Repay all debt
await expect(erc4626cfl.connect(lp2).repayDebt(MaxUint256))
await expect(erc4626cfl.connect(lp2).repayDebt(_A(150)))
.to.emit(erc4626cfl, "DebtChanged")
.withArgs(_A(0))
.to.emit(currency, "Transfer")
Expand All @@ -291,9 +291,10 @@ describe("ERC4626CashFlowLender contract tests", function () {
expect(await erc4626cfl.currentDebt()).to.be.equal(_A(0));
expect(lp2before - (await currency.balanceOf(lp2))).to.equal(_A(200));

await expect(erc4626cfl.connect(lp2).repayDebt(_A(1000))).to.be.revertedWith(
"ERC4626CashFlowLender: you can't repay because there's no debt"
);
// Repay exceeds & debt becomes negative
await erc4626cfl.connect(lp2).repayDebt(_A(300))
expect(await erc4626cfl.currentDebt()).to.be.equal(_A(-300));
expect(lp2before - (await currency.balanceOf(lp2))).to.equal(_A(500));
});

it("Address without LP_ROLE can't deposit/mint", async () => {
Expand Down

0 comments on commit 45d96fe

Please sign in to comment.