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
16814194
Commit
16814194
authored
Sep 19, 2019
by
张振华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
9e17640c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
29 deletions
+49
-29
chain33.test.toml
plugin/consensus/dpos/chain33.test.toml
+5
-5
dpos_test.go
plugin/consensus/dpos/dpos_test.go
+18
-2
node_test.go
plugin/consensus/dpos/node_test.go
+26
-22
No files found.
plugin/consensus/dpos/chain33.test.toml
View file @
16814194
...
...
@@ -106,12 +106,12 @@ continueBlockNum=12
isValidator
=
true
rpcAddr
=
"http://localhost:9801"
#shuffleType为1表示使用固定出块顺序,为2表示使用vrf信息进行出块顺序洗牌
shuffleType
=
1
shuffleType
=
2
#是否更新topN,如果为true,根据下面几个配置项定期更新topN节点;如果为false,则一直使用初始配置的节点,不关注投票结果
whetherUpdateTopN
=
fals
e
blockNumToUpdateDelegate
=
200
00
registTopNHeightLimit
=
10
0
updateTopNHeightLimit
=
20
0
whetherUpdateTopN
=
tru
e
blockNumToUpdateDelegate
=
200
registTopNHeightLimit
=
10
updateTopNHeightLimit
=
20
[store]
name
=
"kvdb"
...
...
plugin/consensus/dpos/dpos_test.go
View file @
16814194
...
...
@@ -92,8 +92,7 @@ func DposPerf() {
defer
q
.
Close
()
defer
cs
.
Close
()
defer
p2p
.
Close
()
var
err
error
err
=
createConn2
()
err
:=
createConn2
()
for
err
!=
nil
{
err
=
createConn2
()
}
...
...
@@ -171,6 +170,12 @@ func DposPerf() {
dposClient
.
csState
.
SendCBTx
(
info
)
sendCBTx
(
dposClient
.
csState
,
info
)
time
.
Sleep
(
2
*
time
.
Second
)
fmt
.
Println
(
"=======start GetCBInfoByCircle!======="
)
//first time, not hit
dposClient
.
csState
.
GetCBInfoByCircle
(
task
.
Cycle
)
//second time, hit cache
dposClient
.
csState
.
GetCBInfoByCircle
(
task
.
Cycle
)
fmt
.
Println
(
"=======start SendRegistVrfMTx!======="
)
...
...
@@ -240,6 +245,17 @@ func DposPerf() {
}
else
{
fmt
.
Println
(
"QueryVrf ok,"
,
vrfInfo
.
Cycle
,
"|"
,
len
(
vrfInfo
.
M
),
"|"
,
len
(
vrfInfo
.
R
),
"|"
,
len
(
vrfInfo
.
P
))
}
fmt
.
Println
(
"=======start QueryVrfInfos!======="
)
var
pubkeys
[][]
byte
pubkeys
=
append
(
pubkeys
,
pubkey
)
vrfInfos
,
err
:=
dposClient
.
QueryVrfInfos
(
pubkeys
,
task
.
Cycle
)
if
err
!=
nil
||
vrfInfos
==
nil
{
fmt
.
Println
(
"QueryVrf failed"
)
}
else
{
fmt
.
Println
(
"QueryVrf ok,"
,
vrfInfos
[
0
]
.
Cycle
,
"|"
,
len
(
vrfInfos
[
0
]
.
M
),
"|"
,
len
(
vrfInfos
[
0
]
.
R
),
"|"
,
len
(
vrfInfos
[
0
]
.
P
))
}
time
.
Sleep
(
2
*
time
.
Second
)
fmt
.
Println
(
"=======start SendTopNRegistTx!======="
)
...
...
plugin/consensus/dpos/node_test.go
View file @
16814194
...
...
@@ -140,7 +140,7 @@ timeoutVoting=3000
timeoutWaitNotify=2000
createEmptyBlocks=false
createEmptyBlocksInterval=0
validatorNodes=["127.0.0.1:3665
7
"]
validatorNodes=["127.0.0.1:3665
6
"]
delegateNum=1
blockInterval=2
continueBlockNum=12
...
...
@@ -403,7 +403,7 @@ func Init() {
func
TestParallel
(
t
*
testing
.
T
)
{
Parallel
(
func
()
{
mutx
.
Lock
()
sum
+
=
1
sum
+
+
mutx
.
Unlock
()
},
func
()
{
...
...
@@ -455,7 +455,7 @@ func TestNode(t *testing.T) {
fmt
.
Println
(
"=======start TestNode!======="
)
Init
()
q1
,
chain1
,
s1
,
mem1
,
exec1
,
cs1
,
p2p1
:=
initEnvDpos1
(
"chain33.test1.toml"
)
q2
,
chain2
,
s2
,
mem2
,
exec2
,
cs2
,
p2p2
:=
initEnvDpos2
(
"chain33.test2.toml"
)
//
q2, chain2, s2, mem2, exec2, cs2, p2p2 := initEnvDpos2("chain33.test2.toml")
defer
clearTestData1
()
defer
chain1
.
Close
()
...
...
@@ -466,13 +466,13 @@ func TestNode(t *testing.T) {
//defer cs1.Close()
defer
p2p1
.
Close
()
defer
chain2
.
Close
()
defer
mem2
.
Close
()
defer
exec2
.
Close
()
defer
s2
.
Close
()
defer
q2
.
Close
()
//
defer chain2.Close()
//
defer mem2.Close()
//
defer exec2.Close()
//
defer s2.Close()
//
defer q2.Close()
//defer cs2.Close()
defer
p2p2
.
Close
()
//
defer p2p2.Close()
time
.
Sleep
(
2
*
time
.
Second
)
...
...
@@ -481,10 +481,10 @@ func TestNode(t *testing.T) {
_
,
_
,
err
=
createConn
(
"127.0.0.1:8802"
)
}
_
,
_
,
err
=
createConn
(
"127.0.0.1:8804"
)
for
err
!=
nil
{
_
,
_
,
err
=
createConn
(
"127.0.0.1:8804"
)
}
//
_, _, err = createConn("127.0.0.1:8804")
//
for err != nil {
//
_, _, err = createConn("127.0.0.1:8804")
//
}
fmt
.
Println
(
"node1 ip:"
,
cs1
.
(
*
Client
)
.
GetNode
()
.
IP
)
fmt
.
Println
(
"node1 id:"
,
cs1
.
(
*
Client
)
.
GetNode
()
.
ID
)
...
...
@@ -499,6 +499,19 @@ func TestNode(t *testing.T) {
}
require
.
Nil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
cs1
.
(
*
Client
)
.
GetNode
()
.
Version
=
"0.1"
require
.
NotNil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
cs1
.
(
*
Client
)
.
GetNode
()
.
Version
=
nodeinfo
.
Version
nodeinfo
.
Version
=
"0.1"
require
.
NotNil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
nodeinfo
.
Version
=
"1.1.0"
require
.
NotNil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
nodeinfo
.
Version
=
"0.0.0"
require
.
Nil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
nodeinfo
.
Version
=
cs1
.
(
*
Client
)
.
GetNode
()
.
Version
nodeinfo
.
Network
=
"chain33-Z2cgFi"
require
.
NotNil
(
t
,
cs1
.
(
*
Client
)
.
GetNode
()
.
CompatibleWith
(
nodeinfo
))
fmt
.
Println
(
"TestNodeCompatibleWith ok"
)
//time.Sleep(2 * time.Second)
...
...
@@ -532,15 +545,6 @@ func TestNode(t *testing.T) {
fmt
.
Println
(
"======= cs1 is not running======="
)
}
//cs2.(*Client).StopC()
if
cs2
.
(
*
Client
)
.
GetNode
()
.
IsRunning
()
{
fmt
.
Println
(
"=======cs2 is running======="
)
//cs2.(*Client).GetConsensusState().Stop()
//cs2.(*Client).GetNode().Stop()
}
else
{
fmt
.
Println
(
"======= cs2 is not running======="
)
}
fmt
.
Println
(
"=======testNode ok======="
)
}
...
...
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