From ee3cab1199b6bdf0c9e37411ec23c187efc64d03 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 11 Jul 2023 15:33:41 +0200 Subject: [PATCH] Fix request redemption scenario in system tests 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. --- system-tests/test/deposit-redemption.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 3c2b33197..2d9aa8b98 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -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 @@ -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 @@ -268,7 +276,7 @@ describe("System Test - Deposit and redemption", () => { systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, sweepUtxo, redeemerOutputScript, - requestedAmount, + requestAmountInTokenPrecision, tbtcTokenHandle )