Skip to content

Commit

Permalink
itest: fix testUnconfirmedChannelFunding for neutrino
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yyforyongyu committed Jul 23, 2024
1 parent 2d21aa3 commit 9180762
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions itest/lnd_funding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9180762

Please sign in to comment.