Skip to content

Commit 9180762

Browse files
committed
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.
1 parent 2d21aa3 commit 9180762

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

itest/lnd_funding_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,24 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
291291
// We'll send her some unconfirmed funds.
292292
ht.FundCoinsUnconfirmed(2*chanAmt, carol)
293293

294+
// For neutrino backend, we will confirm the coins sent above and let
295+
// Carol send all her funds to herself to create unconfirmed output.
296+
if ht.IsNeutrinoBackend() {
297+
// Confirm the above coins.
298+
ht.MineBlocksAndAssertNumTxes(1, 1)
299+
300+
// Create a new address and send to herself.
301+
resp := carol.RPC.NewAddress(&lnrpc.NewAddressRequest{
302+
Type: lnrpc.AddressType_TAPROOT_PUBKEY,
303+
})
304+
305+
// Once sent, Carol would have one unconfirmed UTXO.
306+
carol.RPC.SendCoins(&lnrpc.SendCoinsRequest{
307+
Addr: resp.Address,
308+
SendAll: true,
309+
})
310+
}
311+
294312
// Now, we'll connect her to Alice so that they can open a channel
295313
// together. The funding flow should select Carol's unconfirmed output
296314
// as she doesn't have any other funds since it's a new node.
@@ -361,11 +379,7 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
361379
// parties. For neutrino backend, the funding transaction should be
362380
// mined. Otherwise, two transactions should be mined, the unconfirmed
363381
// spend and the funding tx.
364-
if ht.IsNeutrinoBackend() {
365-
ht.MineBlocksAndAssertNumTxes(6, 1)
366-
} else {
367-
ht.MineBlocksAndAssertNumTxes(6, 2)
368-
}
382+
ht.MineBlocksAndAssertNumTxes(6, 2)
369383

370384
chanPoint := ht.WaitForChannelOpenEvent(chanOpenUpdate)
371385

0 commit comments

Comments
 (0)