Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
db05d548
Commit
db05d548
authored
Mar 26, 2019
by
mdj33
Committed by
33cn
Mar 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add parachain test node
parent
d0a8fa48
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
8 deletions
+64
-8
paracommitmsg_test.go
plugin/consensus/para/paracommitmsg_test.go
+1
-3
paranode_test.go
plugin/consensus/para/paranode_test.go
+59
-0
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+1
-3
cfg.go
plugin/dapp/paracross/testnode/cfg.go
+3
-2
No files found.
plugin/consensus/para/paracommitmsg_test.go
View file @
db05d548
...
@@ -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
T
estRunSuiteParaCommitMsg
(
t
*
testing
.
T
)
{
func
t
estRunSuiteParaCommitMsg
(
t
*
testing
.
T
)
{
log
:=
new
(
suiteParaCommitMsg
)
log
:=
new
(
suiteParaCommitMsg
)
suite
.
Run
(
t
,
log
)
suite
.
Run
(
t
,
log
)
}
}
...
...
plugin/consensus/para/paranode_test.go
0 → 100644
View file @
db05d548
// 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
)
}
}
plugin/consensus/para/paratxrequest_test.go
View file @
db05d548
...
@@ -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
T
estRunSuiteParaClient
(
t
*
testing
.
T
)
{
func
t
estRunSuiteParaClient
(
t
*
testing
.
T
)
{
log
:=
new
(
suiteParaClient
)
log
:=
new
(
suiteParaClient
)
suite
.
Run
(
t
,
log
)
suite
.
Run
(
t
,
log
)
}
}
...
...
plugin/dapp/paracross/testnode/cfg.go
View file @
db05d548
...
@@ -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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment