Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
483bd5fd
Unverified
Commit
483bd5fd
authored
8 years ago
by
Silas Davis
Browse files
Options
Downloads
Patches
Plain Diff
Fix mock test
parent
bae6d668
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/mock/mock_web_api_test.go
+24
-23
24 additions, 23 deletions
test/mock/mock_web_api_test.go
test/mock/pipe.go
+59
-27
59 additions, 27 deletions
test/mock/pipe.go
with
83 additions
and
50 deletions
test/mock/mock_web_api_test.go
+
24
−
23
View file @
483bd5fd
...
@@ -115,7 +115,7 @@ func (this *MockSuite) TestGetBlockchainInfo() {
...
@@ -115,7 +115,7 @@ func (this *MockSuite) TestGetBlockchainInfo() {
ret
:=
&
core_types
.
BlockchainInfo
{}
ret
:=
&
core_types
.
BlockchainInfo
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetBlockchainInfo
.
Output
)
this
.
Equal
(
this
.
testData
.
GetBlockchainInfo
.
Output
,
ret
)
}
}
func
(
this
*
MockSuite
)
TestGetChainId
()
{
func
(
this
*
MockSuite
)
TestGetChainId
()
{
...
@@ -123,7 +123,7 @@ func (this *MockSuite) TestGetChainId() {
...
@@ -123,7 +123,7 @@ func (this *MockSuite) TestGetChainId() {
ret
:=
&
core_types
.
ChainId
{}
ret
:=
&
core_types
.
ChainId
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetChainId
.
Output
)
this
.
Equal
(
this
.
testData
.
GetChainId
.
Output
,
ret
)
}
}
func
(
this
*
MockSuite
)
TestGetGenesisHash
()
{
func
(
this
*
MockSuite
)
TestGetGenesisHash
()
{
...
@@ -131,7 +131,7 @@ func (this *MockSuite) TestGetGenesisHash() {
...
@@ -131,7 +131,7 @@ func (this *MockSuite) TestGetGenesisHash() {
ret
:=
&
core_types
.
GenesisHash
{}
ret
:=
&
core_types
.
GenesisHash
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetGenesisHash
.
Output
)
this
.
Equal
(
this
.
testData
.
GetGenesisHash
.
Output
,
ret
)
}
}
func
(
this
*
MockSuite
)
TestLatestBlockHeight
()
{
func
(
this
*
MockSuite
)
TestLatestBlockHeight
()
{
...
@@ -139,7 +139,7 @@ func (this *MockSuite) TestLatestBlockHeight() {
...
@@ -139,7 +139,7 @@ func (this *MockSuite) TestLatestBlockHeight() {
ret
:=
&
core_types
.
LatestBlockHeight
{}
ret
:=
&
core_types
.
LatestBlockHeight
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetLatestBlockHeight
.
Output
)
this
.
Equal
(
this
.
testData
.
GetLatestBlockHeight
.
Output
,
ret
)
}
}
func
(
this
*
MockSuite
)
TestBlocks
()
{
func
(
this
*
MockSuite
)
TestBlocks
()
{
...
@@ -147,27 +147,28 @@ func (this *MockSuite) TestBlocks() {
...
@@ -147,27 +147,28 @@ func (this *MockSuite) TestBlocks() {
ret
:=
&
core_types
.
Blocks
{}
ret
:=
&
core_types
.
Blocks
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetBlocks
.
Output
)
this
.
Equal
(
this
.
testData
.
GetBlocks
.
Output
,
ret
)
}
}
// ********************************************* Consensus *********************************************
// ********************************************* Consensus *********************************************
func
(
this
*
MockSuite
)
TestGetConsensusState
()
{
// TODO: re-enable these when implemented
resp
:=
this
.
get
(
"/consensus"
)
//func (this *MockSuite) TestGetConsensusState() {
ret
:=
&
core_types
.
ConsensusState
{}
// resp := this.get("/consensus")
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
// ret := &core_types.ConsensusState{}
this
.
NoError
(
errD
)
// errD := this.codec.Decode(ret, resp.Body)
ret
.
StartTime
=
""
// this.NoError(errD)
this
.
Equal
(
ret
,
this
.
testData
.
GetConsensusState
.
Output
)
// ret.StartTime = ""
}
// this.Equal(this.testData.GetConsensusState.Output, ret)
//}
func
(
this
*
MockSuite
)
TestGetValidators
()
{
//
resp
:=
this
.
get
(
"/consensus/validators"
)
//func (this *MockSuite) TestGetValidators() {
ret
:=
&
core_types
.
ValidatorList
{}
// resp := this.get("/consensus/validators")
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
// ret := &core_types.ValidatorList{}
this
.
NoError
(
errD
)
// errD := this.codec.Decode(ret, resp.Body)
this
.
Equal
(
ret
,
this
.
testData
.
GetValidators
.
Output
)
// this.NoError(errD)
}
// this.Equal(this.testData.GetValidators.Output, ret)
//}
// ********************************************* NameReg *********************************************
// ********************************************* NameReg *********************************************
...
@@ -176,7 +177,7 @@ func (this *MockSuite) TestGetNameRegEntry() {
...
@@ -176,7 +177,7 @@ func (this *MockSuite) TestGetNameRegEntry() {
ret
:=
&
core_types
.
NameRegEntry
{}
ret
:=
&
core_types
.
NameRegEntry
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetNameRegEntry
.
Output
)
this
.
Equal
(
this
.
testData
.
GetNameRegEntry
.
Output
,
ret
)
}
}
func
(
this
*
MockSuite
)
TestGetNameRegEntries
()
{
func
(
this
*
MockSuite
)
TestGetNameRegEntries
()
{
...
@@ -184,7 +185,7 @@ func (this *MockSuite) TestGetNameRegEntries() {
...
@@ -184,7 +185,7 @@ func (this *MockSuite) TestGetNameRegEntries() {
ret
:=
&
core_types
.
ResultListNames
{}
ret
:=
&
core_types
.
ResultListNames
{}
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
errD
:=
this
.
codec
.
Decode
(
ret
,
resp
.
Body
)
this
.
NoError
(
errD
)
this
.
NoError
(
errD
)
this
.
Equal
(
ret
,
this
.
testData
.
GetNameRegEntries
.
Output
)
this
.
Equal
(
this
.
testData
.
GetNameRegEntries
.
Output
,
ret
)
}
}
// ********************************************* Network *********************************************
// ********************************************* Network *********************************************
...
...
This diff is collapsed.
Click to expand it.
test/mock/pipe.go
+
59
−
27
View file @
483bd5fd
...
@@ -8,19 +8,24 @@ import (
...
@@ -8,19 +8,24 @@ import (
definitions
"github.com/eris-ltd/eris-db/definitions"
definitions
"github.com/eris-ltd/eris-db/definitions"
event
"github.com/eris-ltd/eris-db/event"
event
"github.com/eris-ltd/eris-db/event"
blockchain_types
"github.com/eris-ltd/eris-db/blockchain/types"
consensus_types
"github.com/eris-ltd/eris-db/consensus/types"
manager_types
"github.com/eris-ltd/eris-db/manager/types"
manager_types
"github.com/eris-ltd/eris-db/manager/types"
td
"github.com/eris-ltd/eris-db/test/testdata/testdata"
td
"github.com/eris-ltd/eris-db/test/testdata/testdata"
"github.com/eris-ltd/eris-db/txs"
"github.com/eris-ltd/eris-db/txs"
"github.com/tendermint/go-crypto"
"github.com/tendermint/go-p2p"
mintTypes
"github.com/tendermint/tendermint/types"
mintTypes
"github.com/tendermint/tendermint/types"
tmsp_types
"github.com/tendermint/tmsp/types"
)
)
// Base struct.
// Base struct.
type
MockPipe
struct
{
type
MockPipe
struct
{
testData
*
td
.
TestData
testData
*
td
.
TestData
accounts
definitions
.
Accounts
accounts
definitions
.
Accounts
blockchain
definition
s
.
Blockchain
blockchain
blockchain_type
s
.
Blockchain
consensus
definition
s
.
Consensus
consensus
consensus_type
s
.
Consensus
events
event
.
EventEmitter
events
event
.
EventEmitter
namereg
definitions
.
NameReg
namereg
definitions
.
NameReg
net
definitions
.
Net
net
definitions
.
Net
...
@@ -57,11 +62,11 @@ func (this *MockPipe) Accounts() definitions.Accounts {
...
@@ -57,11 +62,11 @@ func (this *MockPipe) Accounts() definitions.Accounts {
return
this
.
accounts
return
this
.
accounts
}
}
func
(
this
*
MockPipe
)
Blockchain
()
definition
s
.
Blockchain
{
func
(
this
*
MockPipe
)
Blockchain
()
blockchain_type
s
.
Blockchain
{
return
this
.
blockchain
return
this
.
blockchain
}
}
func
(
this
*
MockPipe
)
Consensus
()
definition
s
.
Consensus
{
func
(
this
*
MockPipe
)
Consensus
()
consensus_type
s
.
Consensus
{
return
this
.
consensus
return
this
.
consensus
}
}
...
@@ -86,12 +91,21 @@ func (this *MockPipe) GetApplication() manager_types.Application {
...
@@ -86,12 +91,21 @@ func (this *MockPipe) GetApplication() manager_types.Application {
return
nil
return
nil
}
}
func
(
this
*
MockPipe
)
SetConsensus
Engine
(
_
definition
s
.
Consensus
)
error
{
func
(
this
*
MockPipe
)
SetConsensus
(
_
consensus_type
s
.
Consensus
)
error
{
// TODO: [ben] mock consensus engine
// TODO: [ben] mock consensus engine
return
nil
return
nil
}
}
func
(
this
*
MockPipe
)
GetConsensusEngine
()
definitions
.
Consensus
{
func
(
this
*
MockPipe
)
GetConsensus
()
consensus_types
.
Consensus
{
return
nil
}
func
(
this
*
MockPipe
)
SetBlockchain
(
_
blockchain_types
.
Blockchain
)
error
{
// TODO: [ben] mock consensus engine
return
nil
}
func
(
this
*
MockPipe
)
GetBlockchain
()
blockchain_types
.
Blockchain
{
return
nil
return
nil
}
}
...
@@ -99,6 +113,10 @@ func (this *MockPipe) GetTendermintPipe() (definitions.TendermintPipe, error) {
...
@@ -99,6 +113,10 @@ func (this *MockPipe) GetTendermintPipe() (definitions.TendermintPipe, error) {
return
nil
,
fmt
.
Errorf
(
"Tendermint pipe is not supported by mocked pipe."
)
return
nil
,
fmt
.
Errorf
(
"Tendermint pipe is not supported by mocked pipe."
)
}
}
func
(
this
*
MockPipe
)
GenesisHash
()
[]
byte
{
return
this
.
testData
.
GetGenesisHash
.
Output
.
Hash
}
// Components
// Components
// Accounts
// Accounts
...
@@ -135,45 +153,59 @@ type blockchain struct {
...
@@ -135,45 +153,59 @@ type blockchain struct {
testData
*
td
.
TestData
testData
*
td
.
TestData
}
}
func
(
this
*
blockchain
)
Info
()
(
*
core_types
.
BlockchainInfo
,
error
)
{
func
(
this
*
blockchain
)
ChainId
()
string
{
return
this
.
testData
.
GetBlockchainInfo
.
Output
,
nil
return
this
.
testData
.
GetChainId
.
Output
.
ChainId
}
func
(
this
*
blockchain
)
Height
()
int
{
return
this
.
testData
.
GetLatestBlockHeight
.
Output
.
Height
}
}
func
(
this
*
blockchain
)
ChainId
()
(
string
,
error
)
{
func
(
this
*
blockchain
)
Block
(
height
int
)
*
mintTypes
.
Block
{
return
this
.
testData
.
Get
ChainId
.
Output
.
ChainId
,
nil
return
this
.
testData
.
Get
Block
.
Output
}
}
func
(
this
*
blockchain
)
GenesisHash
()
([]
byte
,
error
)
{
func
(
this
*
blockchain
)
BlockMeta
(
height
int
)
*
mintTypes
.
BlockMeta
{
return
this
.
testData
.
GetGenesisHash
.
Output
.
Hash
,
nil
return
&
mintTypes
.
BlockMeta
{}
}
}
func
(
this
*
blockchain
)
LatestBlockHeight
()
(
int
,
error
)
{
// Consensus
return
this
.
testData
.
GetLatestBlockHeight
.
Output
.
Height
,
nil
type
consensus
struct
{
testData
*
td
.
TestData
}
}
func
(
this
*
blockchain
)
LatestBlock
()
(
*
mintTypes
.
Block
,
error
)
{
func
(
cons
*
consensus
)
BroadcastTransaction
(
transaction
[]
byte
,
return
this
.
testData
.
GetLatestBlock
.
Output
,
nil
callback
func
(
*
tmsp_types
.
Response
))
error
{
return
nil
}
}
func
(
this
*
blockchain
)
Blocks
([]
*
event
.
FilterData
)
(
*
core_types
.
Blocks
,
error
)
{
func
(
cons
*
consensus
)
IsListening
()
bool
{
return
t
his
.
testData
.
GetBlocks
.
Output
,
nil
return
t
rue
}
}
func
(
this
*
blockchain
)
Block
(
height
int
)
(
*
mintTypes
.
Block
,
error
)
{
func
(
cons
*
consensus
)
Listeners
()
[]
p2p
.
Listener
{
return
th
is
.
te
stData
.
GetBlock
.
Output
,
nil
return
make
([]
p2p
.
L
iste
ner
,
0
)
}
}
// Consensus
func
(
cons
*
consensus
)
NodeInfo
()
*
p2p
.
NodeInfo
{
type
consensus
struct
{
return
&
p2p
.
NodeInfo
{}
testData
*
td
.
TestData
}
}
func
(
thi
s
*
consensus
)
State
()
(
*
core_types
.
ConsensusState
,
error
)
{
func
(
con
s
*
consensus
)
Peers
()
[]
consensus_types
.
Peer
{
return
this
.
testData
.
GetConsensusState
.
Output
,
nil
return
make
([]
consensus_types
.
Peer
,
0
)
}
}
func
(
this
*
consensus
)
Validators
()
(
*
core_types
.
ValidatorList
,
error
)
{
func
(
cons
*
consensus
)
PublicValidatorKey
()
crypto
.
PubKey
{
return
this
.
testData
.
GetValidators
.
Output
,
nil
return
crypto
.
PubKeyEd25519
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
}
}
func
(
cons
*
consensus
)
Events
()
event
.
EventEmitter
{
return
nil
}
}
// Events
// Events
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment