[NOD-1563] Add TestMaxHeaders (#1144)

This commit is contained in:
Ori Newman 2020-11-23 08:33:45 -08:00 committed by GitHub
parent 96d9e5800f
commit 2096a28d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
)
const ibdBatchSize = router.DefaultMaxMessages
const maxHeaders = appmessage.MaxInvPerMsg
// RequestIBDBlocksContext is the interface for the context needed for the HandleRequestHeaders flow.
type RequestIBDBlocksContext interface {
@ -97,7 +98,7 @@ func (flow *handleRequestBlocksFlow) buildMsgBlockHeaders(lowHash *externalapi.D
if err != nil {
return nil, err
}
const maxHeaders = appmessage.MaxInvPerMsg
if len(blockHashes) > maxHeaders {
blockHashes = blockHashes[:maxHeaders]
}

View File

@ -0,0 +1,15 @@
package ibd
import (
"github.com/kaspanet/kaspad/domain/consensus/utils/testutils"
"github.com/kaspanet/kaspad/domain/dagconfig"
"testing"
)
func TestMaxHeaders(t *testing.T) {
testutils.ForAllNets(t, false, func(t *testing.T, params *dagconfig.Params) {
if params.FinalityDepth() > maxHeaders {
t.Errorf("FinalityDepth() in %s should be lower or equal to appmessage.MaxInvPerMsg", params.Name)
}
})
}