-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🦨 Add test coverage to MDC package (#572)
- Loading branch information
Showing
6 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# tests coverage output | ||
coverage | ||
coverage.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
skipFiles: [ | ||
'./carbon', | ||
], | ||
modifierWhitelist: ['initializer'], | ||
onCompileComplete: async () => { | ||
const { spawn } = require('child_process') | ||
const child = spawn('pnpm', ['build:typechain']) | ||
await new Promise((res, rej) => { | ||
child.on('exit', res) | ||
child.on('error', rej) | ||
}); | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { setupFixtureLoader } from 'test/setup' | ||
import { PortfolioStatus, structuredPortfolioFixture } from 'fixtures/structuredPortfolioFixture' | ||
import { parseUSDC } from 'utils' | ||
import { expect } from 'chai' | ||
import { MinimumDepositController__factory } from 'build/types' | ||
|
||
describe('MinimumDepositController.maxDeposit', () => { | ||
const loadFixture = setupFixtureLoader() | ||
const minimumDeposit = parseUSDC(100) | ||
const ceiling = parseUSDC(5e9) | ||
|
||
it('previews max deposit', async () => { | ||
const { equityTranche, wallet } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) | ||
|
||
expect(await equityTranche.maxDeposit(wallet.address)).to.eq(ceiling) | ||
}) | ||
|
||
it('previews current max deposit', async () => { | ||
const { equityTranche, wallet, depositToTranche } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) | ||
await depositToTranche(equityTranche, minimumDeposit) | ||
|
||
expect(await equityTranche.maxDeposit(wallet.address)).to.eq(ceiling.sub(minimumDeposit)) | ||
}) | ||
|
||
it('returns zero if deposit is not allowed', async () => { | ||
const { equityTranche, wallet } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) | ||
const depositController = MinimumDepositController__factory.connect(await equityTranche.depositController(), wallet) | ||
await depositController.setDepositAllowed(false, PortfolioStatus.CapitalFormation) | ||
|
||
expect(await equityTranche.maxDeposit(wallet.address)).to.eq(0) | ||
}) | ||
|
||
it('returns zero if tranche is full', async () => { | ||
const { equityTranche, wallet, depositToTranche } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) | ||
const depositController = MinimumDepositController__factory.connect(await equityTranche.depositController(), wallet) | ||
const amount = parseUSDC(150) | ||
await depositController.setCeiling(amount) | ||
await depositToTranche(equityTranche, amount) | ||
|
||
expect(await equityTranche.maxDeposit(wallet.address)).to.eq(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { setupFixtureLoader } from 'test/setup' | ||
import { structuredPortfolioFixture } from 'fixtures/structuredPortfolioFixture' | ||
import { parseUSDC } from 'utils' | ||
import { expect } from 'chai' | ||
|
||
describe('MinimumDepositController.previewMint', () => { | ||
const loadFixture = setupFixtureLoader() | ||
const minimumDeposit = parseUSDC(100) | ||
|
||
it('previews the mint amount', async () => { | ||
const { equityTranche } = await loadFixture(structuredPortfolioFixture(minimumDeposit)) | ||
const amount = parseUSDC(100) | ||
|
||
expect(await equityTranche.previewMint(amount)).to.eq(amount) | ||
}) | ||
}) |