OSDN Git Service

writer close
[bytom/vapor.git] / wallet / unconfirmed_test.go
index 0cc68bc..5904845 100644 (file)
@@ -14,6 +14,7 @@ import (
        "github.com/vapor/crypto/ed25519/chainkd"
        dbm "github.com/vapor/database/leveldb"
        "github.com/vapor/event"
+       "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
        "github.com/vapor/testutil"
 )
@@ -26,9 +27,11 @@ func TestWalletUnconfirmedTxs(t *testing.T) {
        defer os.RemoveAll(dirPath)
 
        testDB := dbm.NewDB("testdb", "leveldb", "temp")
+       testStore := NewMockWalletStore(testDB)
        defer os.RemoveAll("temp")
 
-       accountManager := account.NewManager(testDB, nil)
+       accountStore := NewMockAccountStore(testDB)
+       accountManager := account.NewManager(accountStore, nil)
        hsm, err := pseudohsm.New(dirPath)
        if err != nil {
                t.Fatal(err)
@@ -52,18 +55,15 @@ func TestWalletUnconfirmedTxs(t *testing.T) {
        controlProg.KeyIndex = 1
 
        reg := asset.NewRegistry(testDB, nil)
-       asset, err := reg.Define([]chainkd.XPub{xpub1.XPub}, 1, nil, 0, "TESTASSET", nil)
-       if err != nil {
-               t.Fatal(err)
-       }
+       asset := bc.AssetID{V0: 5}
 
        dispatcher := event.NewDispatcher()
-       w := mockWallet(testDB, accountManager, reg, nil, dispatcher, false)
+       w := mockWallet(testStore, accountManager, reg, nil, dispatcher, false)
        utxos := []*account.UTXO{}
        btmUtxo := mockUTXO(controlProg, consensus.BTMAssetID)
        utxos = append(utxos, btmUtxo)
 
-       OtherUtxo := mockUTXO(controlProg, &asset.AssetID)
+       OtherUtxo := mockUTXO(controlProg, &asset)
        utxos = append(utxos, OtherUtxo)
        _, txData, err := mockTxData(utxos, testAccount)
        if err != nil {
@@ -128,7 +128,7 @@ func AnnotatedTxs(txs []*types.Tx, w *Wallet) []*query.AnnotatedTx {
                annotatedTxs = append(annotatedTxs, annotatedTx)
        }
 
-       annotateTxsAccount(annotatedTxs, w.DB)
+       w.annotateTxsAccount(annotatedTxs)
        annotateTxsAsset(w, annotatedTxs)
 
        return annotatedTxs