Commit db05d548 authored by mdj33's avatar mdj33 Committed by 33cn

add parachain test node

parent d0a8fa48
...@@ -77,8 +77,6 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu ...@@ -77,8 +77,6 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
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{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("paracross-ForkParacrossCommitTx")}).Return(&types.Int64{Data: 0}, nil).Once()
// GetBlockBySeq return error to stop create's for cycle to request tx // GetBlockBySeq return error to stop create's for cycle to request tx
s.grpcCli.On("GetBlockBySeq", mock.Anything, mock.Anything).Return(nil, errors.New("quit create")) s.grpcCli.On("GetBlockBySeq", mock.Anything, mock.Anything).Return(nil, errors.New("quit create"))
//data := &types.Int64{1} //data := &types.Int64{1}
...@@ -169,7 +167,7 @@ func (s *suiteParaCommitMsg) testRunRmvBlock() { ...@@ -169,7 +167,7 @@ func (s *suiteParaCommitMsg) testRunRmvBlock() {
} }
func TestRunSuiteParaCommitMsg(t *testing.T) { func testRunSuiteParaCommitMsg(t *testing.T) {
log := new(suiteParaCommitMsg) log := new(suiteParaCommitMsg)
suite.Run(t, log) suite.Run(t, log)
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package para
import (
"testing"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/types"
"github.com/stretchr/testify/assert"
node "github.com/33cn/plugin/plugin/dapp/paracross/testnode"
)
func TestParaNode(t *testing.T) {
authAcc := "1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF"
para := node.NewParaNode(nil, nil)
defer para.Close()
//通过rpc 发生信息
genesis := para.Main.GetGenesisAddress()
genesisKey := para.Main.GetGenesisKey()
block := para.Main.GetBlock(0)
acc := para.Main.GetAccount(block.StateHash, genesis)
assert.Equal(t, acc.Balance, 100000000*types.Coin)
//super acc
tx := util.CreateCoinsTx(genesisKey, para.Main.GetHotAddress(), 10*types.Coin)
para.Main.SendTx(tx)
para.Main.Wait()
block = para.Main.GetLastBlock()
acc = para.Main.GetAccount(block.StateHash, para.Main.GetHotAddress())
assert.Equal(t, acc.Balance, 10*types.Coin)
//auth acc
tx = util.CreateCoinsTx(genesisKey, authAcc, 10*types.Coin)
para.Main.SendTx(tx)
para.Main.Wait()
block = para.Main.GetLastBlock()
acc = para.Main.GetAccount(block.StateHash, authAcc)
assert.Equal(t, acc.Balance, 10*types.Coin)
//create manage config
tx = util.CreateManageTx(para.Main.GetHotKey(), "paracross-nodes-user.p.guodun.", "add", "1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF")
reply, err := para.Main.GetAPI().SendTx(tx)
assert.Nil(t, err)
detail, err := para.Main.WaitTx(reply.GetMsg())
assert.Nil(t, err)
assert.Equal(t, detail.Receipt.Ty, int32(types.ExecOk))
for i:=0;i<3;i++{
tx = util.CreateTxWithExecer(para.Para.GetGenesisKey(), "user.p.guodun.none")
para.Para.SendTxRPC(tx)
para.Para.WaitHeight(int64(i)+1)
}
}
...@@ -71,8 +71,6 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule) ...@@ -71,8 +71,6 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
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{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("paracross-ForkParacrossCommitTx")}).Return(&types.Int64{Data: 0}, nil).Once()
s.createBlockMock() s.createBlockMock()
reply := &types.Reply{IsOk: true} reply := &types.Reply{IsOk: true}
...@@ -174,7 +172,7 @@ func (s *suiteParaClient) SetupSuite() { ...@@ -174,7 +172,7 @@ 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)
} }
......
...@@ -99,15 +99,16 @@ startHeight=0 ...@@ -99,15 +99,16 @@ startHeight=0
#打包时间间隔,单位秒 #打包时间间隔,单位秒
writeBlockSeconds=2 writeBlockSeconds=2
#主链每隔几个没有相关交易的区块,平行链上打包空区块 #主链每隔几个没有相关交易的区块,平行链上打包空区块
emptyBlockInterval=50 emptyBlockInterval=2
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空 #验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount="" authAccount="1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF"
#等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2 #等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2
waitBlocks4CommitMsg=2 waitBlocks4CommitMsg=2
#云端主链节点切换后,平行链适配新主链节点block,回溯查找和自己记录的相同blockhash的深度 #云端主链节点切换后,平行链适配新主链节点block,回溯查找和自己记录的相同blockhash的深度
searchHashMatchedBlockDepth=10000 searchHashMatchedBlockDepth=10000
#创世地址额度 #创世地址额度
genesisAmount=100000000 genesisAmount=100000000
MainBlockHashForkHeight=1
[store] [store]
name="mavl" name="mavl"
......
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