2018-02-01 09:25:34 +00:00
|
|
|
package payload
|
|
|
|
|
2018-02-07 14:16:50 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-23 11:09:00 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
2020-05-22 14:30:56 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-02-07 14:16:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetBlockEncodeDecode(t *testing.T) {
|
2020-05-22 14:30:56 +00:00
|
|
|
start := hash.Sha256([]byte("a"))
|
2018-02-07 14:16:50 +00:00
|
|
|
|
2020-05-22 14:30:56 +00:00
|
|
|
p := NewGetBlocks(start, 124)
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, p, new(GetBlocks))
|
2018-02-07 14:16:50 +00:00
|
|
|
|
2020-05-22 14:30:56 +00:00
|
|
|
// invalid count
|
|
|
|
p = NewGetBlocks(start, -2)
|
|
|
|
data, err := testserdes.EncodeBinary(p)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Error(t, testserdes.DecodeBinary(data, new(GetBlocks)))
|
|
|
|
|
|
|
|
// invalid count
|
|
|
|
p = NewGetBlocks(start, 0)
|
|
|
|
data, err = testserdes.EncodeBinary(p)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Error(t, testserdes.DecodeBinary(data, new(GetBlocks)))
|
2018-02-07 14:16:50 +00:00
|
|
|
}
|