test: update testChannelFundingPersistence to use --defaultchanconfs
This commit is contained in:
parent
fa3fd9a19a
commit
0f2fcf68b2
43
lnd_test.go
43
lnd_test.go
@ -493,27 +493,39 @@ func testChannelFundingPersistence(net *networkHarness, t *harnessTest) {
|
|||||||
timeout := time.Duration(time.Second * 10)
|
timeout := time.Duration(time.Second * 10)
|
||||||
ctxt, _ := context.WithTimeout(ctxb, timeout)
|
ctxt, _ := context.WithTimeout(ctxb, timeout)
|
||||||
|
|
||||||
|
// As we need to create a channel that requires more than 1
|
||||||
|
// confirmation before it's open, with the current set of defaults,
|
||||||
|
// we'll need to create a new node instance.
|
||||||
|
const numConfs = 5
|
||||||
|
carolArgs := []string{fmt.Sprintf("--defaultchanconfs=%v", numConfs)}
|
||||||
|
carol, err := net.NewNode(carolArgs)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create new node: %v", err)
|
||||||
|
}
|
||||||
|
if err := net.ConnectNodes(ctxt, net.Alice, carol); err != nil {
|
||||||
|
t.Fatalf("unable to connect alice to carol: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new channel that requires 5 confs before it's considered
|
// Create a new channel that requires 5 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
const numConfs = 5
|
pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, carol,
|
||||||
pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, net.Bob,
|
chanAmt, pushAmt)
|
||||||
chanAmt, pushAmt, numConfs)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, the channel's funding transaction will have
|
// At this point, the channel's funding transaction will have been
|
||||||
// been broadcast, but not confirmed. Alice and Bob's nodes
|
// broadcast, but not confirmed. Alice and Bob's nodes should reflect
|
||||||
// should reflect this when queried via RPC.
|
// this when queried via RPC.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
assertNumOpenChannelsPending(ctxt, t, net.Alice, net.Bob, 1)
|
assertNumOpenChannelsPending(ctxt, t, net.Alice, carol, 1)
|
||||||
|
|
||||||
// Restart both nodes to test that the appropriate state has been
|
// Restart both nodes to test that the appropriate state has been
|
||||||
// persisted and that both nodes recover gracefully.
|
// persisted and that both nodes recover gracefully.
|
||||||
if err := net.RestartNode(net.Alice, nil); err != nil {
|
if err := net.RestartNode(net.Alice, nil); err != nil {
|
||||||
t.Fatalf("Node restart failed: %v", err)
|
t.Fatalf("Node restart failed: %v", err)
|
||||||
}
|
}
|
||||||
if err := net.RestartNode(net.Bob, nil); err != nil {
|
if err := net.RestartNode(carol, nil); err != nil {
|
||||||
t.Fatalf("Node restart failed: %v", err)
|
t.Fatalf("Node restart failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +546,7 @@ func testChannelFundingPersistence(net *networkHarness, t *harnessTest) {
|
|||||||
if err := net.RestartNode(net.Alice, nil); err != nil {
|
if err := net.RestartNode(net.Alice, nil); err != nil {
|
||||||
t.Fatalf("Node restart failed: %v", err)
|
t.Fatalf("Node restart failed: %v", err)
|
||||||
}
|
}
|
||||||
if err := net.RestartNode(net.Bob, nil); err != nil {
|
if err := net.RestartNode(carol, nil); err != nil {
|
||||||
t.Fatalf("Node restart failed: %v", err)
|
t.Fatalf("Node restart failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +561,7 @@ peersPoll:
|
|||||||
case <-peersTimeout:
|
case <-peersTimeout:
|
||||||
t.Fatalf("peers unable to reconnect after restart")
|
t.Fatalf("peers unable to reconnect after restart")
|
||||||
case <-checkPeersTick.C:
|
case <-checkPeersTick.C:
|
||||||
peers, err := net.Bob.ListPeers(ctxb,
|
peers, err := carol.ListPeers(ctxb,
|
||||||
&lnrpc.ListPeersRequest{})
|
&lnrpc.ListPeersRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("ListPeers error: %v\n", err)
|
t.Fatalf("ListPeers error: %v\n", err)
|
||||||
@ -569,7 +581,7 @@ peersPoll:
|
|||||||
// Both nodes should still show a single channel as pending.
|
// Both nodes should still show a single channel as pending.
|
||||||
time.Sleep(time.Millisecond * 300)
|
time.Sleep(time.Millisecond * 300)
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
assertNumOpenChannelsPending(ctxt, t, net.Alice, net.Bob, 1)
|
assertNumOpenChannelsPending(ctxt, t, net.Alice, carol, 1)
|
||||||
|
|
||||||
// Finally, mine the last block which should mark the channel as open.
|
// Finally, mine the last block which should mark the channel as open.
|
||||||
if _, err := net.Miner.Node.Generate(1); err != nil {
|
if _, err := net.Miner.Node.Generate(1); err != nil {
|
||||||
@ -580,7 +592,7 @@ peersPoll:
|
|||||||
// be no pending channels remaining for either node.
|
// be no pending channels remaining for either node.
|
||||||
time.Sleep(time.Millisecond * 300)
|
time.Sleep(time.Millisecond * 300)
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
assertNumOpenChannelsPending(ctxt, t, net.Alice, net.Bob, 0)
|
assertNumOpenChannelsPending(ctxt, t, net.Alice, carol, 0)
|
||||||
|
|
||||||
// The channel should be listed in the peer information returned by
|
// The channel should be listed in the peer information returned by
|
||||||
// both peers.
|
// both peers.
|
||||||
@ -595,7 +607,7 @@ peersPoll:
|
|||||||
t.Fatalf("unable to assert channel existence: %v", err)
|
t.Fatalf("unable to assert channel existence: %v", err)
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
if err := net.AssertChannelExists(ctxt, net.Bob, &outPoint); err != nil {
|
if err := net.AssertChannelExists(ctxt, carol, &outPoint); err != nil {
|
||||||
t.Fatalf("unable to assert channel existence: %v", err)
|
t.Fatalf("unable to assert channel existence: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,6 +620,11 @@ peersPoll:
|
|||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
|
||||||
|
|
||||||
|
// Clean up carol's node.
|
||||||
|
if err := carol.Shutdown(); err != nil {
|
||||||
|
t.Fatalf("unable to shutdown carol: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// testChannelBalance creates a new channel between Alice and Bob, then
|
// testChannelBalance creates a new channel between Alice and Bob, then
|
||||||
|
Loading…
Reference in New Issue
Block a user