From 91807625bbd449945fad7a8a893942f4ac68dbda Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 17 Jul 2024 19:20:33 +0800 Subject: [PATCH] itest: fix `testUnconfirmedChannelFunding` for neutrino This test was previously working because we'd mine an extra block to confirm the coins inside `FundCoinsUnconfirmed` when it's a neutrino backend, as shown in https://github.com/lightningnetwork/lnd/blob/fdd28c8d888792ea8fde3c557ba9f2594e0a6ec8/lntest/harness.go#L1431 Since neutrino has trouble seeing unconfirmed balance, we now send some coins to the wallet, confirm those, then do a self-transfer so the node will have unconfirmed outputs to perform the test. --- itest/lnd_funding_test.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/itest/lnd_funding_test.go b/itest/lnd_funding_test.go index c6c79a893c..8f43620ee1 100644 --- a/itest/lnd_funding_test.go +++ b/itest/lnd_funding_test.go @@ -291,6 +291,24 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) { // We'll send her some unconfirmed funds. ht.FundCoinsUnconfirmed(2*chanAmt, carol) + // For neutrino backend, we will confirm the coins sent above and let + // Carol send all her funds to herself to create unconfirmed output. + if ht.IsNeutrinoBackend() { + // Confirm the above coins. + ht.MineBlocksAndAssertNumTxes(1, 1) + + // Create a new address and send to herself. + resp := carol.RPC.NewAddress(&lnrpc.NewAddressRequest{ + Type: lnrpc.AddressType_TAPROOT_PUBKEY, + }) + + // Once sent, Carol would have one unconfirmed UTXO. + carol.RPC.SendCoins(&lnrpc.SendCoinsRequest{ + Addr: resp.Address, + SendAll: true, + }) + } + // Now, we'll connect her to Alice so that they can open a channel // together. The funding flow should select Carol's unconfirmed output // as she doesn't have any other funds since it's a new node. @@ -361,11 +379,7 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) { // parties. For neutrino backend, the funding transaction should be // mined. Otherwise, two transactions should be mined, the unconfirmed // spend and the funding tx. - if ht.IsNeutrinoBackend() { - ht.MineBlocksAndAssertNumTxes(6, 1) - } else { - ht.MineBlocksAndAssertNumTxes(6, 2) - } + ht.MineBlocksAndAssertNumTxes(6, 2) chanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)