itest: fix send payment flake

In some cases the router isn't yet fully aware of all newly opened
channels. We need to give it some time to process the updates. Therefore
we add a wait for sending payments to give it a few more changes to
catch up.
This commit is contained in:
Oliver Gugger 2020-10-26 14:21:07 +01:00
parent e6b0141b10
commit 1714394add
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -13984,19 +13984,26 @@ func sendAndAssertSuccess(t *harnessTest, node *lntest.HarnessNode,
ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel()
stream, err := node.RouterClient.SendPaymentV2(ctx, req)
if err != nil {
t.Fatalf("unable to send payment: %v", err)
}
var result *lnrpc.Payment
err := wait.NoError(func() error {
stream, err := node.RouterClient.SendPaymentV2(ctx, req)
if err != nil {
return fmt.Errorf("unable to send payment: %v", err)
}
result, err := getPaymentResult(stream)
if err != nil {
t.Fatalf("unable to get payment result: %v", err)
}
result, err = getPaymentResult(stream)
if err != nil {
return fmt.Errorf("unable to get payment result: %v",
err)
}
if result.Status != lnrpc.Payment_SUCCEEDED {
t.Fatalf("payment failed: %v", result.Status)
}
if result.Status != lnrpc.Payment_SUCCEEDED {
return fmt.Errorf("payment failed: %v", result.Status)
}
return nil
}, defaultTimeout)
require.NoError(t.t, err)
return result
}