Skip to content

Commit

Permalink
Tweak failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alsco77 committed Feb 23, 2021
1 parent 101ae77 commit bbc3d85
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
33 changes: 23 additions & 10 deletions test/masset/mint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ describe("Masset - Mint", () => {
)
expect(integratorBalAfter, "integratorBalAfter").eq(integratorBalBefore.add(bAssetQuantityExact))
if (platformInteraction.expectInteraction) {
await expect(tx).to.emit(platform, "Deposit").withArgs(bAsset.address, bAssetBefore.pToken, platformInteraction.amount)
await expect(tx)
.to.emit(platform, "Deposit")
.withArgs(bAsset.address, bAssetBefore.pToken, platformInteraction.amount)
}

// Recipient should have mAsset quantity after
Expand Down Expand Up @@ -269,7 +271,9 @@ describe("Masset - Mint", () => {
// take 0.1% off for the transfer fee = amount * (1 - 0.001)
const bAssetAmountLessFee = bAssetQuantity.mul(999).div(1000)
// 3.1 Check Transfers to lending platform
await expect(tx).to.emit(bAsset, "Transfer").withArgs(sa.default.address, platform.address, bAssetAmountLessFee)
await expect(tx)
.to.emit(bAsset, "Transfer")
.withArgs(sa.default.address, platform.address, bAssetAmountLessFee)
// 3.2 Check Deposits into lending platform
await expect(tx)
.to.emit(platform, "Deposit")
Expand Down Expand Up @@ -362,11 +366,12 @@ describe("Masset - Mint", () => {
bAsset,
100,
99,
true,
false,
sender.signer,
sender.address,
false,
100,
true,
)
})
it("should fail if the bAsset does not exist", async () => {
Expand Down Expand Up @@ -530,15 +535,21 @@ describe("Masset - Mint", () => {
const platformToken = await platform.bAssetToPToken(bAsset.address)
const lendingPlatform = await platform.platformAddress()
// 3.1 Check Transfers from sender to platform integration
await expect(tx).to.emit(bAsset, "Transfer").withArgs(sa.default.address, platform.address, bAssetAmountLessFee)
await expect(tx)
.to.emit(bAsset, "Transfer")
.withArgs(sa.default.address, platform.address, bAssetAmountLessFee)
// 3.2 Check Transfers from platform integration to lending platform
await expect(tx).to.emit(bAsset, "Transfer").withArgs(
platform.address,
lendingPlatform,
bAssetAmountLessFee.mul(999).div(1000), // Take another 0.1% off the transfer value
)
await expect(tx)
.to.emit(bAsset, "Transfer")
.withArgs(
platform.address,
lendingPlatform,
bAssetAmountLessFee.mul(999).div(1000), // Take another 0.1% off the transfer value
)
// 3.3 Check Deposits into lending platform
await expect(tx).to.emit(platform, "Deposit").withArgs(bAsset.address, platformToken, bAssetAmountLessFee)
await expect(tx)
.to.emit(platform, "Deposit")
.withArgs(bAsset.address, platformToken, bAssetAmountLessFee)
// 4.0 Recipient should have mAsset quantity after
const recipientBalAfter = await mAsset.balanceOf(recipient.address)
// Assert that we minted gt 99% of the bAsset
Expand Down Expand Up @@ -613,6 +624,7 @@ describe("Masset - Mint", () => {
ZERO_ADDRESS,
false,
1,
true,
)
})
context("with incorrect bAsset array", async () => {
Expand Down Expand Up @@ -719,6 +731,7 @@ describe("Masset - Mint", () => {
sa.default.address,
false,
100,
true,
)
})
it("should fail if the bAsset does not exist", async () => {
Expand Down
21 changes: 9 additions & 12 deletions test/masset/redeem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ describe("Masset - Redeem", () => {
await expect(tx, "PlatformWithdrawal event").to.emit(platform, "PlatformWithdrawal")
// .withArgs(bAsset.address, bAssetBefore.pToken, platformInteraction.amount, bAssetQuantityExact)
} else if (platformInteraction.hasLendingMarket) {
await expect(tx, "Withdrawal event").to.emit(platform, "Withdrawal").withArgs(bAsset.address, bAssetQuantityExact)
await expect(tx, "Withdrawal event")
.to.emit(platform, "Withdrawal")
.withArgs(bAsset.address, bAssetQuantityExact)
}
// Transfer events
await expect(tx, "Transfer event to burn the redeemed mAssets")
Expand Down Expand Up @@ -639,7 +641,7 @@ describe("Masset - Redeem", () => {
const sender = sa.dummy1
expect(await mAsset.balanceOf(sender.address)).eq(0)
await assertFailedBasicRedemption(
"ERC20: transfer amount exceeds balance",
"ERC20: burn amount exceeds balance",
mAsset,
bAssets[0],
"10000000000000000000",
Expand Down Expand Up @@ -781,7 +783,9 @@ describe("Masset - Redeem", () => {
// VaultBalance should update for this bAsset
const bAssetAfter = await mAsset.getBasset(bAsset.address)
expect(BN.from(bAssetAfter.data.vaultBalance), "before != after + fee").eq(
BN.from(bAssetBefore.data.vaultBalance).sub(oneBasset).add(bAssetFee),
BN.from(bAssetBefore.data.vaultBalance)
.sub(oneBasset)
.add(bAssetFee),
)
})
it("should send less output to user if fee unexpected", async () => {
Expand Down Expand Up @@ -991,7 +995,7 @@ describe("Masset - Redeem", () => {
const sender = sa.dummy1
expect(await mAsset.balanceOf(sender.address)).eq(0)
await assertFailedExactBassetsRedemption(
"ERC20: transfer amount exceeds balance",
"ERC20: burn amount exceeds balance",
mAsset,
bAssets,
[1, 2, 3, 4],
Expand Down Expand Up @@ -1124,14 +1128,7 @@ describe("Masset - Redeem", () => {
const { bAssets, mAsset } = details
const sender = sa.dummy1
expect(await mAsset.balanceOf(sender.address)).eq(0)
await assertFailedMassetRedemption(
"ERC20: transfer amount exceeds balance",
mAsset,
10,
[2, 2, 2, 2],
bAssets,
sender.signer,
)
await assertFailedMassetRedemption("ERC20: burn amount exceeds balance", mAsset, 10, [2, 2, 2, 2], bAssets, sender.signer)
})
context("when a bAsset has broken its peg", () => {
it("should fail if broken below peg", async () => {
Expand Down

0 comments on commit bbc3d85

Please sign in to comment.