mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1563] Add TestMaxHeaders (#1144)
This commit is contained in:
parent
96d9e5800f
commit
2096a28d1c
@ -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]
|
||||
}
|
||||
|
15
app/protocol/flows/ibd/handle_request_headers_test.go
Normal file
15
app/protocol/flows/ibd/handle_request_headers_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user