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
12ce134f
Commit
12ce134f
authored
May 23, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
5bd7a99c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
para_test.go
plugin/consensus/para/para_test.go
+22
-23
No files found.
plugin/consensus/para/para_test.go
View file @
12ce134f
...
@@ -13,18 +13,17 @@ import (
...
@@ -13,18 +13,17 @@ import (
"testing"
"testing"
"time"
"time"
apimocks
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/queue"
qmocks
"github.com/33cn/chain33/queue/mocks"
drivers
"github.com/33cn/chain33/system/consensus"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
typesmocks
"github.com/33cn/chain33/types/mocks"
typesmocks
"github.com/33cn/chain33/types/mocks"
paraexec
"github.com/33cn/plugin/plugin/dapp/paracross/executor"
paraexec
"github.com/33cn/plugin/plugin/dapp/paracross/executor"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/mock"
qmocks
"github.com/33cn/chain33/queue/mocks"
drivers
"github.com/33cn/chain33/system/consensus"
"github.com/33cn/chain33/queue"
apimocks
"github.com/33cn/chain33/client/mocks"
)
)
var
(
var
(
...
@@ -226,42 +225,42 @@ func TestAddMinerTx(t *testing.T) {
...
@@ -226,42 +225,42 @@ func TestAddMinerTx(t *testing.T) {
}
}
func
initBlock
(){
func
initBlock
()
{
println
(
"initblock"
)
println
(
"initblock"
)
}
}
func
TestGetLastBlockInfo
(
t
*
testing
.
T
){
func
TestGetLastBlockInfo
(
t
*
testing
.
T
)
{
para
:=
new
(
client
)
para
:=
new
(
client
)
baseCli
:=
drivers
.
NewBaseClient
(
&
types
.
Consensus
{
Name
:
"name"
})
baseCli
:=
drivers
.
NewBaseClient
(
&
types
.
Consensus
{
Name
:
"name"
})
para
.
BaseClient
=
baseCli
para
.
BaseClient
=
baseCli
grpcClient
:=
&
typesmocks
.
Chain33Client
{}
grpcClient
:=
&
typesmocks
.
Chain33Client
{}
qClient
:=
&
qmocks
.
Client
{}
qClient
:=
&
qmocks
.
Client
{}
para
.
InitClient
(
qClient
,
initBlock
)
para
.
InitClient
(
qClient
,
initBlock
)
api
:=
&
apimocks
.
QueueProtocolAPI
{}
api
:=
&
apimocks
.
QueueProtocolAPI
{}
para
.
SetAPI
(
api
)
para
.
SetAPI
(
api
)
para
.
grpcClient
=
grpcClient
para
.
grpcClient
=
grpcClient
block
:=&
types
.
Block
{
Height
:
0
}
block
:=
&
types
.
Block
{
Height
:
0
}
msg
:=
queue
.
NewMessage
(
0
,
""
,
1
,
block
)
msg
:=
queue
.
NewMessage
(
0
,
""
,
1
,
block
)
qClient
.
On
(
"NewMessage"
,
mock
.
Anything
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
msg
)
qClient
.
On
(
"NewMessage"
,
mock
.
Anything
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
msg
)
qClient
.
On
(
"Send"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
)
qClient
.
On
(
"Send"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
)
qClient
.
On
(
"Wait"
,
mock
.
Anything
)
.
Return
(
msg
,
nil
)
qClient
.
On
(
"Wait"
,
mock
.
Anything
)
.
Return
(
msg
,
nil
)
api
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
int64
(
1
)},
nil
)
api
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
int64
(
1
)},
nil
)
mainBlock
:=
&
types
.
Block
{
ParentHash
:
[]
byte
(
"phash"
)}
mainBlock
:=
&
types
.
Block
{
ParentHash
:
[]
byte
(
"phash"
)}
mainDetail
:=
&
types
.
BlockDetail
{
Block
:
mainBlock
}
mainDetail
:=
&
types
.
BlockDetail
{
Block
:
mainBlock
}
blocks
:=
&
types
.
BlockDetails
{}
blocks
:=
&
types
.
BlockDetails
{}
blocks
.
Items
=
append
(
blocks
.
Items
,
mainDetail
)
blocks
.
Items
=
append
(
blocks
.
Items
,
mainDetail
)
grpcClient
.
On
(
"GetBlockByHashes"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
blocks
,
nil
)
grpcClient
.
On
(
"GetBlockByHashes"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
blocks
,
nil
)
grpcClient
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
int64
(
10
)},
nil
)
grpcClient
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
int64
(
10
)},
nil
)
mainSeq
,
hash
,
err
:=
para
.
getLastBlockMainInfo
()
mainSeq
,
hash
,
err
:=
para
.
getLastBlockMainInfo
()
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
9
),
mainSeq
)
assert
.
Equal
(
t
,
int64
(
9
),
mainSeq
)
assert
.
Equal
(
t
,
[]
byte
(
"phash"
),
hash
)
assert
.
Equal
(
t
,
[]
byte
(
"phash"
),
hash
)
}
}
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