itest: fix anchor SCB sweep tests

Fixes another flake related to Neutrino and how it handles UTXOs.
This commit is contained in:
Oliver Gugger 2021-07-13 18:12:37 +02:00
parent f68335d7e4
commit 6421fd532c
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
2 changed files with 23 additions and 2 deletions

View File

@ -1305,7 +1305,6 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
// Dave should sweep his funds immediately, as they are not timelocked.
// We also expect Dave to sweep his anchor, if present.
_, err = waitForNTxsInMempool(
net.Miner.Client, expectedTxes, minerMempoolTimeout,
)
@ -1341,7 +1340,7 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
// After the Carol's output matures, she should also reclaim her funds.
//
// The commit sweep resolver publishes the sweep tx at defaultCSV-1 and
// we already mined one block after the commitmment was published, so
// we already mined one block after the commitment was published, so
// take that into account.
mineBlocks(t, net, defaultCSV-1-1, 0)
carolSweep, err := waitForTxInMempool(
@ -1363,6 +1362,16 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
}
carolBalance := carolBalResp.ConfirmedBalance
// With Neutrino we don't get a backend error when trying to
// publish an orphan TX (which is what the sweep for the remote
// anchor is since the remote commitment TX was not broadcast).
// That's why the wallet still sees that as unconfirmed and we
// need to count the total balance instead of the confirmed.
if net.BackendCfg.Name() == lntest.NeutrinoBackendName {
carolBalance = carolBalResp.TotalBalance
}
if carolBalance <= carolStartingBalance {
return fmt.Errorf("expected carol to have balance "+
"above %d, instead had %v", carolStartingBalance,

View File

@ -847,6 +847,12 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
// For the anchor output case we need two UTXOs for Carol so she can
// sweep both the local and remote anchor.
if testCase.anchorCommit {
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
@ -1077,6 +1083,12 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
err = restartCarol()
require.NoError(t.t, err)
numUTXOs := 1
if testCase.anchorCommit {
numUTXOs = 2
}
assertNumUTXOs(t.t, carol, numUTXOs)
// Now that we have our new node up, we expect that it'll re-connect to
// Carol automatically based on the restored backup.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)