diff --git a/pkg/core/entities/asset_state_test.go b/pkg/core/entities/asset_state_test.go index 084f1cd3c..58e4896ce 100644 --- a/pkg/core/entities/asset_state_test.go +++ b/pkg/core/entities/asset_state_test.go @@ -36,3 +36,13 @@ func TestEncodeDecodeAssetState(t *testing.T) { assert.Nil(t, r.Err) assert.Equal(t, asset, assetDecode) } + +func TestAssetState_GetName_NEO(t *testing.T) { + asset := &AssetState{AssetType: transaction.GoverningToken} + assert.Equal(t, "NEO", asset.GetName()) +} + +func TestAssetState_GetName_NEOGas(t *testing.T) { + asset := &AssetState{AssetType: transaction.UtilityToken} + assert.Equal(t, "NEOGas", asset.GetName()) +} diff --git a/pkg/core/entities/notification_event_test.go b/pkg/core/entities/notification_event_test.go new file mode 100644 index 000000000..6bd7f47dc --- /dev/null +++ b/pkg/core/entities/notification_event_test.go @@ -0,0 +1,44 @@ +package entities + +import ( + "testing" + + "github.com/CityOfZion/neo-go/pkg/core/testutil" + "github.com/CityOfZion/neo-go/pkg/io" + "github.com/stretchr/testify/assert" +) + +func TestEncodeDecodeNotificationEvent(t *testing.T) { + event := &NotificationEvent{ + ScriptHash: testutil.RandomUint160(), + Item: nil, + } + + buf := io.NewBufBinWriter() + event.EncodeBinary(buf.BinWriter) + assert.Nil(t, buf.Err) + + eventDecoded := &NotificationEvent{} + reader := io.NewBinReaderFromBuf(buf.Bytes()) + eventDecoded.DecodeBinary(reader) + assert.Equal(t, event, eventDecoded) +} + +func TestEncodeDecodeAppExecResult(t *testing.T) { + appExecResult := &AppExecResult{ + TxHash: testutil.RandomUint256(), + Trigger: 1, + VMState: "Hault", + GasConsumed: 10, + Stack: "", + Events: []NotificationEvent{}, + } + buf := io.NewBufBinWriter() + appExecResult.EncodeBinary(buf.BinWriter) + assert.Nil(t, buf.Err) + + appExecResultDecoded := &AppExecResult{} + reader := io.NewBinReaderFromBuf(buf.Bytes()) + appExecResultDecoded.DecodeBinary(reader) + assert.Equal(t, appExecResult, appExecResultDecoded) +} diff --git a/pkg/core/entities/storage_item_test.go b/pkg/core/entities/storage_item_test.go index 870b5d166..6200cc19b 100644 --- a/pkg/core/entities/storage_item_test.go +++ b/pkg/core/entities/storage_item_test.go @@ -1,2 +1,26 @@ package entities +import ( + "testing" + + "github.com/CityOfZion/neo-go/pkg/io" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestEncodeDecodeStorageItem(t *testing.T) { + storageItem := &StorageItem{ + Value: []byte{}, + IsConst: false, + } + buf := io.NewBufBinWriter() + storageItem.EncodeBinary(buf.BinWriter) + require.NoError(t, buf.Err) + + decodedStorageItem := &StorageItem{} + r := io.NewBinReaderFromBuf(buf.Bytes()) + decodedStorageItem.DecodeBinary(r) + require.NoError(t, r.Err) + + assert.Equal(t, storageItem, decodedStorageItem) +}