Skip to content

Commit

Permalink
Fix request redemption scenario in system tests
Browse files Browse the repository at this point in the history
The `Bank` contract returns the balance in Satoshis. Here we convert the
balance to the tBTC token precision because the `requestRedemption`
function from `tbtc-v2.ts` lib requires the amount in tBTC token
precision.
  • Loading branch information
r-czajkowski committed Jul 11, 2023
1 parent 0826d7e commit ee3cab1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions system-tests/test/deposit-redemption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("System Test - Deposit and redemption", () => {

tbtcTokenHandle = new EthereumTBTCToken({
address: deployedContracts.TBTC.address,
signerOrProvider: depositor
signerOrProvider: depositor,
})

const bankDeploymentInfo = deployedContracts.Bank
Expand Down Expand Up @@ -259,6 +259,14 @@ describe("System Test - Deposit and redemption", () => {
systemTestsContext.depositor.address
)

// The `Bank` contract returns the balance in Satoshis. Here we convert
// the balance to the tBTC token precision because the
// `requestRedemption` function from tbtc-v2.ts lib requires the
// amount in tBTC token precision.
const requestAmountInTokenPrecision = BigNumber.from(
requestedAmount
).mul(BigNumber.from(10).pow(10))

// Request redemption to depositor's address.
redeemerOutputScript = `0014${computeHash160(
systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed
Expand All @@ -268,7 +276,7 @@ describe("System Test - Deposit and redemption", () => {
systemTestsContext.walletBitcoinKeyPair.publicKey.compressed,
sweepUtxo,
redeemerOutputScript,
requestedAmount,
requestAmountInTokenPrecision,
tbtcTokenHandle
)

Expand Down

0 comments on commit ee3cab1

Please sign in to comment.