From 4d7074138476783a8e2954fefcbc48152d791c0b Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 24 Jul 2023 12:17:44 +0200 Subject: [PATCH] Used main UTXO data from previous test case --- system-tests/test/deposit-redemption.test.ts | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 2ccbc5735..f40c0c6d0 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -70,6 +70,7 @@ describe("System Test - Deposit and redemption", () => { let deposit: Deposit let depositUtxo: UnspentTransactionOutput let sweepUtxo: UnspentTransactionOutput + let redemptionUtxo: UnspentTransactionOutput | undefined before(async () => { systemTestsContext = await setupSystemTestsContext() @@ -328,7 +329,7 @@ describe("System Test - Deposit and redemption", () => { before( "make the redemption and submit redemption proof", async () => { - ;({ transactionHash: redemptionTxHash } = + ;({ transactionHash: redemptionTxHash, newMainUtxo: redemptionUtxo } = await submitRedemptionTransaction( electrumClient, maintainerBridgeHandle, @@ -459,7 +460,8 @@ describe("System Test - Deposit and redemption", () => { systemTestsContext.walletBitcoinKeyPair.wif, true, [depositUtxo], - [deposit] + [deposit], + redemptionUtxo // The UTXO from the previous test became the new main UTXO. )) console.log(` @@ -481,18 +483,16 @@ describe("System Test - Deposit and redemption", () => { sweepUtxo.transactionHash ) - // TODO: Consider fetching the current wallet main UTXO and passing it - // here. This will allow running this test scenario multiple - // times for the same wallet. + // If the redemption transaction from the previous test created a new + // main UTXO, use it. Otherwise call it with a zero-filled main UTXO. + const mainUtxo = redemptionUtxo ? redemptionUtxo : { + transactionHash: BitcoinTransactionHash.from(constants.HashZero), + outputIndex: 0, + value: BigNumber.from(0), + }; await SpvMaintainer.submitDepositSweepProof( sweepUtxo.transactionHash, - // This is the first sweep of the given wallet so there is no main UTXO. - { - // The function expects an unprefixed hash. - transactionHash: BitcoinTransactionHash.from(constants.HashZero), - outputIndex: 0, - value: BigNumber.from(0), - }, + mainUtxo, maintainerBridgeHandle, electrumClient, deposit.vault,