2018-04-16 20:15:30 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
2019-08-27 13:29:42 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
2018-04-16 20:15:30 +00:00
|
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEncodeDecodeAssetState(t *testing.T) {
|
|
|
|
asset := &AssetState{
|
2019-08-23 15:50:45 +00:00
|
|
|
ID: randomUint256(),
|
2018-04-16 20:15:30 +00:00
|
|
|
AssetType: transaction.Token,
|
|
|
|
Name: "super cool token",
|
|
|
|
Amount: util.Fixed8(1000000),
|
|
|
|
Available: util.Fixed8(100),
|
|
|
|
Precision: 0,
|
|
|
|
FeeMode: feeMode,
|
2019-08-27 13:29:42 +00:00
|
|
|
Owner: &keys.PublicKey{},
|
2019-08-23 15:50:45 +00:00
|
|
|
Admin: randomUint160(),
|
|
|
|
Issuer: randomUint160(),
|
2018-04-16 20:15:30 +00:00
|
|
|
Expiration: 10,
|
|
|
|
IsFrozen: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
assert.Nil(t, asset.EncodeBinary(buf))
|
|
|
|
assetDecode := &AssetState{}
|
|
|
|
assert.Nil(t, assetDecode.DecodeBinary(buf))
|
|
|
|
assert.Equal(t, asset, assetDecode)
|
|
|
|
}
|