diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 5d25820d5..024f162e3 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -55,6 +55,7 @@ describe("System Test - Deposit and redemption", () => { let depositorBridgeHandle: EthereumBridge let bank: Contract let relay: Contract + let tbtc: Contract const depositAmount = BigNumber.from(2000000) const depositSweepTxFee = BigNumber.from(10000) @@ -63,6 +64,8 @@ describe("System Test - Deposit and redemption", () => { // Initial backoff step in milliseconds that will be increased exponentially for // subsequent Electrum retry attempts. const ELECTRUM_RETRY_BACKOFF_STEP_MS = 10000 // 10sec + // Multiplier to convert satoshi to TBTC token units. + const SATOSHI_MULTIPLIER: BigNumber = BigNumber.from("10000000000") let deposit: Deposit let depositUtxo: UnspentTransactionOutput @@ -112,6 +115,12 @@ describe("System Test - Deposit and redemption", () => { relayDeploymentInfo.abi, maintainer ) + + const tbtcDeploymentInfo = deployedContracts.TBTC + tbtc = new Contract( + tbtcDeploymentInfo.address, + tbtcDeploymentInfo.abi, + ) }) context("when deposit is made and revealed without a vault", () => { @@ -484,7 +493,8 @@ describe("System Test - Deposit and redemption", () => { value: BigNumber.from(0), }, maintainerBridgeHandle, - electrumClient + electrumClient, + deposit.vault, ) console.log(` @@ -507,7 +517,7 @@ describe("System Test - Deposit and redemption", () => { expect(sweptAt).to.be.greaterThan(0) }) - it("should increase depositor's balance in the bank", async () => { + it("should increase vault's balance in the bank", async () => { const { treasuryFee } = await TBTC.getRevealedDeposit( depositUtxo, maintainerBridgeHandle @@ -518,6 +528,25 @@ describe("System Test - Deposit and redemption", () => { .sub(depositSweepTxFee) const actualBalance = await bank.balanceOf( + vaultAddress + ) + + expect(actualBalance).to.be.equal(expectedBalance) + }) + + it("should mint TBTC tokens for the depositor", async () => { + const { treasuryFee } = await TBTC.getRevealedDeposit( + depositUtxo, + maintainerBridgeHandle + ) + + const balanceInSatoshis = depositAmount + .sub(treasuryFee) + .sub(depositSweepTxFee) + + const expectedBalance = balanceInSatoshis.mul(SATOSHI_MULTIPLIER) + + const actualBalance = tbtc.balanceOf( systemTestsContext.depositor.address )