forked from TrueCloudLab/neoneo-go
ec7e17ffa6
Simplifies a lot of code and removes some duplication. Unfortunately I had to move test_util random functions in same commit to avoid cycle dependencies. One of these random functions was also used in core/transaction testing, to simplify things I've just dropped it there and used a static string (which is nice to have for a test anyway). There is still sha256 left in wallet (but it needs to pass Hash structure into the signing function).
34 lines
820 B
Go
34 lines
820 B
Go
package core
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
"github.com/CityOfZion/neo-go/pkg/crypto"
|
|
"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: &crypto.PublicKey{},
|
|
Admin: randomUint160(),
|
|
Issuer: randomUint160(),
|
|
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)
|
|
}
|