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
71d7abb0
Commit
71d7abb0
authored
Jul 29, 2019
by
mdj33
Committed by
vipwzw
Aug 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add UT
parent
32d57ba1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
6 deletions
+82
-6
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+3
-4
paracreate.go
plugin/consensus/para/paracreate.go
+7
-2
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+72
-0
No files found.
plugin/consensus/para/paracommitmsg.go
View file @
71d7abb0
...
...
@@ -289,9 +289,9 @@ func (client *commitMsgClient) getSendingTx(startHeight, endHeight int64) (*type
}
sendingMsgs
:=
status
[
:
count
]
plog
.
Info
(
"paracommitmsg sending"
,
"txhash"
,
common
.
ToHex
(
signTx
.
Hash
()),
"exec"
,
string
(
signTx
.
Execer
))
plog
.
Debug
(
"paracommitmsg sending"
,
"txhash"
,
common
.
ToHex
(
signTx
.
Hash
()),
"exec"
,
string
(
signTx
.
Execer
))
for
i
,
msg
:=
range
sendingMsgs
{
plog
.
Info
(
"paracommitmsg sending"
,
"idx"
,
i
,
"height"
,
msg
.
Height
,
"mainheight"
,
msg
.
MainBlockHeight
,
plog
.
Debug
(
"paracommitmsg sending"
,
"idx"
,
i
,
"height"
,
msg
.
Height
,
"mainheight"
,
msg
.
MainBlockHeight
,
"blockhash"
,
common
.
HashHex
(
msg
.
BlockHash
),
"mainHash"
,
common
.
HashHex
(
msg
.
MainBlockHash
),
"from"
,
client
.
paraClient
.
authAccount
)
}
...
...
@@ -606,7 +606,6 @@ out:
//如果主链的共识高度产生了回滚,本地链也需要重新检查共识高度
if
status
.
Height
<
atomic
.
LoadInt64
(
&
client
.
consensHeight
)
{
plog
.
Debug
(
"para getMainConsensusStatus rollback"
,
"height"
,
status
.
Height
,
"lastHeight"
,
atomic
.
LoadInt64
(
&
client
.
consensHeight
))
atomic
.
StoreInt64
(
&
client
.
consensHeight
,
status
.
Height
)
client
.
resetNotify
()
}
else
{
...
...
@@ -618,7 +617,7 @@ out:
if
selfStatus
!=
nil
{
selfHeight
=
selfStatus
.
Height
}
plog
.
Debug
(
"para consensusHeight"
,
"mainHeight"
,
status
.
Height
,
"selfHeight"
,
selfHeight
)
plog
.
Info
(
"para consensusHeight"
,
"mainHeight"
,
status
.
Height
,
"selfHeight"
,
selfHeight
)
}
}
...
...
plugin/consensus/para/paracreate.go
View file @
71d7abb0
...
...
@@ -389,7 +389,12 @@ func verifyMainBlocks(preMainBlockHash []byte, mainBlocks *pt.ParaTxDetails) err
if
err
!=
nil
{
return
err
}
pre
=
block
.
Header
.
Hash
if
block
.
Type
==
addAct
{
pre
=
block
.
Header
.
Hash
}
else
{
pre
=
block
.
Header
.
ParentHash
}
}
return
nil
}
...
...
@@ -525,7 +530,7 @@ out:
continue
}
plog
.
Info
(
"Parachain CreateBlock"
,
"curSeq"
,
currSeq
,
"count"
,
count
,
"lastSeqMainHash"
,
common
.
ToHex
(
lastSeqMainHash
))
plog
.
Debug
(
"Parachain CreateBlock"
,
"curSeq"
,
currSeq
,
"count"
,
count
,
"lastSeqMainHash"
,
common
.
ToHex
(
lastSeqMainHash
))
paraTxs
,
err
:=
client
.
RequestTx
(
currSeq
,
count
,
lastSeqMainHash
)
if
err
!=
nil
{
currSeq
,
lastSeqMainHash
,
err
=
client
.
processHashNotMatchError
(
currSeq
,
lastSeqMainHash
,
err
)
...
...
plugin/consensus/para/paratxrequest_test.go
View file @
71d7abb0
...
...
@@ -138,3 +138,75 @@ func TestSendCommitMsg(t *testing.T) {
close
(
commitCli
.
quit
)
}
func
TestVerifyMainBlocks
(
t
*
testing
.
T
)
{
hash0
:=
[]
byte
(
"0"
)
hash1
:=
[]
byte
(
"1"
)
hash2
:=
[]
byte
(
"2"
)
hash3
:=
[]
byte
(
"3"
)
//hash4 := []byte("4")
//hash5 := []byte("5")
hash6
:=
[]
byte
(
"6"
)
header1
:=
&
types
.
Header
{
ParentHash
:
hash0
,
Hash
:
hash1
,
}
block1
:=
&
pt
.
ParaTxDetail
{
Type
:
addAct
,
Header
:
header1
,
}
header2
:=
&
types
.
Header
{
ParentHash
:
hash1
,
Hash
:
hash2
,
}
block2
:=
&
pt
.
ParaTxDetail
{
Type
:
addAct
,
Header
:
header2
,
}
header3
:=
&
types
.
Header
{
ParentHash
:
hash2
,
Hash
:
hash3
,
}
block3
:=
&
pt
.
ParaTxDetail
{
Type
:
addAct
,
Header
:
header3
,
}
//del3
header4
:=
&
types
.
Header
{
ParentHash
:
hash2
,
Hash
:
hash3
,
}
block4
:=
&
pt
.
ParaTxDetail
{
Type
:
delAct
,
Header
:
header4
,
}
//del2
header5
:=
&
types
.
Header
{
ParentHash
:
hash1
,
Hash
:
hash2
,
}
block5
:=
&
pt
.
ParaTxDetail
{
Type
:
delAct
,
Header
:
header5
,
}
header6
:=
&
types
.
Header
{
ParentHash
:
hash1
,
Hash
:
hash6
,
}
block6
:=
&
pt
.
ParaTxDetail
{
Type
:
addAct
,
Header
:
header6
,
}
mainBlocks
:=
&
pt
.
ParaTxDetails
{
Items
:
[]
*
pt
.
ParaTxDetail
{
block1
,
block2
,
block3
,
block4
,
block5
,
block6
},
}
err
:=
verifyMainBlocks
(
hash0
,
mainBlocks
)
assert
.
Equal
(
t
,
nil
,
err
)
}
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