Skip to content

Commit

Permalink
Adjusted test scenario to account for the vault presence
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Jul 18, 2023
1 parent 7aba3cf commit f6117bc
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions system-tests/test/deposit-redemption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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", () => {
Expand Down Expand Up @@ -484,7 +493,8 @@ describe("System Test - Deposit and redemption", () => {
value: BigNumber.from(0),
},
maintainerBridgeHandle,
electrumClient
electrumClient,
deposit.vault,
)

console.log(`
Expand All @@ -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
Expand All @@ -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
)

Expand Down

0 comments on commit f6117bc

Please sign in to comment.