Skip to content

Commit

Permalink
Used main UTXO data from previous test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Jul 24, 2023
1 parent 580040f commit 4d70741
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions system-tests/test/deposit-redemption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(`
Expand All @@ -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,
Expand Down

0 comments on commit 4d70741

Please sign in to comment.