core: restrict the muximum number of contents per block
This commit is contained in:
parent
c79d440c21
commit
e1e586f18b
6 changed files with 140 additions and 3 deletions
|
@ -3,7 +3,9 @@ package consensus
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/random"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -30,3 +32,32 @@ func TestPrepareRequest_Setters(t *testing.T) {
|
|||
p.SetTransactionHashes(hashes[:])
|
||||
require.Equal(t, hashes[:], p.TransactionHashes())
|
||||
}
|
||||
|
||||
func TestPrepareRequest_EncodeDecodeBinary(t *testing.T) {
|
||||
t.Run("positive", func(t *testing.T) {
|
||||
expected := &prepareRequest{
|
||||
timestamp: 112,
|
||||
nonce: 1325,
|
||||
transactionHashes: []util.Uint256{
|
||||
random.Uint256(),
|
||||
random.Uint256(),
|
||||
},
|
||||
}
|
||||
testserdes.EncodeDecodeBinary(t, expected, new(prepareRequest))
|
||||
})
|
||||
|
||||
t.Run("bad hashes count", func(t *testing.T) {
|
||||
hashes := make([]util.Uint256, block.MaxTransactionsPerBlock+1)
|
||||
for i := range hashes {
|
||||
hashes[i] = random.Uint256()
|
||||
}
|
||||
expected := &prepareRequest{
|
||||
timestamp: 112,
|
||||
nonce: 1325,
|
||||
transactionHashes: hashes,
|
||||
}
|
||||
data, err := testserdes.EncodeBinary(expected)
|
||||
require.NoError(t, err)
|
||||
require.Error(t, testserdes.DecodeBinary(data, new(prepareRequest)))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue