neo-go/pkg/core/native/blocked_accounts_test.go
2020-06-24 07:35:07 +03:00

53 lines
1.4 KiB
Go

package native
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/stretchr/testify/require"
)
func TestEncodeDecodeBinary(t *testing.T) {
expected := &BlockedAccounts{
util.Uint160{1, 2, 3},
util.Uint160{4, 5, 6},
}
actual := new(BlockedAccounts)
testserdes.EncodeDecodeBinary(t, expected, actual)
expected = &BlockedAccounts{}
actual = new(BlockedAccounts)
testserdes.EncodeDecodeBinary(t, expected, actual)
}
func TestBytesFromBytes(t *testing.T) {
expected := BlockedAccounts{
util.Uint160{1, 2, 3},
util.Uint160{4, 5, 6},
}
actual, err := BlockedAccountsFromBytes(expected.Bytes())
require.NoError(t, err)
require.Equal(t, expected, actual)
expected = BlockedAccounts{}
actual, err = BlockedAccountsFromBytes(expected.Bytes())
require.NoError(t, err)
require.Equal(t, expected, actual)
}
func TestToStackItem(t *testing.T) {
u1 := util.Uint160{1, 2, 3}
u2 := util.Uint160{4, 5, 6}
expected := BlockedAccounts{u1, u2}
actual := stackitem.NewArray([]stackitem.Item{
stackitem.NewByteArray(u1.BytesLE()),
stackitem.NewByteArray(u2.BytesLE()),
})
require.Equal(t, expected.ToStackItem(), actual)
expected = BlockedAccounts{}
actual = stackitem.NewArray([]stackitem.Item{})
require.Equal(t, expected.ToStackItem(), actual)
}