mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-05 02:11:10 +01:00
htlcswitch+routing: rename GetPaymentResult to GetAttemptResult
This commit renames the method `GetPaymentResult` to be `GetAttemptResult` to avoid potential confusion and to address the one-to-many relationship between a payment and its attempts.
This commit is contained in:
@@ -3441,9 +3441,9 @@ func TestSendMPPaymentSucceed(t *testing.T) {
|
||||
payment.HTLCs = append(payment.HTLCs, activeAttempt)
|
||||
})
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 10)
|
||||
payer.On("GetPaymentResult",
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, identifier, mock.Anything,
|
||||
).Run(func(args mock.Arguments) {
|
||||
// Before the mock method is returned, we send the result to
|
||||
@@ -3608,14 +3608,14 @@ func TestSendMPPaymentSucceedOnExtraShards(t *testing.T) {
|
||||
payment.HTLCs = append(payment.HTLCs, activeAttempt)
|
||||
})
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 10)
|
||||
|
||||
// We use the failAttemptCount to track how many attempts we want to
|
||||
// fail. Each time the following mock method is called, the count gets
|
||||
// updated.
|
||||
failAttemptCount := 0
|
||||
payer.On("GetPaymentResult",
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, identifier, mock.Anything,
|
||||
).Run(func(args mock.Arguments) {
|
||||
// Before the mock method is returned, we send the result to
|
||||
@@ -3820,14 +3820,14 @@ func TestSendMPPaymentFailed(t *testing.T) {
|
||||
payment.HTLCs = append(payment.HTLCs, activeAttempt)
|
||||
})
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 10)
|
||||
|
||||
// We use the failAttemptCount to track how many attempts we want to
|
||||
// fail. Each time the following mock method is called, the count gets
|
||||
// updated.
|
||||
failAttemptCount := 0
|
||||
payer.On("GetPaymentResult",
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, identifier, mock.Anything,
|
||||
).Run(func(args mock.Arguments) {
|
||||
// Before the mock method is returned, we send the result to
|
||||
@@ -4024,18 +4024,18 @@ func TestSendMPPaymentFailedWithShardsInFlight(t *testing.T) {
|
||||
payment.HTLCs = append(payment.HTLCs, activeAttempt)
|
||||
})
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 10)
|
||||
|
||||
// We use the getPaymentResultCnt to track how many times we called
|
||||
// GetPaymentResult. As shard launch is sequential, and we fail the
|
||||
// first shard that calls GetPaymentResult, we may end up with different
|
||||
// GetAttemptResult. As shard launch is sequential, and we fail the
|
||||
// first shard that calls GetAttemptResult, we may end up with different
|
||||
// counts since the lifecycle itself is asynchronous. To avoid flakes
|
||||
// due to this undeterminsitic behavior, we'll compare the final
|
||||
// getPaymentResultCnt with other counters to create a final test
|
||||
// expectation.
|
||||
getPaymentResultCnt := 0
|
||||
payer.On("GetPaymentResult",
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, identifier, mock.Anything,
|
||||
).Run(func(args mock.Arguments) {
|
||||
// Before the mock method is returned, we send the result to
|
||||
@@ -4254,9 +4254,9 @@ func TestSendToRouteSkipTempErrSuccess(t *testing.T) {
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Return(nil)
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 1)
|
||||
payer.On("GetPaymentResult",
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Run(func(_ mock.Arguments) {
|
||||
// Send a successful payment result.
|
||||
@@ -4329,7 +4329,7 @@ func TestSendToRouteSkipTempErrTempFailure(t *testing.T) {
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Return(nil)
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 1)
|
||||
|
||||
// Create the error to be returned.
|
||||
@@ -4338,8 +4338,8 @@ func TestSendToRouteSkipTempErrTempFailure(t *testing.T) {
|
||||
1,
|
||||
)
|
||||
|
||||
// Mock GetPaymentResult to return a failure.
|
||||
payer.On("GetPaymentResult",
|
||||
// Mock GetAttemptResult to return a failure.
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Run(func(_ mock.Arguments) {
|
||||
// Send an attempt failure.
|
||||
@@ -4418,7 +4418,7 @@ func TestSendToRouteSkipTempErrPermanentFailure(t *testing.T) {
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Return(nil)
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 1)
|
||||
|
||||
// Create the error to be returned.
|
||||
@@ -4426,8 +4426,8 @@ func TestSendToRouteSkipTempErrPermanentFailure(t *testing.T) {
|
||||
&lnwire.FailIncorrectDetails{}, 1,
|
||||
)
|
||||
|
||||
// Mock GetPaymentResult to return a failure.
|
||||
payer.On("GetPaymentResult",
|
||||
// Mock GetAttemptResult to return a failure.
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Run(func(_ mock.Arguments) {
|
||||
// Send a permanent failure.
|
||||
@@ -4507,7 +4507,7 @@ func TestSendToRouteTempFailure(t *testing.T) {
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Return(nil)
|
||||
|
||||
// Create a buffered chan and it will be returned by GetPaymentResult.
|
||||
// Create a buffered chan and it will be returned by GetAttemptResult.
|
||||
payer.resultChan = make(chan *htlcswitch.PaymentResult, 1)
|
||||
|
||||
// Create the error to be returned.
|
||||
@@ -4516,8 +4516,8 @@ func TestSendToRouteTempFailure(t *testing.T) {
|
||||
1,
|
||||
)
|
||||
|
||||
// Mock GetPaymentResult to return a failure.
|
||||
payer.On("GetPaymentResult",
|
||||
// Mock GetAttemptResult to return a failure.
|
||||
payer.On("GetAttemptResult",
|
||||
mock.Anything, mock.Anything, mock.Anything,
|
||||
).Run(func(_ mock.Arguments) {
|
||||
// Send an attempt failure.
|
||||
|
||||
Reference in New Issue
Block a user