Merge pull request #1877 from halseth/garbage-collect-link-nodes

[integration tests] Fix flake in persistent connection pruning test
This commit is contained in:
Olaoluwa Osuntokun 2018-09-11 19:17:21 -07:00 committed by GitHub
commit 2c48ec8dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5663,6 +5663,12 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
if err != nil {
t.Fatalf("alice did not reconnect to carol")
}
err = lntest.WaitPredicate(func() bool {
return isConnected(dave.PubKeyStr)
}, 15*time.Second)
if err != nil {
t.Fatalf("alice did not reconnect to dave")
}
// testReconnection is a helper closure that restarts the nodes at both
// ends of a channel to ensure they do not reconnect after restarting.
@ -5670,13 +5676,24 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
// reestablished her connection with Dave, as they still have an open
// channel together.
testReconnection := func(node *lntest.HarnessNode) {
// Restart both nodes, to trigger the pruning logic.
if err := net.RestartNode(node, nil); err != nil {
t.Fatalf("unable to restart %v's node: %v",
node.Name(), err)
}
if err := net.RestartNode(net.Alice, nil); err != nil {
t.Fatalf("unable to restart alice's node: %v", err)
}
// Now restart both nodes and make sure they don't reconnect.
if err := net.RestartNode(node, nil); err != nil {
t.Fatalf("unable to restart %v's node: %v", node.Name(),
err)
}
err = lntest.WaitPredicate(func() bool {
err = lntest.WaitInvariant(func() bool {
return !isConnected(node.PubKeyStr)
}, 20*time.Second)
}, 5*time.Second)
if err != nil {
t.Fatalf("alice reconnected to %v", node.Name())
}
@ -5685,11 +5702,15 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to restart alice's node: %v", err)
}
err = lntest.WaitPredicate(func() bool {
if !isConnected(dave.PubKeyStr) {
return false
}
return !isConnected(node.PubKeyStr)
return isConnected(dave.PubKeyStr)
}, 20*time.Second)
if err != nil {
t.Fatalf("alice didn't reconnect to Dave")
}
err = lntest.WaitInvariant(func() bool {
return !isConnected(node.PubKeyStr)
}, 5*time.Second)
if err != nil {
t.Fatalf("alice reconnected to %v", node.Name())
}