itest: use wait predicate for balance assertion in assertDLPExecuted

This assertion would at times fail if the wallet balance hadn't been
updated yet.
This commit is contained in:
Wilmer Paulino committed 2021-04-29 13:56:20 -07:00
1 parent 6bb7b00a80
commit f26cfac440
1 file changed
+11 -3
+11 -3
View File
@@ -9705,18 +9705,26 @@ func assertDLPExecuted(net *lntest.NetworkHarness, t *harnessTest,
assertNumPendingChannels(t, carol, 0, 0) assertNumPendingChannels(t, carol, 0, 0)
// Make sure Carol got her balance back. // Make sure Carol got her balance back.
err = wait.NoError(func() error {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
carolBalResp, err := carol.WalletBalance(ctxt, balReq) carolBalResp, err := carol.WalletBalance(ctxt, balReq)
if err != nil { if err != nil {
t.Fatalf("unable to get carol's balance: %v", err) return fmt.Errorf("unable to get carol's balance: %v", err)
} }
carolBalance := carolBalResp.ConfirmedBalance carolBalance := carolBalResp.ConfirmedBalance
if carolBalance <= carolStartingBalance { if carolBalance <= carolStartingBalance {
t.Fatalf("expected carol to have balance above %d, "+ return fmt.Errorf("expected carol to have balance "+
"instead had %v", carolStartingBalance, "above %d, instead had %v", carolStartingBalance,
carolBalance) carolBalance)
} }
return nil
}, defaultTimeout)
if err != nil {
t.Fatalf(err.Error())
}
assertNodeNumChannels(t, dave, 0) assertNodeNumChannels(t, dave, 0)
assertNodeNumChannels(t, carol, 0) assertNodeNumChannels(t, carol, 0)
} }