lnd test: check inactive channel disables in testSendUpdateDisableChannel
This commit is contained in:
parent
52941cec53
commit
7b1ac0a979
71
lnd_test.go
71
lnd_test.go
@ -10902,6 +10902,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to create carol's node: %v", err)
|
t.Fatalf("unable to create carol's node: %v", err)
|
||||||
}
|
}
|
||||||
defer shutdownAndAssert(net, t, carol)
|
defer shutdownAndAssert(net, t, carol)
|
||||||
|
|
||||||
if err := net.ConnectNodes(ctxb, net.Alice, carol); err != nil {
|
if err := net.ConnectNodes(ctxb, net.Alice, carol); err != nil {
|
||||||
t.Fatalf("unable to connect alice to carol: %v", err)
|
t.Fatalf("unable to connect alice to carol: %v", err)
|
||||||
}
|
}
|
||||||
@ -10910,6 +10911,34 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
ctxt, t, net, net.Alice, carol, chanAmt, 0, false,
|
ctxt, t, net, net.Alice, carol, chanAmt, 0, false,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// We create a new node Eve that has an inactive channel timeout of
|
||||||
|
// just 2 seconds (down from the default 20m). It will be used to test
|
||||||
|
// channel updates for channels going inactive.
|
||||||
|
eve, err := net.NewNode("Eve", []string{"--inactivechantimeout=2s"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create eve's node: %v", err)
|
||||||
|
}
|
||||||
|
defer shutdownAndAssert(net, t, eve)
|
||||||
|
|
||||||
|
// Give Eve some coins.
|
||||||
|
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, eve)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to send coins to eve: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect Eve to Carol and Bob, and open a channel to carol.
|
||||||
|
if err := net.ConnectNodes(ctxb, eve, carol); err != nil {
|
||||||
|
t.Fatalf("unable to connect alice to carol: %v", err)
|
||||||
|
}
|
||||||
|
if err := net.ConnectNodes(ctxb, eve, net.Bob); err != nil {
|
||||||
|
t.Fatalf("unable to connect eve to bob: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
|
chanPointEveCarol := openChannelAndAssert(
|
||||||
|
ctxt, t, net, eve, carol, chanAmt, 0, false,
|
||||||
|
)
|
||||||
|
|
||||||
// Launch a node for Dave which will connect to Bob in order to receive
|
// Launch a node for Dave which will connect to Bob in order to receive
|
||||||
// graph updates from. This will ensure that the channel updates are
|
// graph updates from. This will ensure that the channel updates are
|
||||||
// propagated throughout the network.
|
// propagated throughout the network.
|
||||||
@ -10934,6 +10963,29 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
Disabled: true,
|
Disabled: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let Carol go offline. Since Eve has an inactive timeout of 2s, we
|
||||||
|
// expect her to send an update disabling the channel.
|
||||||
|
restartCarol, err := net.SuspendNode(carol)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to suspend carol: %v", err)
|
||||||
|
}
|
||||||
|
waitForChannelUpdate(
|
||||||
|
t, daveUpdates, eve.PubKeyStr, expectedPolicy,
|
||||||
|
chanPointEveCarol,
|
||||||
|
)
|
||||||
|
|
||||||
|
// We restart Carol. Since the channel now becomes active again, Eve
|
||||||
|
// should send a ChannelUpdate setting the channel no longer disabled.
|
||||||
|
if err := restartCarol(); err != nil {
|
||||||
|
t.Fatalf("unable to restart carol: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedPolicy.Disabled = false
|
||||||
|
waitForChannelUpdate(
|
||||||
|
t, daveUpdates, eve.PubKeyStr, expectedPolicy,
|
||||||
|
chanPointEveCarol,
|
||||||
|
)
|
||||||
|
|
||||||
// Close Alice's channels with Bob and Carol cooperatively and
|
// Close Alice's channels with Bob and Carol cooperatively and
|
||||||
// unilaterally respectively.
|
// unilaterally respectively.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
@ -10950,6 +11002,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Now that the channel close processes have been started, we should
|
// Now that the channel close processes have been started, we should
|
||||||
// receive an update marking each as disabled.
|
// receive an update marking each as disabled.
|
||||||
|
expectedPolicy.Disabled = true
|
||||||
waitForChannelUpdate(
|
waitForChannelUpdate(
|
||||||
t, daveUpdates, net.Alice.PubKeyStr, expectedPolicy,
|
t, daveUpdates, net.Alice.PubKeyStr, expectedPolicy,
|
||||||
chanPointAliceBob, chanPointAliceCarol,
|
chanPointAliceBob, chanPointAliceCarol,
|
||||||
@ -10961,6 +11014,24 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("expected transactions not found in mempool: %v", err)
|
t.Fatalf("expected transactions not found in mempool: %v", err)
|
||||||
}
|
}
|
||||||
mineBlocks(t, net, 1)
|
mineBlocks(t, net, 1)
|
||||||
|
|
||||||
|
// Also do this check for Eve's channel with Carol.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||||
|
_, _, err = net.CloseChannel(ctxt, eve, chanPointEveCarol, false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to close channel: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
waitForChannelUpdate(
|
||||||
|
t, daveUpdates, eve.PubKeyStr, expectedPolicy,
|
||||||
|
chanPointEveCarol,
|
||||||
|
)
|
||||||
|
|
||||||
|
_, err = waitForNTxsInMempool(net.Miner.Node, 1, timeout)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("expected transactions not found in mempool: %v", err)
|
||||||
|
}
|
||||||
|
mineBlocks(t, net, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user