OSDN Git Service

fix log
[bytom/vapor.git] / test / util.go
index 6b6a771..54b9b05 100644 (file)
@@ -4,14 +4,15 @@ import (
        "context"
        "time"
 
-       dbm "github.com/tendermint/tmlibs/db"
-
        "github.com/vapor/account"
        "github.com/vapor/blockchain/pseudohsm"
        "github.com/vapor/blockchain/txbuilder"
+       "github.com/vapor/config"
        "github.com/vapor/consensus"
        "github.com/vapor/crypto/ed25519/chainkd"
-       "github.com/vapor/database/leveldb"
+       "github.com/vapor/database"
+       dbm "github.com/vapor/database/leveldb"
+       "github.com/vapor/event"
        "github.com/vapor/protocol"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
@@ -24,10 +25,12 @@ const (
 )
 
 // MockChain mock chain with genesis block
-func MockChain(testDB dbm.DB) (*protocol.Chain, *leveldb.Store, *protocol.TxPool, error) {
-       store := leveldb.NewStore(testDB)
-       txPool := protocol.NewTxPool(store)
-       chain, err := protocol.NewChain(store, txPool)
+func MockChain(testDB dbm.DB) (*protocol.Chain, *database.Store, *protocol.TxPool, error) {
+       config.CommonConfig = config.DefaultConfig()
+       store := database.NewStore(testDB)
+       dispatcher := event.NewDispatcher()
+       txPool := protocol.NewTxPool(store, dispatcher)
+       chain, err := protocol.NewChain(store, txPool, dispatcher)
        return chain, store, txPool, err
 }
 
@@ -58,7 +61,7 @@ func MockTx(utxo *account.UTXO, testAccount *account.Account) (*txbuilder.Templa
        if err := b.AddInput(txInput, sigInst); err != nil {
                return nil, nil, err
        }
-       out := types.NewTxOutput(*consensus.BTMAssetID, 100, []byte{byte(vm.OP_FAIL)})
+       out := types.NewIntraChainOutput(*consensus.BTMAssetID, 100, []byte{byte(vm.OP_FAIL)})
        if err := b.AddOutput(out); err != nil {
                return nil, nil, err
        }