X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=blobdiff_plain;f=test%2Futil.go;h=44748931dc8fa8afe3c715f6862acb995d0c10cb;hp=b534a42abe632ddefb782c2d922604028a5df4ef;hb=1337be95f74a1d2a1a7316737efde413f29bcb2f;hpb=a7c5e4f0b8dab4ffe44a5e20fe5e1e30db14026c diff --git a/test/util.go b/test/util.go index b534a42a..44748931 100644 --- a/test/util.go +++ b/test/util.go @@ -4,20 +4,19 @@ 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/common" - "github.com/vapor/config" - "github.com/vapor/consensus" - "github.com/vapor/crypto/ed25519/chainkd" - "github.com/vapor/database/leveldb" - "github.com/vapor/protocol" - "github.com/vapor/protocol/bc" - "github.com/vapor/protocol/bc/types" - "github.com/vapor/protocol/vm" + "github.com/bytom/vapor/account" + "github.com/bytom/vapor/blockchain/pseudohsm" + "github.com/bytom/vapor/blockchain/txbuilder" + "github.com/bytom/vapor/config" + "github.com/bytom/vapor/consensus" + "github.com/bytom/vapor/crypto/ed25519/chainkd" + "github.com/bytom/vapor/database" + dbm "github.com/bytom/vapor/database/leveldb" + "github.com/bytom/vapor/event" + "github.com/bytom/vapor/protocol" + "github.com/bytom/vapor/protocol/bc" + "github.com/bytom/vapor/protocol/bc/types" + "github.com/bytom/vapor/protocol/vm" ) const ( @@ -26,24 +25,12 @@ const ( ) // MockChain mock chain with genesis block -func MockChain(testDB dbm.DB) (*protocol.Chain, *leveldb.Store, *protocol.TxPool, error) { +func MockChain(testDB dbm.DB) (*protocol.Chain, *database.Store, *protocol.TxPool, error) { config.CommonConfig = config.DefaultConfig() - consensus.SoloNetParams.Signer = "78673764e0ba91a4c5ba9ec0c8c23c69e3d73bf27970e05e0a977e81e13bde475264d3b177a96646bc0ce517ae7fd63504c183ab6d330dea184331a4cf5912d5" - config.CommonConfig.Consensus.Dpos.SelfVoteSigners = append(config.CommonConfig.Consensus.Dpos.SelfVoteSigners, "vsm1qkm743xmgnvh84pmjchq2s4tnfpgu9ae2f9slep") - config.CommonConfig.Consensus.Dpos.XPrv = "a8e281b615809046698fb0b0f2804a36d824d48fa443350f10f1b80649d39e5f1e85cf9855548915e36137345910606cbc8e7dd8497c831dce899ee6ac112445" - for _, v := range config.CommonConfig.Consensus.Dpos.SelfVoteSigners { - address, err := common.DecodeAddress(v, &consensus.SoloNetParams) - if err != nil { - return nil, nil, nil, err - } - config.CommonConfig.Consensus.Dpos.Signers = append(config.CommonConfig.Consensus.Dpos.Signers, address) - } - - store := leveldb.NewStore(testDB) - txPool := protocol.NewTxPool(store) - chain, err := protocol.NewChain(store, txPool) - consensus.ActiveNetParams.Signer = "78673764e0ba91a4c5ba9ec0c8c23c69e3d73bf27970e05e0a977e81e13bde475264d3b177a96646bc0ce517ae7fd63504c183ab6d330dea184331a4cf5912d5" - setAuthoritys(chain) + store := database.NewStore(testDB) + dispatcher := event.NewDispatcher() + txPool := protocol.NewTxPool(store, dispatcher) + chain, err := protocol.NewChain(store, txPool, dispatcher) return chain, store, txPool, err } @@ -74,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 }