Skip to content

Commit

Permalink
Fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymx95 committed Apr 24, 2024
1 parent 72b4f20 commit 742f56d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion test/trinity/StabilityPoolTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,9 @@ contract("StabilityPool", async accounts => {
}) // 180 TRI closed
await stabilityPool.withdrawFromSP(dec(199_000, 18), validCollateral, { from: whale })
const stability_col_AfterWhaleERC20 = await stabilityPool.getCollateral(erc20.address)
assert.isAtMost(stability_col_AfterWhaleERC20.sub(aliceExpectedGainERC20), 10000)

const lastAssetError_Offset= (await stabilityPool.lastAssetError_Offset(idx)).div(toBN(10).pow(toBN(18)))
assert.closeTo(stability_col_AfterWhaleERC20.sub(aliceExpectedGainERC20), lastAssetError_Offset, toBN(Math.floor(lastAssetError_Offset * 0.001)))
})

it("withdrawFromSP(): withdraw from SP, passing same asset twice will revert", async () => {
Expand Down
11 changes: 7 additions & 4 deletions test/trinity/VesselManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1201,19 +1201,22 @@ contract("VesselManager", async accounts => {

const totalDeposits_Asset = bob_Deposit_Before_Asset.add(A_spDeposit)

const lastAssetError_Offset= (await stabilityPool.lastAssetError_Offset(idx)).div(toBN(10).pow(toBN(18)))
const lastDebtTokenLossError_Offset = (await stabilityPool.lastDebtTokenLossError_Offset()).div(toBN(10).pow(toBN(18)))

assert.isAtMost(
th.getDifference(
alice_Deposit_After_Asset,
A_spDeposit.sub(B_debt_Asset.mul(A_spDeposit).div(totalDeposits_Asset))
),
1000000
lastDebtTokenLossError_Offset
)
assert.isAtMost(
th.getDifference(
alice_ETHGain_After_Asset,
th.applyLiquidationFee(B_collateral_Asset).mul(A_spDeposit).div(totalDeposits_Asset)
),
1000000
lastAssetError_Offset
)

const bob_Deposit_After_Asset = await stabilityPool.getCompoundedDebtTokenDeposits(bob)
Expand All @@ -1224,7 +1227,7 @@ contract("VesselManager", async accounts => {
bob_Deposit_After_Asset,
bob_Deposit_Before_Asset.sub(B_debt_Asset.mul(bob_Deposit_Before_Asset).div(totalDeposits_Asset))
),
1000000
lastDebtTokenLossError_Offset
)
assert.isAtMost(
th.getDifference(
Expand All @@ -1233,7 +1236,7 @@ contract("VesselManager", async accounts => {
th.applyLiquidationFee(B_collateral_Asset).mul(bob_Deposit_Before_Asset).div(totalDeposits_Asset)
)
),
1000000
lastAssetError_Offset
)
})

Expand Down
2 changes: 1 addition & 1 deletion test/trinity/VesselManager_RecoveryModeTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,7 @@ contract("VesselManager - in Recovery Mode", async accounts => {
const dennis_ETHGain_Before_Asset = (await getDepositorGain(dennis, validCollateral, erc20.address)).toString()

const lastDebtTokenLossError_Offset = (await stabilityPool.lastDebtTokenLossError_Offset()).div(toBN(10).pow(toBN(18)))
const idx = validCollateral.indexOf(erc20.address)
const idx = (await adminContract.getValidCollateral()).indexOf(erc20.address)
const lastAssetError_Offset= (await stabilityPool.lastAssetError_Offset(idx)).div(toBN(10).pow(toBN(18)))

assert.equal(th.getDifference(dennis_Deposit_Before_Asset, spDeposit_Asset.sub(C_totalDebt_Asset)).toString(), lastDebtTokenLossError_Offset.toString())
Expand Down

0 comments on commit 742f56d

Please sign in to comment.