From 52dff48477f09f73291e87bc5178aba35d0ff736 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sat, 4 Feb 2023 02:57:34 +0800 Subject: [PATCH] itest: fix flake in `testOptionScidUpgrade` --- itest/lnd_zero_conf_test.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/itest/lnd_zero_conf_test.go b/itest/lnd_zero_conf_test.go index d5f0e87aa..ae3ca0ec7 100644 --- a/itest/lnd_zero_conf_test.go +++ b/itest/lnd_zero_conf_test.go @@ -1,6 +1,7 @@ package itest import ( + "fmt" "testing" "time" @@ -821,25 +822,34 @@ func testOptionScidUpgrade(ht *lntest.HarnessTest) { var startingAlias lnwire.ShortChannelID startingAlias.BlockHeight = 16_000_000 - err := wait.Predicate(func() bool { + // TODO(yy): Carol and Dave will attempt to connect to each other + // during restart. However, due to the race condition in peer + // connection, they may both fail. Thus we need to ensure the + // connection here. Once the race is fixed, we can remove this line. + ht.EnsureConnected(dave, carol) + + err := wait.NoError(func() error { invoiceResp := dave.RPC.AddInvoice(daveParams) decodedReq := dave.RPC.DecodePayReq(invoiceResp.PaymentRequest) if len(decodedReq.RouteHints) != 1 { - return false + return fmt.Errorf("expected 1 route hint, got %v", + decodedReq.RouteHints) } if len(decodedReq.RouteHints[0].HopHints) != 1 { - return false + return fmt.Errorf("expected 1 hop hint, got %v", + len(decodedReq.RouteHints[0].HopHints)) } hopHint := decodedReq.RouteHints[0].HopHints[0].ChanId if startingAlias.ToUint64() == hopHint { daveInvoice = invoiceResp - return true + return nil } - return false + return fmt.Errorf("unmatched alias, expected %v, got %v", + startingAlias.ToUint64(), hopHint) }, defaultTimeout) require.NoError(ht, err)