Commit 74c65969 authored by vipwzw's avatar vipwzw

auto ci

parent 80eddb34
...@@ -627,7 +627,7 @@ func (client *client) CreateBlock() { ...@@ -627,7 +627,7 @@ func (client *client) CreateBlock() {
plog.Info("Parachain process block", "lastBlockSeq", lastSeq, "curSeq", currSeq, plog.Info("Parachain process block", "lastBlockSeq", lastSeq, "curSeq", currSeq,
"currSeqMainHeight", lastSeqMainHeight, "currSeqMainHash", common.ToHex(lastSeqMainHash), "currSeqMainHeight", lastSeqMainHeight, "currSeqMainHash", common.ToHex(lastSeqMainHash),
"lastBlockMainHeight", lastBlockMainHeight, "lastBlockMainHash", common.ToHex(lastBlockMainHash),"seqTy",seqTy) "lastBlockMainHeight", lastBlockMainHeight, "lastBlockMainHash", common.ToHex(lastBlockMainHash), "seqTy", seqTy)
if seqTy == delAct { if seqTy == delAct {
if len(txs) == 0 { if len(txs) == 0 {
......
...@@ -6,6 +6,7 @@ package para ...@@ -6,6 +6,7 @@ package para
import ( import (
"testing" "testing"
"github.com/33cn/chain33/blockchain" "github.com/33cn/chain33/blockchain"
"github.com/33cn/chain33/common/log" "github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/executor" "github.com/33cn/chain33/executor"
...@@ -14,18 +15,17 @@ import ( ...@@ -14,18 +15,17 @@ import (
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
//"github.com/33cn/plugin/plugin/dapp/paracross/rpc" //"github.com/33cn/plugin/plugin/dapp/paracross/rpc"
"time"
"github.com/33cn/chain33/queue" "github.com/33cn/chain33/queue"
"github.com/33cn/chain33/store" "github.com/33cn/chain33/store"
_ "github.com/33cn/chain33/system" _ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
typesmocks "github.com/33cn/chain33/types/mocks" typesmocks "github.com/33cn/chain33/types/mocks"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types" pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"time"
) )
func init() { func init() {
//types.Init("user.p.para.", nil) //types.Init("user.p.para.", nil)
log.SetLogLevel("debug") log.SetLogLevel("debug")
...@@ -44,7 +44,6 @@ type suiteParaClient struct { ...@@ -44,7 +44,6 @@ type suiteParaClient struct {
network *p2p.P2p network *p2p.P2p
} }
func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) { func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) {
q := queue.New("channel") q := queue.New("channel")
s.q = q s.q = q
...@@ -59,8 +58,8 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) ...@@ -59,8 +58,8 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s.store = store.New(cfg.Store, sub.Store) s.store = store.New(cfg.Store, sub.Store)
s.store.SetQueueClient(q.Client()) s.store.SetQueueClient(q.Client())
cfg.Consensus.StartHeight=0 cfg.Consensus.StartHeight = 0
cfg.Consensus.EmptyBlockInterval=1 cfg.Consensus.EmptyBlockInterval = 1
s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client) s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client)
s.grpcCli = &typesmocks.Chain33Client{} s.grpcCli = &typesmocks.Chain33Client{}
blockHash := &types.BlockSequence{ blockHash := &types.BlockSequence{
...@@ -70,34 +69,33 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) ...@@ -70,34 +69,33 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
blockSeqs := &types.BlockSequences{Items: []*types.BlockSequence{blockHash}} blockSeqs := &types.BlockSequences{Items: []*types.BlockSequence{blockHash}}
s.grpcCli.On("GetBlockSequences", mock.Anything, mock.Anything).Return(blockSeqs, nil) s.grpcCli.On("GetBlockSequences", mock.Anything, mock.Anything).Return(blockSeqs, nil)
block := &types.Block{Height:0} block := &types.Block{Height: 0}
blockDetail := &types.BlockDetail{Block: block} blockDetail := &types.BlockDetail{Block: block}
blockDetails := &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}} blockDetails := &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}}
s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once() s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once()
block = &types.Block{Height:6,BlockTime:8888888888} block = &types.Block{Height: 6, BlockTime: 8888888888}
blockDetail = &types.BlockDetail{Block: block} blockDetail = &types.BlockDetail{Block: block}
blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}} blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}}
s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once() s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once()
block = &types.Block{Height:0} block = &types.Block{Height: 0}
blockDetail = &types.BlockDetail{Block: block} blockDetail = &types.BlockDetail{Block: block}
blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}} blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}}
s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once() s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil).Once()
block = &types.Block{Height:0} block = &types.Block{Height: 0}
blockDetail = &types.BlockDetail{Block: block} blockDetail = &types.BlockDetail{Block: block}
blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}} blockDetails = &types.BlockDetails{Items: []*types.BlockDetail{blockDetail}}
s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil) s.grpcCli.On("GetBlockByHashes", mock.Anything, mock.Anything).Return(blockDetails, nil)
seq := &types.Int64{Data:1} seq := &types.Int64{Data: 1}
s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil).Once() s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil).Once()
seq = &types.Int64{Data:2} seq = &types.Int64{Data: 2}
s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil).Once() s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil).Once()
seq = &types.Int64{Data:3} seq = &types.Int64{Data: 3}
s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil) s.grpcCli.On("GetLastBlockSequence", mock.Anything, mock.Anything).Return(seq, nil)
seq = &types.Int64{Data:1} seq = &types.Int64{Data: 1}
s.grpcCli.On("GetSequenceByHash", mock.Anything, mock.Anything).Return(seq, nil) s.grpcCli.On("GetSequenceByHash", mock.Anything, mock.Anything).Return(seq, nil)
reply := &types.Reply{IsOk: true} reply := &types.Reply{IsOk: true}
s.grpcCli.On("IsSync", mock.Anything, mock.Anything).Return(reply, nil) s.grpcCli.On("IsSync", mock.Anything, mock.Anything).Return(reply, nil)
result := &pt.ParacrossStatus{Height: -1} result := &pt.ParacrossStatus{Height: -1}
...@@ -115,17 +113,12 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) ...@@ -115,17 +113,12 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s.network = p2p.New(cfg.P2P) s.network = p2p.New(cfg.P2P)
s.network.SetQueueClient(q.Client()) s.network.SetQueueClient(q.Client())
} }
func (s *suiteParaClient) SetupSuite() { func (s *suiteParaClient) SetupSuite() {
s.initEnv(types.InitCfg("../../../plugin/dapp/paracross/cmd/build/chain33.para.test.toml")) s.initEnv(types.InitCfg("../../../plugin/dapp/paracross/cmd/build/chain33.para.test.toml"))
} }
func TestRunSuiteParaClient(t *testing.T) { func TestRunSuiteParaClient(t *testing.T) {
log := new(suiteParaClient) log := new(suiteParaClient)
suite.Run(t, log) suite.Run(t, log)
...@@ -143,9 +136,6 @@ func (s *suiteParaClient) TearDownSuite() { ...@@ -143,9 +136,6 @@ func (s *suiteParaClient) TearDownSuite() {
} }
//func newMockParaNode() *testnode.Chain33Mock { //func newMockParaNode() *testnode.Chain33Mock {
// //_, sub := testnode.GetDefaultConfig() // //_, sub := testnode.GetDefaultConfig()
// //cfg.Consensus.Minerstart = false // //cfg.Consensus.Minerstart = false
...@@ -174,6 +164,3 @@ func (s *suiteParaClient) TearDownSuite() { ...@@ -174,6 +164,3 @@ func (s *suiteParaClient) TearDownSuite() {
// cs.switchHashMatchedBlock(&currSeq,&preMainBlockHash) // cs.switchHashMatchedBlock(&currSeq,&preMainBlockHash)
// assert.Equal(t,1,currSeq) // assert.Equal(t,1,currSeq)
//} //}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment