OSDN Git Service

Fix typo and delete coretest
authorBlockmeta-区块元 <blockmeta@8btc.com>
Wed, 1 Nov 2017 09:24:01 +0000 (17:24 +0800)
committerBlockmeta-区块元 <blockmeta@8btc.com>
Wed, 1 Nov 2017 09:24:01 +0000 (17:24 +0800)
fix typo  "XKey“
delete coretest directory

blockchain/coretest/fixture.go [deleted file]
blockchain/pseudohsm/UTC--2017-11-01T09-22-05.314919273Z--1d19c967-56f2-45ac-97bf-c26c9d80a34f [new file with mode: 0644]
blockchain/pseudohsm/keystore_passphrase_test.go
blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.003850839Z--63b126d2-e248-41f5-a433-44aa2ef04f8a [new file with mode: 0644]
blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.127699477Z--a46104b7-095e-4a5c-b341-bb0d08c48fa0 [new file with mode: 0644]
blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.846041974Z--94e71abb-91bc-4e34-bc11-5a22cd3911f5 [new file with mode: 0644]
blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.954884405Z--338fe728-12f9-4251-9b64-8b0a6d6dd3c0 [new file with mode: 0644]

diff --git a/blockchain/coretest/fixture.go b/blockchain/coretest/fixture.go
deleted file mode 100644 (file)
index 5810c85..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
- Package coretest provides utilities for testing Chain Core.
-package coretest
-
-import (
-    "context"
-    "testing"
-    "time"
-
-    "github.com/bytom/account"
-    "github.com/bytom/asset"
-    "github.com/bytom/pin"
-    "github.com/bytom/query"
-    "github.com/bytom/txbuilder"
-    "github.com/bytom/crypto/ed25519/chainkd"
-    "github.com/bytom/protocol"
-    "github.com/bytom/protocol/bc"
-    "github.com/bytom/protocol/bc/legacy"
-    "github.com/bytom/testutil"
-)
-
-func CreatePins(ctx context.Context, t testing.TB, s *pin.Store) {
-    pins := []string{
-        account.PinName,
-        account.ExpirePinName,
-        account.DeleteSpentsPinName,
-        asset.PinName,
-        query.TxPinName,
-    }
-    for _, p := range pins {
-        err := s.CreatePin(ctx, p, 0)
-        if err != nil {
-            testutil.FatalErr(t, err)
-        }
-    }
-}
-
-func CreateAccount(ctx context.Context, t testing.TB, accounts *account.Manager, alias string, tags map[string]interface{}) string {
-    keys := []chainkd.XPub{testutil.TestXPub}
-    acc, err := accounts.Create(ctx, keys, 1, alias, tags, "")
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-    return acc.ID
-}
-
-func CreateAsset(ctx context.Context, t testing.TB, assets *asset.Registry, def map[string]interface{}, alias string, tags map[string]interface{}) bc.AssetID {
-    keys := []chainkd.XPub{testutil.TestXPub}
-    asset, err := assets.Define(ctx, keys, 1, def, alias, tags, "")
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-    return asset.AssetID
-}
-
-func IssueAssets(ctx context.Context, t testing.TB, c *protocol.Chain, s txbuilder.Submitter, assets *asset.Registry, accounts *account.Manager, assetID bc.AssetID, amount uint64, accountID string) (*legacy.TxOutput, *bc.Output, bc.Hash) {
-    assetAmount := bc.AssetAmount{AssetId: &assetID, Amount: amount}
-
-    tpl, err := txbuilder.Build(ctx, nil, []txbuilder.Action{
-        assets.NewIssueAction(assetAmount, nil), // does not support reference data
-        accounts.NewControlAction(assetAmount, accountID, nil),
-    }, time.Now().Add(time.Hour))
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-
-    SignTxTemplate(t, ctx, tpl, &testutil.TestXPrv)
-
-    err = txbuilder.FinalizeTx(ctx, c, s, tpl.Transaction)
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-
-    outID0 := tpl.Transaction.OutputID(0)
-    out0 := tpl.Transaction.Entries[*outID0].(*bc.Output)
-    return tpl.Transaction.Outputs[0], out0, *outID0
-}
-
-func Transfer(ctx context.Context, t testing.TB, c *protocol.Chain, s txbuilder.Submitter, actions []txbuilder.Action) *legacy.Tx {
-    template, err := txbuilder.Build(ctx, nil, actions, time.Now().Add(time.Hour))
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-
-    SignTxTemplate(t, ctx, template, &testutil.TestXPrv)
-
-    tx := legacy.NewTx(template.Transaction.TxData)
-    err = txbuilder.FinalizeTx(ctx, c, s, tx)
-    if err != nil {
-        testutil.FatalErr(t, err)
-    }
-
-    return tx
-}
-
-func SignTxTemplate(t testing.TB, ctx context.Context, template *txbuilder.Template, priv *chainkd.XPrv) {
-    if priv == nil {
-        priv = &testutil.TestXPrv
-    }
-    err := txbuilder.Sign(ctx, template, []chainkd.XPub{priv.XPub()}, func(_ context.Context, _ chainkd.XPub, path [][]byte, data [32]byte) ([]byte, error) {
-        derived := priv.Derive(path)
-        return derived.Sign(data[:]), nil
-    })
-    if err != nil {
-        t.Fatal(err)
-    }
-}
diff --git a/blockchain/pseudohsm/UTC--2017-11-01T09-22-05.314919273Z--1d19c967-56f2-45ac-97bf-c26c9d80a34f b/blockchain/pseudohsm/UTC--2017-11-01T09-22-05.314919273Z--1d19c967-56f2-45ac-97bf-c26c9d80a34f
new file mode 100644 (file)
index 0000000..b81f71d
--- /dev/null
@@ -0,0 +1 @@
+{"crypto":{"cipher":"aes-128-ctr","ciphertext":"d163ea867f61ff851898e777bbe9ea288e319da0cd0906cfd31c3b975dab705c2e79fd3e84d61788a3b74645e4e9d5f52a809e6c03474941055511e65a085f1c","cipherparams":{"iv":"51c6ff5614aa837736a12d3ccc79d1e7"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":2,"p":1,"r":8,"salt":"de4c2af72f3c697a65492227149c797c17b01ea78444bd18bf45ebdab79424eb"},"mac":"5d44bab4cbcfb183197c56eba4260c77fa38db6a07905dad44b9659f2f39ec30"},"id":"1d19c967-56f2-45ac-97bf-c26c9d80a34f","type":"bytom_kd","version":1,"alias":"verylight","xpub":"e534ee7fbf8d68b8be552a1b9d806137be1b70522cce382187f6deb053e45f96e368de9290a17cb44b6190fca9e24718c94791a99d104e4aff3faf23b34cfa43"}
\ No newline at end of file
index 032503b..87dcc48 100644 (file)
@@ -46,7 +46,6 @@ func TestKeyEncryptDecrypt(t *testing.T) {
        }
 }
 
-
 func TestGenerateFile(t *testing.T) {
        xprv, xpub, err := chainkd.NewXKeys(nil)
        if err != nil {
@@ -54,14 +53,14 @@ func TestGenerateFile(t *testing.T) {
        }
        id := uuid.NewRandom()
        key := &XKey{
-               Id:      id,
+               ID:      id,
                KeyType: "bytom_kd",
                XPub:    xpub,
                XPrv:    xprv,
-               Alias:   "verylight",
+               Alias:   "verylight",
        }
        t.Log(key)
        password := "bytomtest"
        xkey, err := EncryptKey(key, password, veryLightScryptN, veryLightScryptP)
-       writeKeyFile(keyFileName(key.Id.String()), xkey)
+       writeKeyFile(keyFileName(key.ID.String()), xkey)
 }
diff --git a/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.003850839Z--63b126d2-e248-41f5-a433-44aa2ef04f8a b/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.003850839Z--63b126d2-e248-41f5-a433-44aa2ef04f8a
new file mode 100644 (file)
index 0000000..fc6d07c
--- /dev/null
@@ -0,0 +1 @@
+{"crypto":{"cipher":"aes-128-ctr","ciphertext":"755eda9615a4954baf6b75fccf6354796f543342031d83d6cbfe0d4209197b853bc711c84f5a9d1e4ad6ef2de123e6eca1be06408927705cc2db43a722ff6dea","cipherparams":{"iv":"e39dc4c729d0bd1deff496333f5a10f5"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"4cf147c1529b551480004b050b1799d7ea0568131b443f61da0ee2303e504641"},"mac":"0705d0ff181c46f38b11d553fa9ce13788d75a2d85a3102a73789db5569d42a3"},"id":"63b126d2-e248-41f5-a433-44aa2ef04f8a","type":"bytom_kd","version":1,"alias":"xpub1","xpub":"39d87af4069a715d73bb2a2b2072842ccae0f3f9d982a35d6e2f76df01779b20c37b4317d527b054d27f8f6e82c29eedb75490e71ae8a6fea64c97ed4c45d9fa"}
\ No newline at end of file
diff --git a/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.127699477Z--a46104b7-095e-4a5c-b341-bb0d08c48fa0 b/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-16-30.127699477Z--a46104b7-095e-4a5c-b341-bb0d08c48fa0
new file mode 100644 (file)
index 0000000..f373b61
--- /dev/null
@@ -0,0 +1 @@
+{"crypto":{"cipher":"aes-128-ctr","ciphertext":"f74202ca92bd18c0a4a07cc7a75551bd6595027c1643517e50d2221a33fb75bf5b8dba6052c4afa97add9578cd1864888bb3d6ba07a393eb490604722874b5dc","cipherparams":{"iv":"916dbcce9ee7388fbd0deb2184ec504a"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"9b78c1a7a4fe73d72e8785b265ba3a7b69a003bd0fe047e10d5830231de48d74"},"mac":"c2ce02e09fbdd341fec6dc28ec13eea70e4f48ba9c690eef1bb73db02c22de83"},"id":"a46104b7-095e-4a5c-b341-bb0d08c48fa0","type":"bytom_kd","version":1,"alias":"xpub2","xpub":"f93bbabfec4fc854700f9e4b60c26bfd52db8393c80303df11e859306a2516c5789fb7222ad72d16848b52f849469ad370dd11ef6d7b6b3e55b65b73c350146d"}
\ No newline at end of file
diff --git a/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.846041974Z--94e71abb-91bc-4e34-bc11-5a22cd3911f5 b/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.846041974Z--94e71abb-91bc-4e34-bc11-5a22cd3911f5
new file mode 100644 (file)
index 0000000..68203fd
--- /dev/null
@@ -0,0 +1 @@
+{"crypto":{"cipher":"aes-128-ctr","ciphertext":"d772b05b5b2759390745dba39e02ba12f8b09568fb51007f773c17ecb688f2f979ebe31bdfa86c5ff3a9f6546bb3c5f6e970302108415026c140e4a339ca0761","cipherparams":{"iv":"b2f5f4625fd314fd879a17aa094f0c45"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"64fbe90b20a1bb78c2d48bfb00550a503b52e2da158be55fcd5c194352743307"},"mac":"fc3e6fbdf28d62df16f548838d7169ba2679a94d9fa262e9393ff51911933965"},"id":"94e71abb-91bc-4e34-bc11-5a22cd3911f5","type":"bytom_kd","version":1,"alias":"xpub1","xpub":"d528a5804d59f1dacbcdcc5b962853f0db3f7dad2448b25a7635128417ee4c0890de36c31f38b12e7882b1c36b1d2457db13b68193493c5495585619d3d74a43"}
\ No newline at end of file
diff --git a/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.954884405Z--338fe728-12f9-4251-9b64-8b0a6d6dd3c0 b/blockchain/pseudohsm/testdata/pseudo/UTC--2017-11-01T09-22-06.954884405Z--338fe728-12f9-4251-9b64-8b0a6d6dd3c0
new file mode 100644 (file)
index 0000000..170f7a5
--- /dev/null
@@ -0,0 +1 @@
+{"crypto":{"cipher":"aes-128-ctr","ciphertext":"b0e302ac52aa8136db46d973d833091508b55a25e6d14dbc7094e1c5abaef10b98e78cd52ba49602272326171893dda8d189ed4a26d4803ef1110461cc263191","cipherparams":{"iv":"af31e86b57a802791c8cdbdfa9de3ecc"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"e3f9d124a5a28743a3bad4820ac585dcb77ddbf0bb0690cd6f47f60768e443bb"},"mac":"a85fbd00b23937567a02042c3076192b03e8233b5784bc1d571cf709c0d9ee2d"},"id":"338fe728-12f9-4251-9b64-8b0a6d6dd3c0","type":"bytom_kd","version":1,"alias":"xpub2","xpub":"8873b019d6cc60b481017434facacf24efc7660d5745ee590ec314cfa2e7af23c41a18236f8a72c8daf44f83a5403540d66457a48286b302777fd768554b806a"}
\ No newline at end of file