Merge pull request #5573 from yyforyongyu/5530-payment-test-race
routing: fix race in TestSendMPPaymentFailed
This commit is contained in:
3 files changed
+12
-8
No files matched your search
@@ -60,6 +60,7 @@ you.
|
|||||||
alert](https://github.com/lightningnetwork/lnd/pull/5576).
|
alert](https://github.com/lightningnetwork/lnd/pull/5576).
|
||||||
* [Fixed timeout flakes in async payment benchmark tests](https://github.com/lightningnetwork/lnd/pull/5579).
|
* [Fixed timeout flakes in async payment benchmark tests](https://github.com/lightningnetwork/lnd/pull/5579).
|
||||||
* [Fixed a missing import and git tag in the healthcheck package](https://github.com/lightningnetwork/lnd/pull/5582).
|
* [Fixed a missing import and git tag in the healthcheck package](https://github.com/lightningnetwork/lnd/pull/5582).
|
||||||
|
* [Fixed a data race in payment unit test](https://github.com/lightningnetwork/lnd/pull/5573).
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
@@ -80,3 +81,4 @@ to make LNDs payment throughput (and latency) with better when using etcd.
|
|||||||
* Martin Habovstiak
|
* Martin Habovstiak
|
||||||
* Zero-1729
|
* Zero-1729
|
||||||
* Oliver Gugger
|
* Oliver Gugger
|
||||||
|
* Yong Yu
|
||||||
@@ -591,8 +591,6 @@ func (m *mockPaymentSessionSource) NewPaymentSessionEmpty() PaymentSession {
|
|||||||
|
|
||||||
type mockMissionControl struct {
|
type mockMissionControl struct {
|
||||||
mock.Mock
|
mock.Mock
|
||||||
|
|
||||||
failReason *channeldb.FailureReason
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ MissionController = (*mockMissionControl)(nil)
|
var _ MissionController = (*mockMissionControl)(nil)
|
||||||
@@ -603,7 +601,13 @@ func (m *mockMissionControl) ReportPaymentFail(
|
|||||||
*channeldb.FailureReason, error) {
|
*channeldb.FailureReason, error) {
|
||||||
|
|
||||||
args := m.Called(paymentID, rt, failureSourceIdx, failure)
|
args := m.Called(paymentID, rt, failureSourceIdx, failure)
|
||||||
return m.failReason, args.Error(1)
|
|
||||||
|
// Type assertion on nil will fail, so we check and return here.
|
||||||
|
if args.Get(0) == nil {
|
||||||
|
return nil, args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return args.Get(0).(*channeldb.FailureReason), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockMissionControl) ReportPaymentSuccess(paymentID uint64,
|
func (m *mockMissionControl) ReportPaymentSuccess(paymentID uint64,
|
||||||
|
|||||||
@@ -4023,17 +4023,16 @@ func TestSendMPPaymentFailed(t *testing.T) {
|
|||||||
failureReason := channeldb.FailureReasonPaymentDetails
|
failureReason := channeldb.FailureReasonPaymentDetails
|
||||||
missionControl.On("ReportPaymentFail",
|
missionControl.On("ReportPaymentFail",
|
||||||
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
|
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
|
||||||
).Return(nil, nil).Run(func(args mock.Arguments) {
|
).Return(&failureReason, nil).Run(func(args mock.Arguments) {
|
||||||
// We only return the terminal error once, thus when the method
|
// We only return the terminal error once, thus when the method
|
||||||
// is called, we will return it with a nil error.
|
// is called, we will return it with a nil error.
|
||||||
if called {
|
if called {
|
||||||
missionControl.failReason = nil
|
args[0] = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's the first time calling this method, we will return a
|
// If it's the first time calling this method, we will return a
|
||||||
// terminal error.
|
// terminal error.
|
||||||
missionControl.failReason = &failureReason
|
|
||||||
payment.FailureReason = &failureReason
|
payment.FailureReason = &failureReason
|
||||||
called = true
|
called = true
|
||||||
})
|
})
|
||||||
@@ -4213,8 +4212,7 @@ func TestSendMPPaymentFailedWithShardsInFlight(t *testing.T) {
|
|||||||
failureReason := channeldb.FailureReasonPaymentDetails
|
failureReason := channeldb.FailureReasonPaymentDetails
|
||||||
missionControl.On("ReportPaymentFail",
|
missionControl.On("ReportPaymentFail",
|
||||||
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
|
mock.Anything, mock.Anything, mock.Anything, mock.Anything,
|
||||||
).Return(failureReason, nil).Run(func(args mock.Arguments) {
|
).Return(&failureReason, nil).Run(func(args mock.Arguments) {
|
||||||
missionControl.failReason = &failureReason
|
|
||||||
payment.FailureReason = &failureReason
|
payment.FailureReason = &failureReason
|
||||||
}).Once()
|
}).Once()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user