From d50247304b18488d401e0cdb6768b59b5405eb8e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 3 May 2018 21:07:06 -0700 Subject: [PATCH] test: fix flake in testInvoiceRoutingHints by using WaitPredicate --- lnd_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 07e95f3a..8b8b6a90 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -3448,9 +3448,17 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) { // 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. - if len(decoded.RouteHints) != 1 { - t.Fatalf("expected one route hint, got %d", - len(decoded.RouteHints)) + var predErr error + err = lntest.WaitPredicate(func() bool { + if len(decoded.RouteHints) != 1 { + predErr = fmt.Errorf("expected one route hint, got %d", + len(decoded.RouteHints)) + return false + } + return true + }, time.Second*15) + if err != nil { + t.Fatalf(predErr.Error()) } hops := decoded.RouteHints[0].HopHints