2020-05-22 12:43:46 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetBlockDataEncodeDecode(t *testing.T) {
|
2020-07-31 10:58:22 +00:00
|
|
|
d := NewGetBlockByIndex(123, 100)
|
|
|
|
testserdes.EncodeDecodeBinary(t, d, new(GetBlockByIndex))
|
2020-05-22 12:43:46 +00:00
|
|
|
|
|
|
|
// invalid block count
|
2020-07-31 10:58:22 +00:00
|
|
|
d = NewGetBlockByIndex(5, 0)
|
2020-05-22 12:43:46 +00:00
|
|
|
data, err := testserdes.EncodeBinary(d)
|
|
|
|
require.NoError(t, err)
|
2020-07-31 10:58:22 +00:00
|
|
|
require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex)))
|
2020-05-22 12:43:46 +00:00
|
|
|
|
|
|
|
// invalid block count
|
2020-07-31 11:03:35 +00:00
|
|
|
d = NewGetBlockByIndex(5, MaxHeadersAllowed+1)
|
2020-05-22 12:43:46 +00:00
|
|
|
data, err = testserdes.EncodeBinary(d)
|
|
|
|
require.NoError(t, err)
|
2020-07-31 10:58:22 +00:00
|
|
|
require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex)))
|
2020-05-22 12:43:46 +00:00
|
|
|
}
|