itest: use require.Eventually where tick speed matters

To not waste a lot of time with the adjusted longer tick interval, we
use a short interval with require.Eventually where we can save some
time.
This commit is contained in:
Oliver Gugger 2020-12-08 18:54:18 +01:00
parent a436618e43
commit 9de659ea4f
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -7948,18 +7948,12 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to restart carol's node: %v", err)
}
err = wait.Predicate(func() bool {
require.Eventually(t.t, func() bool {
return isConnected(net.Bob.PubKeyStr)
}, defaultTimeout)
if err != nil {
t.Fatalf("alice did not reconnect to bob")
}
err = wait.Predicate(func() bool {
}, defaultTimeout, 20*time.Millisecond)
require.Eventually(t.t, func() bool {
return isConnected(carol.PubKeyStr)
}, defaultTimeout)
if err != nil {
t.Fatalf("alice did not reconnect to carol")
}
}, defaultTimeout, 20*time.Millisecond)
// We'll also restart Alice to ensure she can reconnect to her peers
// with open channels.
@ -7967,24 +7961,18 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to restart alice's node: %v", err)
}
err = wait.Predicate(func() bool {
require.Eventually(t.t, func() bool {
return isConnected(net.Bob.PubKeyStr)
}, defaultTimeout)
if err != nil {
t.Fatalf("alice did not reconnect to bob")
}
err = wait.Predicate(func() bool {
}, defaultTimeout, 20*time.Millisecond)
require.Eventually(t.t, func() bool {
return isConnected(carol.PubKeyStr)
}, defaultTimeout)
if err != nil {
t.Fatalf("alice did not reconnect to carol")
}
}, defaultTimeout, 20*time.Millisecond)
require.Eventually(t.t, func() bool {
return isConnected(dave.PubKeyStr)
}, defaultTimeout, 20*time.Millisecond)
err = wait.Predicate(func() bool {
return isConnected(dave.PubKeyStr)
}, defaultTimeout)
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.