OSDN Git Service

Peer add announces new block message num limit
[bytom/vapor.git] / test / bench_blockchain_test.go
index 1d3413b..092811d 100644 (file)
@@ -11,13 +11,14 @@ import (
        "github.com/vapor/blockchain/pseudohsm"
        "github.com/vapor/blockchain/signers"
        "github.com/vapor/blockchain/txbuilder"
+       "github.com/vapor/config"
        "github.com/vapor/consensus"
        "github.com/vapor/crypto/ed25519/chainkd"
        "github.com/vapor/database"
        dbm "github.com/vapor/database/leveldb"
        "github.com/vapor/database/storage"
        "github.com/vapor/event"
-       "github.com/vapor/mining"
+       "github.com/vapor/proposal"
        "github.com/vapor/protocol"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
@@ -126,7 +127,7 @@ func GenerateChainData(dirPath string, testDB dbm.DB, txNumber, otherAssetNum in
 
        // init UtxoViewpoint
        utxoView := state.NewUtxoViewpoint()
-       utxoEntry := storage.NewUtxoEntry(false, 1, false)
+       utxoEntry := storage.NewUtxoEntry(storage.NormalUTXOType, 1, false)
        for _, tx := range txs {
                for _, id := range tx.SpentOutputIDs {
                        utxoView.Entries[id] = utxoEntry
@@ -137,10 +138,11 @@ func GenerateChainData(dirPath string, testDB dbm.DB, txNumber, otherAssetNum in
                return nil, nil, nil, err
        }
 
+       config.CommonConfig = config.DefaultConfig()
        store := database.NewStore(testDB)
        dispatcher := event.NewDispatcher()
        txPool := protocol.NewTxPool(store, dispatcher)
-       chain, err := protocol.NewChain(store, txPool)
+       chain, err := protocol.NewChain(store, txPool, dispatcher)
        if err != nil {
                return nil, nil, nil, err
        }
@@ -157,7 +159,7 @@ func InsertChain(chain *protocol.Chain, txPool *protocol.TxPool, txs []*types.Tx
                }
        }
 
-       block, err := mining.NewBlockTemplate(chain, txPool, nil)
+       block, err := proposal.NewBlockTemplate(chain, txPool, nil, uint64(time.Now().UnixNano()/1e6))
        if err != nil {
                return err
        }
@@ -249,7 +251,7 @@ func AddTxInputFromUtxo(utxo *account.UTXO, singer *signers.Signer) (*types.TxIn
 }
 
 func AddTxOutput(assetID bc.AssetID, amount uint64, controlProgram []byte) *types.TxOutput {
-       out := types.NewTxOutput(assetID, amount, controlProgram)
+       out := types.NewIntraChainOutput(assetID, amount, controlProgram)
        return out
 }
 
@@ -366,7 +368,8 @@ func SetUtxoView(db dbm.DB, view *state.UtxoViewpoint) error {
 
 //-------------------------Mock actual transaction----------------------------------
 func MockTxsP2PKH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) {
-       accountManager := account.NewManager(testDB, nil)
+       accountStore := database.NewAccountStore(testDB)
+       accountManager := account.NewManager(accountStore, nil)
        hsm, err := pseudohsm.New(keyDirPath)
        if err != nil {
                return nil, err
@@ -408,7 +411,8 @@ func MockTxsP2PKH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int)
 }
 
 func MockTxsP2SH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) {
-       accountManager := account.NewManager(testDB, nil)
+       accountStore := database.NewAccountStore(testDB)
+       accountManager := account.NewManager(accountStore, nil)
        hsm, err := pseudohsm.New(keyDirPath)
        if err != nil {
                return nil, err
@@ -455,7 +459,8 @@ func MockTxsP2SH(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int)
 }
 
 func MockTxsMultiSign(keyDirPath string, testDB dbm.DB, txNumber, otherAssetNum int) ([]*types.Tx, error) {
-       accountManager := account.NewManager(testDB, nil)
+       accountStore := database.NewAccountStore(testDB)
+       accountManager := account.NewManager(accountStore, nil)
        hsm, err := pseudohsm.New(keyDirPath)
        if err != nil {
                return nil, err