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.
This commit is contained in:
Johan T. Halseth 2019-05-24 14:17:48 +02:00
parent 3df0821aa3
commit 335a039ba2
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -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 {