mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 14:44:22 +01:00
discovery: limit NumBlocks to best known height for outgoing QueryChannelRange
This is done to ensure we don't receive replies for channels in blocks not currently known to us, which we wouldn't be able to process.
This commit is contained in:
@@ -2,7 +2,6 @@ package discovery
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
@@ -34,6 +33,9 @@ func newTestSyncManager(numActiveSyncers int) *SyncManager {
|
||||
RotateTicker: ticker.NewForce(DefaultSyncerRotationInterval),
|
||||
HistoricalSyncTicker: ticker.NewForce(DefaultHistoricalSyncInterval),
|
||||
NumActiveSyncers: numActiveSyncers,
|
||||
BestHeight: func() uint32 {
|
||||
return latestKnownHeight
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -202,7 +204,7 @@ func TestSyncManagerInitialHistoricalSync(t *testing.T) {
|
||||
syncMgr.InitSyncState(peer)
|
||||
assertMsgSent(t, peer, &lnwire.QueryChannelRange{
|
||||
FirstBlockHeight: 0,
|
||||
NumBlocks: math.MaxUint32,
|
||||
NumBlocks: latestKnownHeight,
|
||||
})
|
||||
|
||||
// The graph should not be considered as synced since the initial
|
||||
@@ -290,7 +292,7 @@ func TestSyncManagerForceHistoricalSync(t *testing.T) {
|
||||
syncMgr.InitSyncState(peer)
|
||||
assertMsgSent(t, peer, &lnwire.QueryChannelRange{
|
||||
FirstBlockHeight: 0,
|
||||
NumBlocks: math.MaxUint32,
|
||||
NumBlocks: latestKnownHeight,
|
||||
})
|
||||
|
||||
// If an additional peer connects, then a historical sync should not be
|
||||
@@ -305,7 +307,7 @@ func TestSyncManagerForceHistoricalSync(t *testing.T) {
|
||||
syncMgr.cfg.HistoricalSyncTicker.(*ticker.Force).Force <- time.Time{}
|
||||
assertMsgSent(t, extraPeer, &lnwire.QueryChannelRange{
|
||||
FirstBlockHeight: 0,
|
||||
NumBlocks: math.MaxUint32,
|
||||
NumBlocks: latestKnownHeight,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -326,7 +328,7 @@ func TestSyncManagerGraphSyncedAfterHistoricalSyncReplacement(t *testing.T) {
|
||||
syncMgr.InitSyncState(peer)
|
||||
assertMsgSent(t, peer, &lnwire.QueryChannelRange{
|
||||
FirstBlockHeight: 0,
|
||||
NumBlocks: math.MaxUint32,
|
||||
NumBlocks: latestKnownHeight,
|
||||
})
|
||||
|
||||
// The graph should not be considered as synced since the initial
|
||||
@@ -531,7 +533,7 @@ func assertTransitionToChansSynced(t *testing.T, s *GossipSyncer, peer *mockPeer
|
||||
|
||||
query := &lnwire.QueryChannelRange{
|
||||
FirstBlockHeight: 0,
|
||||
NumBlocks: math.MaxUint32,
|
||||
NumBlocks: latestKnownHeight,
|
||||
}
|
||||
assertMsgSent(t, peer, query)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user