lnd: Context timeouts on SendPayment RPC request in tests.
This helps catch issues in the RPC tests faster by putting a timeout on all SendPayment requests. Otherwise, if a payment stalled, the test would run until the test suite timeout, 10 minutes. Also simplifies some code with a helper function and using SendPaymentSync where possible.
This commit is contained in:
1 parent
7d65ad4302
commit
c501da3a95
2 files changed
+148
-234
No files matched your search
+8
-4
@@ -1726,9 +1726,11 @@ func (r *rpcServer) SendPaymentSync(ctx context.Context,
|
||||
// largest payment size allotted to (2^32) - 1 mSAT or 4.29 million
|
||||
// satoshis.
|
||||
if amtMSat > maxPaymentMSat {
|
||||
return nil, fmt.Errorf("payment of %v is too large, max payment "+
|
||||
"allowed is %v", nextPayment.Amt,
|
||||
maxPaymentMSat.ToSatoshis())
|
||||
err := fmt.Errorf("payment of %v is too large, max payment "+
|
||||
"allowed is %v", nextPayment.Amt, maxPaymentMSat.ToSatoshis())
|
||||
return &lnrpc.SendResponse{
|
||||
PaymentError: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Finally, send a payment request to the channel router. If the
|
||||
@@ -1744,7 +1746,9 @@ func (r *rpcServer) SendPaymentSync(ctx context.Context,
|
||||
}
|
||||
preImage, route, err := r.server.chanRouter.SendPayment(payment)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return &lnrpc.SendResponse{
|
||||
PaymentError: err.Error(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// With the payment completed successfully, we now ave the details of
|
||||
|
||||
Reference in new issue
Block a user