From f26a9a84d71fb48ddd77abed4ce81258b41387d2 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 8 Dec 2022 11:48:54 +0100 Subject: [PATCH] lntest: fix rescan test to show correct behavior Now that we have patched the btcwallet version to the one that includes the fix, we can adjust the rescan test to show the correct and expected behavior. --- lntest/itest/lnd_recovery_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lntest/itest/lnd_recovery_test.go b/lntest/itest/lnd_recovery_test.go index fa53f7c4b..4ba521912 100644 --- a/lntest/itest/lnd_recovery_test.go +++ b/lntest/itest/lnd_recovery_test.go @@ -355,18 +355,15 @@ func testRescanAddressDetection(ht *lntemp.HarnessTest) { // Make sure we see the change output in our list of unspent outputs. // We _don't_ expect to see the ghost UTXO here as in this step it's // ignored as an internal address correctly. - // TODO(guggero): This is incorrect, should only be 1 UTXO. - ht.AssertNumUTXOsConfirmed(carol, 2) + ht.AssertNumUTXOsConfirmed(carol, 1) unspent := carol.RPC.ListUnspent(&walletrpc.ListUnspentRequest{ MinConfs: 1, }) // Which one was the change output and which one the ghost UTXO output? var ghostUtxoIndex uint32 - if unspent.Utxos[0].Address == ghostUtxoAddr.String() { - ghostUtxoIndex = unspent.Utxos[0].Outpoint.OutputIndex - } else { - ghostUtxoIndex = unspent.Utxos[1].Outpoint.OutputIndex + if unspent.Utxos[0].Outpoint.OutputIndex == 0 { + ghostUtxoIndex = 1 } ghostUtxoHash, err := chainhash.NewHash( @@ -442,6 +439,5 @@ func testRescanAddressDetection(ht *lntemp.HarnessTest) { // There should now still only be a single UTXO from the change output // instead of two (the ghost UTXO should be missing if the fix works). - // TODO(guggero): This is incorrect, should only be 1 UTXO. - ht.AssertNumUTXOsConfirmed(carol, 2) + ht.AssertNumUTXOsConfirmed(carol, 1) }