discovery/syncer_test: fix benign off-by-one in DelayDOS test

Prior to this change, the numQueryResponses that we calculated would be
one more than what we actually wanted since it didn't account for the
initial QueryChannelRange msg. This resulted in the test sending one
extra delayed query than was configured. This doesn't fundamentally
impact the test, but does make what happens in the test more reflective
of the configuration.
This commit is contained in:
Conner Fromknecht committed 2019-04-26 20:05:23 -07:00
1 parent bf4543e2bd
commit 5251ebe117
1 file changed
+8 -5
+8 -5
View File
@@ -1070,8 +1070,10 @@ func TestGossipSyncerDelayDOS(t *testing.T) {
numUndelayedQueries := syncer1.cfg.maxUndelayedQueryReplies numUndelayedQueries := syncer1.cfg.maxUndelayedQueryReplies
// We will send enough queries to exhaust the undelayed responses, and // We will send enough queries to exhaust the undelayed responses, and
// then send two more queries which should be delayed. // then send two more queries which should be delayed. An additional one
numQueryResponses := numUndelayedQueries + numDelayedQueries // is subtracted from the total since undelayed message will be consumed
// by the initial QueryChannelRange.
numQueryResponses := numUndelayedQueries + numDelayedQueries - 1
// The total number of responses must include the initial reply each // The total number of responses must include the initial reply each
// syncer will make to QueryChannelRange. // syncer will make to QueryChannelRange.
@@ -1081,10 +1083,11 @@ func TestGossipSyncerDelayDOS(t *testing.T) {
// scaled by the chunk size being used. // scaled by the chunk size being used.
numTotalChans := numQueryResponses * chunkSize numTotalChans := numQueryResponses * chunkSize
// Although both nodes are at the same height, they'll have a // Construct enough channels so that all of the queries will have enough
// completely disjoint set of chan ID's that they know of. // channels. Since syncer1 won't know of any channels, their sets are
// inherently disjoint.
var syncer2Chans []lnwire.ShortChannelID var syncer2Chans []lnwire.ShortChannelID
for i := numTotalChans; i < numTotalChans+numTotalChans; i++ { for i := 0; i < numTotalChans; i++ {
syncer2Chans = append( syncer2Chans = append(
syncer2Chans, lnwire.NewShortChanIDFromInt(uint64(i)), syncer2Chans, lnwire.NewShortChanIDFromInt(uint64(i)),
) )