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
6a778070
Commit
6a778070
authored
Feb 03, 2019
by
mdj33
Committed by
vipwzw
Feb 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ut cov
parent
a260bdd4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
14 deletions
+38
-14
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+38
-14
No files found.
plugin/consensus/para/paratxrequest_test.go
View file @
6a778070
...
@@ -40,9 +40,11 @@ type suiteParaClient struct {
...
@@ -40,9 +40,11 @@ type suiteParaClient struct {
store
queue
.
Module
store
queue
.
Module
mem
queue
.
Module
mem
queue
.
Module
network
*
p2p
.
P2p
network
*
p2p
.
P2p
mainBlockList
[]
*
types
.
Block
}
}
func
(
s
*
suiteParaClient
)
initEnv
(
cfg
*
types
.
Config
,
sub
*
types
.
ConfigSubModule
)
{
func
(
s
*
suiteParaClient
)
initEnv
(
cfg
*
types
.
Config
,
sub
*
types
.
ConfigSubModule
)
{
s
.
createTempBlock
()
q
:=
queue
.
New
(
"channel"
)
q
:=
queue
.
New
(
"channel"
)
s
.
q
=
q
s
.
q
=
q
//api, _ = client.New(q.Client(), nil)
//api, _ = client.New(q.Client(), nil)
...
@@ -92,24 +94,29 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
...
@@ -92,24 +94,29 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s
.
createBlock
()
s
.
createBlock
()
}
}
func
(
s
*
suiteParaClient
)
createBlockMock
()
{
func
(
s
*
suiteParaClient
)
createTempBlock
(){
var
i
,
hashdata
int64
var
parentHash
[]
byte
for
i
=
0
;
i
<
3
;
i
++
{
for
i
:=
0
;
i
<
3
;
i
++
{
hashdata
=
i
if
i
>
0
{
hashdata
=
i
-
1
}
block
:=
&
types
.
Block
{
block
:=
&
types
.
Block
{
Height
:
i
,
Height
:
i
nt64
(
i
)
,
ParentHash
:
[]
byte
(
string
(
hashdata
))
,
ParentHash
:
parentHash
,
}
}
hash
:=
block
.
HashByForkHeight
(
1
)
s
.
mainBlockList
=
append
(
s
.
mainBlockList
,
block
)
parentHash
=
hash
}
}
func
(
s
*
suiteParaClient
)
createBlockMock
()
{
var
i
int64
for
i
=
0
;
i
<
3
;
i
++
{
blockSeq
:=
&
types
.
BlockSeq
{
blockSeq
:=
&
types
.
BlockSeq
{
Seq
:
&
types
.
BlockSequence
{
Seq
:
&
types
.
BlockSequence
{
Hash
:
[]
byte
(
string
(
i
)
),
Hash
:
s
.
mainBlockList
[
i
]
.
HashByForkHeight
(
1
),
Type
:
1
,
Type
:
1
,
},
},
Detail
:
&
types
.
BlockDetail
{
Block
:
block
},
Detail
:
&
types
.
BlockDetail
{
Block
:
s
.
mainBlockList
[
i
]
},
}
}
s
.
grpcCli
.
On
(
"GetBlockBySeq"
,
mock
.
Anything
,
&
types
.
Int64
{
Data
:
i
})
.
Return
(
blockSeq
,
nil
)
s
.
grpcCli
.
On
(
"GetBlockBySeq"
,
mock
.
Anything
,
&
types
.
Int64
{
Data
:
i
})
.
Return
(
blockSeq
,
nil
)
...
@@ -120,9 +127,10 @@ func (s *suiteParaClient) createBlockMock() {
...
@@ -120,9 +127,10 @@ func (s *suiteParaClient) createBlockMock() {
Height
:
3
,
Height
:
3
,
ParentHash
:
[]
byte
(
string
(
1
)),
ParentHash
:
[]
byte
(
string
(
1
)),
}
}
hash
:=
block3
.
HashByForkHeight
(
1
)
blockSeq3
:=
&
types
.
BlockSeq
{
blockSeq3
:=
&
types
.
BlockSeq
{
Seq
:
&
types
.
BlockSequence
{
Seq
:
&
types
.
BlockSequence
{
Hash
:
[]
byte
(
string
(
3
))
,
Hash
:
hash
,
Type
:
1
,
Type
:
1
,
},
},
Detail
:
&
types
.
BlockDetail
{
Block
:
block3
},
Detail
:
&
types
.
BlockDetail
{
Block
:
block3
},
...
@@ -154,7 +162,7 @@ func (s *suiteParaClient) createBlock() {
...
@@ -154,7 +162,7 @@ func (s *suiteParaClient) createBlock() {
plog
.
Error
(
"para test"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"para test"
,
"err"
,
err
.
Error
())
}
}
plog
.
Info
(
"para test---------1"
,
"last height"
,
lastBlock
.
Height
)
plog
.
Info
(
"para test---------1"
,
"last height"
,
lastBlock
.
Height
)
s
.
para
.
createBlock
(
lastBlock
,
nil
,
i
,
get
MainBlock
(
i
+
1
,
lastBlock
.
BlockTime
+
1
))
s
.
para
.
createBlock
(
lastBlock
,
nil
,
i
,
s
.
getPara
MainBlock
(
i
+
1
,
lastBlock
.
BlockTime
+
1
))
}
}
}
}
...
@@ -178,3 +186,18 @@ func (s *suiteParaClient) TearDownSuite() {
...
@@ -178,3 +186,18 @@ func (s *suiteParaClient) TearDownSuite() {
s
.
q
.
Close
()
s
.
q
.
Close
()
}
}
func
(
s
*
suiteParaClient
)
getParaMainBlock
(
height
int64
,
BlockTime
int64
)
*
types
.
BlockSeq
{
return
&
types
.
BlockSeq
{
Num
:
height
,
Seq
:
&
types
.
BlockSequence
{
Hash
:
s
.
mainBlockList
[
height
-
1
]
.
HashByForkHeight
(
1
),
Type
:
addAct
},
Detail
:
&
types
.
BlockDetail
{
Block
:
&
types
.
Block
{
ParentHash
:
s
.
mainBlockList
[
height
-
1
]
.
ParentHash
,
Height
:
height
,
BlockTime
:
BlockTime
,
},
},
}
}
\ No newline at end of file
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