From 0f400b2b161c159980a0e8bf79193c16b458cc61 Mon Sep 17 00:00:00 2001 From: Andras Banki-Horvath Date: Fri, 6 Aug 2021 14:12:11 +0200 Subject: [PATCH] itests: payments test flake fix --- lntest/itest/lnd_payment_test.go | 44 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/lntest/itest/lnd_payment_test.go b/lntest/itest/lnd_payment_test.go index 0e0f81e32..2ea2aff71 100644 --- a/lntest/itest/lnd_payment_test.go +++ b/lntest/itest/lnd_payment_test.go @@ -581,24 +581,34 @@ func testBidirectionalAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) // Next query for Bob's and Alice's channel states, in order to confirm // that all payment have been successful transmitted. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - bobInfo, err := getChanInfo(ctxt, net.Bob) - if err != nil { - t.Fatalf("unable to get bob's channel info: %v", err) - } + err = wait.NoError(func() error { + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + bobInfo, err := getChanInfo(ctxt, net.Bob) + if err != nil { + t.Fatalf("unable to get bob's channel info: %v", err) + } - if bobInfo.LocalBalance != bobAmt { - t.Fatalf("bob's local balance is incorrect, got %v, expected"+ - " %v", bobInfo.LocalBalance, bobAmt) - } - if bobInfo.RemoteBalance != aliceAmt { - t.Fatalf("bob's remote balance is incorrect, got %v, "+ - "expected %v", bobInfo.RemoteBalance, aliceAmt) - } - if len(bobInfo.PendingHtlcs) != 0 { - t.Fatalf("bob's pending htlcs is incorrect, got %v, "+ - "expected %v", len(bobInfo.PendingHtlcs), 0) - } + if bobInfo.LocalBalance != bobAmt { + return fmt.Errorf("bob's local balance is incorrect, "+ + "got %v, expected %v", bobInfo.LocalBalance, + bobAmt) + } + + if bobInfo.RemoteBalance != aliceAmt { + return fmt.Errorf("bob's remote balance is incorrect, "+ + "got %v, expected %v", bobInfo.RemoteBalance, + aliceAmt) + } + + if len(bobInfo.PendingHtlcs) != 0 { + return fmt.Errorf("bob's pending htlcs is incorrect, "+ + "got %v, expected %v", + len(bobInfo.PendingHtlcs), 0) + } + + return nil + }, defaultTimeout) + require.NoError(t.t, err) // Finally, immediately close the channel. This function will also // block until the channel is closed and will additionally assert the