From f26cfac440f25c3ad971afb4c9d8044f58edd6ef Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 28 Apr 2021 16:20:57 -0700 Subject: [PATCH] itest: use wait predicate for balance assertion in assertDLPExecuted This assertion would at times fail if the wallet balance hadn't been updated yet. --- lntest/itest/lnd_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 5e7dd921..3c2fa586 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -9705,16 +9705,24 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest, assertNumPendingChannels(t, carol, 0, 0) // Make sure Carol got her balance back. - ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) - carolBalResp, err := carol.WalletBalance(ctxt, balReq) + err = wait.NoError(func() error { + ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) + carolBalResp, err := carol.WalletBalance(ctxt, balReq) + if err != nil { + return fmt.Errorf("unable to get carol's balance: %v", err) + } + + carolBalance := carolBalResp.ConfirmedBalance + if carolBalance <= carolStartingBalance { + return fmt.Errorf("expected carol to have balance "+ + "above %d, instead had %v", carolStartingBalance, + carolBalance) + } + + return nil + }, defaultTimeout) if err != nil { - t.Fatalf("unable to get carol's balance: %v", err) - } - carolBalance := carolBalResp.ConfirmedBalance - if carolBalance <= carolStartingBalance { - t.Fatalf("expected carol to have balance above %d, "+ - "instead had %v", carolStartingBalance, - carolBalance) + t.Fatalf(err.Error()) } assertNodeNumChannels(t, dave, 0)