test: fix flake in testInvoiceRoutingHints by using WaitPredicate

This commit is contained in:
Olaoluwa Osuntokun 2018-05-03 21:07:06 -07:00
parent 8712ab110d
commit d50247304b
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -3448,9 +3448,17 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
// Due to the way the channels were set up above, the channel between // Due to the way the channels were set up above, the channel between
// Alice and Bob should be the only channel used as a routing hint. // Alice and Bob should be the only channel used as a routing hint.
var predErr error
err = lntest.WaitPredicate(func() bool {
if len(decoded.RouteHints) != 1 { if len(decoded.RouteHints) != 1 {
t.Fatalf("expected one route hint, got %d", predErr = fmt.Errorf("expected one route hint, got %d",
len(decoded.RouteHints)) len(decoded.RouteHints))
return false
}
return true
}, time.Second*15)
if err != nil {
t.Fatalf(predErr.Error())
} }
hops := decoded.RouteHints[0].HopHints hops := decoded.RouteHints[0].HopHints