OSDN Git Service

Fixed code file abs path.
authorgguoss <1536310027@qq.com>
Fri, 22 Sep 2017 02:13:58 +0000 (10:13 +0800)
committergguoss <1536310027@qq.com>
Fri, 22 Sep 2017 02:13:58 +0000 (10:13 +0800)
blockchain/hsm.go
blockchain/hsm_test.go [deleted file]
blockchain/pseudohsm/addrcache.go
blockchain/pseudohsm/addrcache_test.go
blockchain/pseudohsm/key.go
blockchain/pseudohsm/keystore_passphrase.go
blockchain/pseudohsm/keystore_passphrase_test.go
blockchain/pseudohsm/pseudohsm.go
blockchain/pseudohsm/pseudohsm_test.go
crypto/crypto.go

index 1aff0aa..5d2451f 100644 (file)
@@ -1,14 +1,12 @@
-//+build !no_Pseudohsm
-
-package core
+package blockchain
 
 import (
        "context"
-       "bytom/core/pseudohsm"
-       "bytom/core/txbuilder"
-       "bytom/crypto/ed25519/chainkd"
-       "bytom/net/http/httperror"
-       "bytom/net/http/httpjson"
+       "github.com/bytom/blockchain/pseudohsm"
+       "github.com/bytom/blockchain/txbuilder"
+       "github.com/bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/net/http/httperror"
+       "github.com/bytom/net/http/httpjson"
 )
 
 func init() {
@@ -157,4 +155,4 @@ func (h *remoteHSM) Sign(ctx context.Context, pk ed25519.PublicKey, date [32]byt
        err = h.Client.Call(ctx, "/sign-transaction", body, &sigBytes)
        return sigBytes
 }
-*/
\ No newline at end of file
+*/
diff --git a/blockchain/hsm_test.go b/blockchain/hsm_test.go
deleted file mode 100644 (file)
index b7f043b..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-package core
-
-import (
-       "context"
-       "testing"
-       "time"
-
-       "chain/core/account"
-       "chain/core/asset"
-       "chain/core/coretest"
-       "chain/core/generator"
-       "chain/core/pseudohsm"
-       "chain/core/pin"
-       "chain/core/query"
-       "chain/core/txbuilder"
-       "chain/crypto/ed25519/chainkd"
-       "chain/database/pg/pgtest"
-       "chain/protocol/bc"
-       "chain/protocol/prottest"
-       "chain/testutil"
-)
-
-func TestPseudoHSM((t *testing.T) {
-       c := prottest.NewChain(t)
-       g := generator.New(c, nil, db)
-       pinStore := pin.NewStore(db)
-       assets := asset.NewRegistry(db, c, pinStore)
-       accounts := account.NewManager(db, c, pinStore)
-       coretest.CreatePins(ctx, t, pinStore)
-       accounts.IndexAccounts(query.NewIndexer(db, c, pinStore))
-       go accounts.ProcessBlocks(ctx)
-       pseudohsm := pseudohsm.New(db)
-
-       xpub1, err := pseudohsm.XCreate("langyu", "nopassword")
-       if err != nil {
-               t.Fatal(err)
-       }
-       acct1, err := accounts.Create(ctx, []chainkd.XPub{xpub1.XPub}, 1, "", nil, "")
-       if err != nil {
-               t.Fatal(err)
-       }
-
-       _, xpub2, err := chainkd.NewXKeys(nil)
-       if err != nil {
-               t.Fatal(err)
-       }
-       acct2, err := accounts.Create(ctx, []chainkd.XPub{xpub2}, 1, "", nil, "")
-       if err != nil {
-               t.Fatal(err)
-       }
-
-       assetDef1 := map[string]interface{}{"foo": 1}
-       assetDef2 := map[string]interface{}{"foo": 2}
-
-       asset1ID := coretest.CreateAsset(ctx, t, assets, assetDef1, "", nil)
-       asset2ID := coretest.CreateAsset(ctx, t, assets, assetDef2, "", nil)
-
-       issueSrc1 := txbuilder.Action(assets.NewIssueAction(bc.AssetAmount{AssetId: &asset1ID, Amount: 100}, nil))
-       issueSrc2 := txbuilder.Action(assets.NewIssueAction(bc.AssetAmount{AssetId: &asset2ID, Amount: 200}, nil))
-       issueDest1 := accounts.NewControlAction(bc.AssetAmount{AssetId: &asset1ID, Amount: 100}, acct1.ID, nil)
-       issueDest2 := accounts.NewControlAction(bc.AssetAmount{AssetId: &asset2ID, Amount: 200}, acct2.ID, nil)
-       tmpl, err := txbuilder.Build(ctx, nil, []txbuilder.Action{issueSrc1, issueSrc2, issueDest1, issueDest2}, time.Now().Add(time.Minute))
-       if err != nil {
-               t.Fatal(err)
-       }
-       coretest.SignTxTemplate(t, ctx, tmpl, &testutil.TestXPrv)
-       err = txbuilder.FinalizeTx(ctx, c, g, tmpl.Transaction)
-       if err != nil {
-               t.Fatal(err)
-       }
-       handler := &mockHSMHandler{MockHSM: mockhsm}
-       outTmpls := handler.mockhsmSignTemplates(ctx, struct {
-               Txs   []*txbuilder.Template `json:"transactions"`
-               XPubs []chainkd.XPub        `json:"xpubs"`
-       }{[]*txbuilder.Template{tmpl}, []chainkd.XPub{xpub1.XPub}})
-       if len(outTmpls) != 1 {
-               t.Fatalf("expected 1 output template, got %d", len(outTmpls))
-       }
-       outTmpl, ok := outTmpls[0].(*txbuilder.Template)
-       if !ok {
-               t.Fatalf("expected a *txbuilder.Template, got %T (%v)", outTmpls[0], outTmpls[0])
-       }
-       if len(outTmpl.SigningInstructions) != 2 {
-               t.Fatalf("expected 2 signing instructions, got %d", len(outTmpl.SigningInstructions))
-       }
-
-       inspectSigInst(t, outTmpl.SigningInstructions[0], true)
-       inspectSigInst(t, outTmpl.SigningInstructions[1], false)
-}
-
-func inspectSigInst(t *testing.T, si *txbuilder.SigningInstruction, expectSig bool) {
-       if len(si.SignatureWitnesses) != 1 {
-               t.Fatalf("len(si.SignatureWitnesses) is %d, want 1", len(si.SignatureWitnesses))
-       }
-       s := si.SignatureWitnesses[0]
-       if len(s.Sigs) != 1 {
-               t.Fatalf("len(s.Sigs) is %d, want 1", len(s.Sigs))
-       }
-       if expectSig {
-               if len(s.Sigs[0]) == 0 {
-                       t.Errorf("expected a signature in s.Sigs[0]")
-               }
-       } else {
-               if len(s.Sigs[0]) != 0 {
-                       t.Errorf("expected no signature in s.Sigs[0], got %x", s.Sigs[0])
-               }
-       }
-}
index 60e6b8c..12e3064 100644 (file)
@@ -28,8 +28,8 @@ import (
        "sync"
        "time"
 
-       "bytom/common"
-       _"bytom/errors"
+       "github.com/bytom/common"
+       _"github.com/bytom/errors"
 )
 
 // Minimum amount of time between cache reloads. This limit applies if the platform does
index 024631b..804b4cd 100644 (file)
@@ -27,7 +27,7 @@ import (
        "testing"
        "time"
 
-       "bytom/common"
+       "github.com/bytom/common"
        "github.com/cespare/cp"
        "github.com/davecgh/go-spew/spew"
 )
index 42b47d1..bc71f2b 100644 (file)
@@ -9,8 +9,8 @@ import (
        "path/filepath"
        "time"
 
-       "bytom/common"
-       "bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/common"
+       "github.com/bytom/crypto/ed25519/chainkd"
 
        "github.com/pborman/uuid"
 
index 9faead1..f4ae531 100644 (file)
@@ -36,10 +36,10 @@ import (
        "io/ioutil"
        "path/filepath"
 
-       "bytom/common"
-       "bytom/crypto"
-       "bytom/crypto/randentropy"
-       "bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/common"
+       "github.com/bytom/crypto"
+       "github.com/bytom/crypto/randentropy"
+       "github.com/bytom/crypto/ed25519/chainkd"
        "github.com/pborman/uuid"
        "golang.org/x/crypto/pbkdf2"
        "golang.org/x/crypto/scrypt"
@@ -317,4 +317,4 @@ func pkcs7Unpad(in []byte) []byte {
                }
        }
        return in[:len(in)-int(padding)]
-}
\ No newline at end of file
+}
index 5449dfd..f6cd7aa 100644 (file)
@@ -20,9 +20,9 @@ import (
        "io/ioutil"
        "testing"
 
-       "bytom/common"
-       "bytom/crypto"
-       "bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/common"
+       "github.com/bytom/crypto"
+       "github.com/bytom/crypto/ed25519/chainkd"
 
        "github.com/pborman/uuid"
 
index e95b7d3..ff546a6 100644 (file)
@@ -9,13 +9,13 @@ import (
        "sync"
        "os"
 
-       "bytom/crypto/ed25519/chainkd"
-       "bytom/common"
-       "bytom/errors"
-       "bytom/crypto"
+       "github.com/bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/common"
+       "github.com/bytom/errors"
+       "github.com/bytom/crypto"
        //"bytom/protocol/bc/legacy"
 
-       "bytom/blockchain/config"
+       //"github.com/bytom/blockchain/config"
        "github.com/pborman/uuid"
 )
 
@@ -46,8 +46,8 @@ type XPub struct {
        File    string             `json:"file"`
 }
 
-func New(conf *config.Config) *HSM {
-       keydir, _ := filepath.Abs(conf.KeyPath)
+func New(/*conf *config.Config*/) *HSM {
+       keydir, _ := filepath.Abs("~/.bytom")
        return &HSM{
                keyStore:   &keyStorePassphrase{keydir, LightScryptN, LightScryptP},
                cache:          newAddrCache(keydir),
@@ -193,4 +193,4 @@ func (h *HSM) ResetPassword(xpub chainkd.XPub, auth, newAuth string) error {
                return err
        }
        return h.keyStore.StoreKey(xpb.File, xkey, newAuth)
-}
\ No newline at end of file
+}
index 111193f..a2aec04 100644 (file)
@@ -5,8 +5,8 @@ import (
        "testing"
        _"github.com/davecgh/go-spew/spew"
 
-       "bytom/blockchain/config"
-       "bytom/errors"
+       "github.com/bytom/blockchain/config"
+       "github.com/bytom/errors"
        //"bytom/protocol/bc/legacy"
 )
 
index 8c328d9..db2079f 100644 (file)
@@ -26,7 +26,7 @@ import (
        //"encoding/hex"
        //"errors"
 
-       "bytom/common"
+       "github.com/bytom/common"
        "golang.org/x/crypto/sha3"
        "golang.org/x/crypto/ripemd160"
 )