Skip to content

Commit

Permalink
🌙 Add closeVessel fees tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MiksuJak committed Apr 24, 2024
1 parent a4b4fe8 commit 7e55052
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion test/trinity/BorrowerOperations_FeesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {_1e18BN} = testHelpers.MoneyValues


contract("BorrowerOperations_Fees", async accounts => {
const [owner, alice, treasury] = accounts
const [owner, alice, bob, treasury] = accounts

let contracts
let snapshotId
Expand All @@ -29,6 +29,17 @@ contract("BorrowerOperations_Fees", async accounts => {
})
}

async function closeVessel(account) {
const {borrowerOperations, erc20} = contracts.core
return borrowerOperations.closeVessel(erc20.address, {
from: account,
})
}

async function mintDebtTokens(account, amount) {
return contracts.core.debtToken.unprotectedMint(account, amount)
}

async function skipToNextEpoch() {
await th.fastForwardTime(SECONDS_IN_ONE_WEEK, web3.currentProvider)
}
Expand Down Expand Up @@ -196,6 +207,43 @@ contract("BorrowerOperations_Fees", async accounts => {
})
})

describe('closeVessel', () => {
it('does not add fees mid epoch', async () => {
const {erc20, debtToken, borrowerOperations} = contracts.core
await openVessel(alice)
await openVessel(bob)
await skipToNextEpoch()

await borrowerOperations.collectVesselFee(erc20.address, alice)

const treasuryBalanceBefore = await debtToken.balanceOf(treasury)

await mintDebtTokens(alice, vesselTotalDebt)
await closeVessel(alice)

const treasuryBalanceAfter = await debtToken.balanceOf(treasury)

assert.isTrue(treasuryBalanceBefore.eq(treasuryBalanceAfter))
})

it('skips due fee payment when called before collectVesselFee', async () => {
const {debtToken} = contracts.core
await openVessel(alice)
await openVessel(bob)

const treasuryBalanceBefore = await debtToken.balanceOf(treasury)

await skipToNextEpoch()

await mintDebtTokens(alice, vesselTotalDebt)
await closeVessel(alice)

const treasuryBalanceAfter = await debtToken.balanceOf(treasury)

assert.isTrue(treasuryBalanceBefore.eq(treasuryBalanceAfter))
})
})

describe('collectVesselFee', () => {
it('does nothing if called twice in single epoch', async () => {
const {erc20, borrowerOperations, vesselManager} = contracts.core
Expand Down

0 comments on commit 7e55052

Please sign in to comment.