Skip to content

Commit

Permalink
Fix PoolController test (#136)
Browse files Browse the repository at this point in the history
* Fix PoolController test

* Move FirstLossDeposited event to interface
  • Loading branch information
bricestacey authored Dec 8, 2022
1 parent 4b03c2a commit 5c26c64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 9 additions & 0 deletions contracts/controllers/interfaces/IPoolController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ interface IPoolController {
*/
event LoanDefaulted(address indexed loan);

/**
* @dev Emitted when first loss is supplied to the pool.
*/
event FirstLossDeposited(
address indexed caller,
address indexed spender,
uint256 amount
);

/**
* @dev Emitted when first loss capital is used to cover loan defaults
*/
Expand Down
9 changes: 4 additions & 5 deletions test/controllers/PoolController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,13 @@ describe("PoolController", () => {
});

it("if the pool is closed, the withdraw window won't increase if it's already less than 1 day", async () => {
const { operator, poolAdmin } = await loadFixture(loadPoolFixture);
const { poolAdmin } = await loadFixture(loadPoolFixture);

const overriddenPoolSettings = {
withdrawRequestPeriodDuration: 86399
};

const { poolController: newPoolController } = await deployPool({
operator,
poolAdmin: poolAdmin,
settings: overriddenPoolSettings
});
Expand Down Expand Up @@ -506,8 +505,8 @@ describe("PoolController", () => {
.approve(poolController.address, firstLossAmount);

// Contribute first loss
expect(
await poolController
await expect(
poolController
.connect(poolAdmin)
.depositFirstLoss(firstLossAmount, poolAdmin.address)
).to.emit(poolController, "FirstLossDeposited");
Expand Down Expand Up @@ -907,7 +906,7 @@ describe("PoolController", () => {
expect((await pool.accountings()).totalDefaults).to.equal(0);
expect((await pool.accountings()).totalFirstLossApplied).to.equal(0);

poolController.connect(poolAdmin).defaultLoan(loan.address);
await poolController.connect(poolAdmin).defaultLoan(loan.address);
expect((await pool.accountings()).totalDefaults).to.equal(
await loan.principal()
);
Expand Down

0 comments on commit 5c26c64

Please sign in to comment.