Skip to content

Commit

Permalink
Adding tests for releaseDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpar committed Apr 10, 2024
1 parent 0cb1123 commit 59c3d6f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions core/test/MezoAllocator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,48 @@ describe("MezoAllocator", () => {
})
})
})

describe("releaseDeposit", () => {
beforeAfterSnapshotWrapper()

context("when a caller is not a maintainer", () => {
it("should revert", async () => {
await expect(
mezoAllocator.connect(thirdParty).releaseDeposit(),
).to.be.revertedWithCustomError(
mezoAllocator,
"OwnableUnauthorizedAccount",
)
})
})

context("when the caller is governance", () => {
context("when there is a deposit", () => {
let tx: ContractTransactionResponse

before(async () => {
await tbtc.mint(await stbtc.getAddress(), to1e18(5))
await mezoAllocator.connect(maintainer).allocate()
tx = await mezoAllocator.connect(governance).releaseDeposit()
})

it("should emit DepositReleased event", async () => {
await expect(tx)
.to.emit(mezoAllocator, "DepositReleased")
.withArgs(1, to1e18(5))
})

it("should decrease tracked deposit balance amount to zero", async () => {
const depositBalance = await mezoAllocator.depositBalance()
expect(depositBalance).to.equal(0)
})

it("should decrease Mezo Portal balance", async () => {
expect(await tbtc.balanceOf(await mezoPortal.getAddress())).to.equal(
0,
)
})
})
})
})
})

0 comments on commit 59c3d6f

Please sign in to comment.