neoneo-go/pkg/network/payload/getblockbyindex_test.go
Anna Shaleva 737ba700e9 network: rename GetBlockData command
GetBlockData -> GetBlockByIndex
2020-08-04 17:52:34 +03:00

25 lines
678 B
Go

package payload
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
"github.com/stretchr/testify/require"
)
func TestGetBlockDataEncodeDecode(t *testing.T) {
d := NewGetBlockByIndex(123, 100)
testserdes.EncodeDecodeBinary(t, d, new(GetBlockByIndex))
// invalid block count
d = NewGetBlockByIndex(5, 0)
data, err := testserdes.EncodeBinary(d)
require.NoError(t, err)
require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex)))
// invalid block count
d = NewGetBlockByIndex(5, maxBlockCount+1)
data, err = testserdes.EncodeBinary(d)
require.NoError(t, err)
require.Error(t, testserdes.DecodeBinary(data, new(GetBlockByIndex)))
}