"testing"
"time"
- dbm "github.com/tendermint/tmlibs/db"
-
"github.com/vapor/account"
"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/leveldb"
+ "github.com/vapor/database"
+ dbm "github.com/vapor/database/leveldb"
"github.com/vapor/database/storage"
- "github.com/vapor/mining"
+ "github.com/vapor/event"
+ "github.com/vapor/proposal"
"github.com/vapor/protocol"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
// 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
return nil, nil, nil, err
}
- store := leveldb.NewStore(testDB)
- txPool := protocol.NewTxPool(store)
- chain, err := protocol.NewChain(store, txPool)
+ config.CommonConfig = config.DefaultConfig()
+ store := database.NewStore(testDB)
+ dispatcher := event.NewDispatcher()
+ txPool := protocol.NewTxPool(store, dispatcher)
+ chain, err := protocol.NewChain(store, txPool, dispatcher)
if err != nil {
return nil, nil, nil, err
}
}
}
- block, err := mining.NewBlockTemplate(chain, txPool, nil)
+ block, err := proposal.NewBlockTemplate(chain, txPool, nil, uint64(time.Now().UnixNano()/1e6))
if err != nil {
return err
}
}
func processNewTxch(txPool *protocol.TxPool) {
- newTxCh := txPool.GetMsgCh()
- for tx := range newTxCh {
- if tx == nil {
- }
- }
}
func MockSimpleUtxo(index uint64, assetID *bc.AssetID, amount uint64, ctrlProg *account.CtrlProgram) *account.UTXO {
}
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
}
func SetUtxoView(db dbm.DB, view *state.UtxoViewpoint) error {
batch := db.NewBatch()
- if err := leveldb.SaveUtxoView(batch, view); err != nil {
+ if err := database.SaveUtxoView(batch, view); err != nil {
return err
}
batch.Write()
//-------------------------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
}
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
}
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