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:
Wilmer Paulino committed 2020-12-08 15:18:06 -08:00
1 parent 592a0c5699
commit c5fc7334a4
5 files changed
+54 -23

No files matched your search

+8 -5
View File
@@ -158,6 +158,9 @@ func newTestSyncer(hID lnwire.ShortChannelID,
return nil
},
delayedQueryReplyInterval: 2 * time.Second,
bestHeight: func() uint32 {
return latestKnownHeight
},
}
syncer := newGossipSyncer(cfg)
@@ -1134,9 +1137,9 @@ func TestGossipSyncerGenChanRangeQuery(t *testing.T) {
rangeQuery.FirstBlockHeight,
startingHeight-chanRangeQueryBuffer)
}
if rangeQuery.NumBlocks != math.MaxUint32-firstHeight {
if rangeQuery.NumBlocks != latestKnownHeight-firstHeight {
t.Fatalf("wrong num blocks: expected %v, got %v",
math.MaxUint32-firstHeight, rangeQuery.NumBlocks)
latestKnownHeight-firstHeight, rangeQuery.NumBlocks)
}
// Generating a historical range query should result in a start height
@@ -1149,9 +1152,9 @@ func TestGossipSyncerGenChanRangeQuery(t *testing.T) {
t.Fatalf("incorrect chan range query: expected %v, %v", 0,
rangeQuery.FirstBlockHeight)
}
if rangeQuery.NumBlocks != math.MaxUint32 {
if rangeQuery.NumBlocks != latestKnownHeight {
t.Fatalf("wrong num blocks: expected %v, got %v",
math.MaxUint32, rangeQuery.NumBlocks)
latestKnownHeight, rangeQuery.NumBlocks)
}
}
@@ -2234,7 +2237,7 @@ func TestGossipSyncerHistoricalSync(t *testing.T) {
// sent to the remote peer with a FirstBlockHeight of 0.
expectedMsg := &lnwire.QueryChannelRange{
FirstBlockHeight: 0,
NumBlocks: math.MaxUint32,
NumBlocks: latestKnownHeight,
}
select {