mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-02 09:45:50 +00:00
d1a4e43c48
Further simplifies error handling.
37 lines
922 B
Go
37 lines
922 B
Go
package core
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestEncodeDecodeAssetState(t *testing.T) {
|
|
asset := &AssetState{
|
|
ID: randomUint256(),
|
|
AssetType: transaction.Token,
|
|
Name: "super cool token",
|
|
Amount: util.Fixed8(1000000),
|
|
Available: util.Fixed8(100),
|
|
Precision: 0,
|
|
FeeMode: feeMode,
|
|
Owner: &keys.PublicKey{},
|
|
Admin: randomUint160(),
|
|
Issuer: randomUint160(),
|
|
Expiration: 10,
|
|
IsFrozen: false,
|
|
}
|
|
|
|
buf := io.NewBufBinWriter()
|
|
asset.EncodeBinary(buf.BinWriter)
|
|
assert.Nil(t, buf.Err)
|
|
assetDecode := &AssetState{}
|
|
r := io.NewBinReaderFromBuf(buf.Bytes())
|
|
assetDecode.DecodeBinary(r)
|
|
assert.Nil(t, r.Err)
|
|
assert.Equal(t, asset, assetDecode)
|
|
}
|