b77e533d13
And drop associated _pkg.dev remnants (refs. #307). Original `dev` branch had two separate packages for public and private keys, but those are so intertwined (`TestHelper` subpackage is a proof) that it's better unite them and all associated code (like WIF and NEP-2) in one package. This patch also: * creates internal `keytestcases` package to share things with wallet (maybe it'll be changed in some future) * ports some tests from `dev` * ports Verify() method for public key from `dev` * expands TestPrivateKey() with public key check
34 lines
823 B
Go
34 lines
823 B
Go
package core
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
|
"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 := new(bytes.Buffer)
|
|
assert.Nil(t, asset.EncodeBinary(buf))
|
|
assetDecode := &AssetState{}
|
|
assert.Nil(t, assetDecode.DecodeBinary(buf))
|
|
assert.Equal(t, asset, assetDecode)
|
|
}
|