neoneo-go/pkg/vm/stackitem/serialization_test.go
Roman Khimov 5a9efcc654 stackitem: rework error handling
Return good named errors everywhere, export appropriate constants, make
errors.Is() work.
2021-07-07 00:18:00 +03:00

23 lines
479 B
Go

package stackitem
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestSerializationMaxErr(t *testing.T) {
base := make([]byte, MaxSize/2+1)
item := Make(base)
// Pointer is unserializable, but we specifically want to catch ErrTooBig.
arr := []Item{item, item.Dup(), NewPointer(0, []byte{})}
aitem := Make(arr)
_, err := Serialize(item)
require.NoError(t, err)
_, err = Serialize(aitem)
require.True(t, errors.Is(err, ErrTooBig), err)
}