2018-03-25 10:45:54 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-26 14:43:24 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2018-03-25 10:45:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRegisterTX(t *testing.T) {
|
2019-11-27 09:20:31 +00:00
|
|
|
someuint160, _ := util.Uint160DecodeStringBE("4d3b96ae1bcc5a585e075e3b81920210dec16302")
|
2020-04-10 10:41:49 +00:00
|
|
|
registerTx := &RegisterTX{
|
|
|
|
AssetType: UtilityToken,
|
|
|
|
Name: "this is some token I created",
|
|
|
|
Amount: util.Fixed8FromInt64(1000000),
|
|
|
|
Precision: 8,
|
|
|
|
Admin: someuint160,
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
2020-04-10 10:41:49 +00:00
|
|
|
tx := NewRegisterTX(registerTx)
|
2020-03-26 14:43:24 +00:00
|
|
|
_ = tx.Hash()
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, tx, new(Transaction))
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 10:41:49 +00:00
|
|
|
//TODO NEO3.0: update binary
|
|
|
|
/*
|
2018-03-25 10:45:54 +00:00
|
|
|
func TestDecodeRegisterTXFromRawString(t *testing.T) {
|
|
|
|
rawTX := "400000455b7b226c616e67223a227a682d434e222c226e616d65223a22e5b08fe89a81e882a1227d2c7b226c616e67223a22656e222c226e616d65223a22416e745368617265227d5d0000c16ff28623000000da1745e9b549bd0bfa1a569971c77eba30cd5a4b00000000"
|
|
|
|
b, err := hex.DecodeString(rawTX)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
|
|
|
tx := &Transaction{}
|
2020-03-26 14:43:24 +00:00
|
|
|
assert.NoError(t, testserdes.DecodeBinary(b, tx))
|
2018-03-25 10:45:54 +00:00
|
|
|
assert.Equal(t, RegisterType, tx.Type)
|
|
|
|
txData := tx.Data.(*RegisterTX)
|
|
|
|
assert.Equal(t, GoverningToken, txData.AssetType)
|
|
|
|
assert.Equal(t, "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]", txData.Name)
|
2019-08-23 12:41:22 +00:00
|
|
|
assert.Equal(t, util.Fixed8FromInt64(100000000), txData.Amount)
|
2018-03-25 10:45:54 +00:00
|
|
|
assert.Equal(t, uint8(0), txData.Precision)
|
2019-12-09 15:33:04 +00:00
|
|
|
assert.Equal(t, keys.PublicKey{}, txData.Owner)
|
2019-12-25 14:34:18 +00:00
|
|
|
assert.Equal(t, "Abf2qMs1pzQb8kYk9RuxtUb9jtRKJVuBJt", address.Uint160ToString(txData.Admin))
|
2019-11-27 09:23:18 +00:00
|
|
|
assert.Equal(t, "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b", tx.Hash().StringLE())
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2020-03-26 14:43:24 +00:00
|
|
|
testserdes.EncodeDecodeBinary(t, tx, new(Transaction))
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
2020-04-10 10:41:49 +00:00
|
|
|
*/
|