routing+lnd: prepare closed channel SCIDs in server

The method `FetchClosedChannels` sometimes prematurely mark a pending
force closing channel as finalized, therefore we need to furthur check
`FetchPendingChannels` to make sure the channel is indeed finalized.
This commit is contained in:
yyforyongyu authored and yyforyongyu committed 2024-08-07 22:19:23 +08:00
1 parent e8f292edf4
commit 188aa9a4d4
3 files changed
+83 -53

No files matched your search

+10 -12
View File
@@ -93,9 +93,7 @@ func (c *testCtx) getChannelIDFromAlias(t *testing.T, a, b string) uint64 {
return channelID
}
func mockFetchClosedChannels(_ bool) ([]*channeldb.ChannelCloseSummary, error) {
return nil, nil
}
var mockClosedSCIDs map[lnwire.ShortChannelID]struct{}
func createTestCtxFromGraphInstance(t *testing.T, startingHeight uint32,
graphInstance *testGraphInstance) *testCtx {
@@ -162,10 +160,10 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
next := atomic.AddUint64(&uniquePaymentID, 1)
return next, nil
},
PathFindingConfig: pathFindingConfig,
Clock: clock.NewTestClock(time.Unix(1, 0)),
ApplyChannelUpdate: graphBuilder.ApplyChannelUpdate,
FetchClosedChannels: mockFetchClosedChannels,
PathFindingConfig: pathFindingConfig,
Clock: clock.NewTestClock(time.Unix(1, 0)),
ApplyChannelUpdate: graphBuilder.ApplyChannelUpdate,
ClosedSCIDs: mockClosedSCIDs,
})
require.NoError(t, router.Start(), "unable to start router")
@@ -2175,7 +2173,7 @@ func TestSendToRouteSkipTempErrSuccess(t *testing.T) {
NextPaymentID: func() (uint64, error) {
return 0, nil
},
FetchClosedChannels: mockFetchClosedChannels,
ClosedSCIDs: mockClosedSCIDs,
}}
// Register mockers with the expected method calls.
@@ -2259,7 +2257,7 @@ func TestSendToRouteSkipTempErrNonMPP(t *testing.T) {
NextPaymentID: func() (uint64, error) {
return 0, nil
},
FetchClosedChannels: mockFetchClosedChannels,
ClosedSCIDs: mockClosedSCIDs,
}}
// Expect an error to be returned.
@@ -2314,7 +2312,7 @@ func TestSendToRouteSkipTempErrTempFailure(t *testing.T) {
NextPaymentID: func() (uint64, error) {
return 0, nil
},
FetchClosedChannels: mockFetchClosedChannels,
ClosedSCIDs: mockClosedSCIDs,
}}
// Create the error to be returned.
@@ -2397,7 +2395,7 @@ func TestSendToRouteSkipTempErrPermanentFailure(t *testing.T) {
NextPaymentID: func() (uint64, error) {
return 0, nil
},
FetchClosedChannels: mockFetchClosedChannels,
ClosedSCIDs: mockClosedSCIDs,
}}
// Create the error to be returned.
@@ -2484,7 +2482,7 @@ func TestSendToRouteTempFailure(t *testing.T) {
NextPaymentID: func() (uint64, error) {
return 0, nil
},
FetchClosedChannels: mockFetchClosedChannels,
ClosedSCIDs: mockClosedSCIDs,
}}
// Create the error to be returned.