OSDN Git Service

update
authorChengcheng Zhang <943420582@qq.com>
Sat, 25 May 2019 16:02:23 +0000 (00:02 +0800)
committerChengcheng Zhang <943420582@qq.com>
Sat, 25 May 2019 16:02:23 +0000 (00:02 +0800)
account/accounts_test.go
crypto/ed25519/chainkd/serialize.go

index 1f773d4..94b5393 100644 (file)
@@ -62,18 +62,20 @@ func TestCreateAccountWithSpaceTrimed(t *testing.T) {
 
 func TestCreateAccount(t *testing.T) {
        m := mockAccountManager(t)
-       xpubs := []vcrypto.XPubKeyer{testutil.TestXPub}
-       account, err := m.Create(xpubs, 1, "test-alias", signers.BIP0044)
+       // xpubs := []vcrypto.XPubKeyer{testutil.TestXPub}
+       xpubers := make([]vcrypto.XPubKeyer, 1)
+       xpubers[0] = testutil.TestXPub
+       account, err := m.Create(xpubers, 1, "test-alias", signers.BIP0044)
        if err != nil {
                testutil.FatalErr(t, err)
        }
-       fmt.Println("account is:", account, "account xpub:", account.XPubs)
+       fmt.Println("TestCreateAccount account is:", account, "account xpub:", account.XPubs, "type of xpubs:", reflect.TypeOf(account.XPubs[0]))
 
        found, err := m.FindByID(account.ID)
        if err != nil {
                t.Errorf("unexpected error %v", err)
        }
-       fmt.Println("found is:", found, "found xpub:", found.XPubs)
+       fmt.Println("TestCreateAccount found is:", found, "found xpub:", found.XPubs, "type of xpubs:", reflect.TypeOf(found.XPubs[0]))
        if !testutil.DeepEqual(account, found) {
                t.Errorf("expected account %v to be recorded as %v", account, found)
                //////////
index 133b94b..b903dcb 100644 (file)
@@ -60,8 +60,9 @@ func (xprv XPrv) String() string {
        return hex.EncodeToString(xprv.Bytes())
 }
 
-func NewXPub(str string) (xpub *XPub, err error) {
-       if len(str) != 2*extendedPublicKeySize {
+func NewXPub(str string) (*XPub, error) {
+       xpub := new(XPub)
+       if len(str) != 2*64 {
                fmt.Println("str length is:", len(str))
                fmt.Println("str is:", str)
                return nil, errors.New("string length is invalid.")
@@ -69,8 +70,10 @@ func NewXPub(str string) (xpub *XPub, err error) {
        if xpubBytes, err := hex.DecodeString(str); err != nil {
                return nil, err
        } else {
+
+               fmt.Println("NewXPub xpub is:", xpub)
+               fmt.Println("NewXPub xpubBytes is:", xpubBytes)
                copy(xpub[:], xpubBytes[:])
        }
-
        return xpub, nil
 }