From 335a039ba2050b3bd332829903cb47ec395dca19 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 24 May 2019 14:17:48 +0200 Subject: [PATCH] lnd_test: alter testUnconfirmedChannelFunding to work with Neutrino We slightly alter testUnconfirmedChannelFunding to instead of using an external deposit to test unconfirmed channel funding, we use one of our own unconfirmed change outputs. This is done since Neutrino currently has now way of knowing about incoming unconfirmed outputs. --- lnd_test.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index fa80bc83..a1aa4ae2 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -972,8 +972,8 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) { closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false) } -// testUnconfirmedChannelFunding tests that unconfirmed outputs that pay to us -// can be used to fund channels. +// testUnconfirmedChannelFunding tests that our unconfirmed change outputs can +// be used to fund channels. func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) { ctxb := context.Background() @@ -989,13 +989,34 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) { } defer shutdownAndAssert(net, t, carol) - // We'll send her some funds that should not confirm. + // We'll send her some confirmed funds. ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) - err = net.SendCoinsUnconfirmed(ctxt, 2*chanAmt, carol) + err = net.SendCoins(ctxt, 2*chanAmt, carol) if err != nil { t.Fatalf("unable to send coins to carol: %v", err) } + // Now let Carol send some funds to herself, making a unconfirmed + // change output. + addrReq := &lnrpc.NewAddressRequest{ + Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH, + } + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + resp, err := carol.NewAddress(ctxt, addrReq) + if err != nil { + t.Fatalf("unable to get new address: %v", err) + } + + sendReq := &lnrpc.SendCoinsRequest{ + Addr: resp.Address, + Amount: int64(chanAmt) / 5, + } + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + _, err = carol.SendCoins(ctxt, sendReq) + if err != nil { + t.Fatalf("unable to send coins: %v", err) + } + // Make sure the unconfirmed tx is seen in the mempool. _, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout) if err != nil {