Skip to content
Snippets Groups Projects
Commit 6e0b3bc9 authored by Benjamin Bollen's avatar Benjamin Bollen Committed by GitHub
Browse files

Merge pull request #297 from silasdavis/net-info

Implemented rpc/v0 network info
parents a3f39a29 1c3dad0a
No related branches found
No related tags found
No related merge requests found
...@@ -2,3 +2,5 @@ ...@@ -2,3 +2,5 @@
vendor vendor
# Temporary / cached # Temporary / cached
*.swp *.swp
debug
.idea
...@@ -180,11 +180,12 @@ func (tendermint *Tendermint) Listeners() []p2p.Listener { ...@@ -180,11 +180,12 @@ func (tendermint *Tendermint) Listeners() []p2p.Listener {
return copyListeners return copyListeners
} }
func (tendermint *Tendermint) Peers() []consensus_types.Peer { func (tendermint *Tendermint) Peers() []*consensus_types.Peer {
peers := []consensus_types.Peer{} p2pPeers := tendermint.tmintNode.Switch().Peers().List()
for _, peer := range tendermint.tmintNode.Switch().Peers().List() { peers := make([]*consensus_types.Peer, 0)
peers = append(peers, consensus_types.Peer{ for _, peer := range p2pPeers {
NodeInfo: *peer.NodeInfo, peers = append(peers, &consensus_types.Peer{
NodeInfo: peer.NodeInfo,
IsOutbound: peer.IsOutbound(), IsOutbound: peer.IsOutbound(),
}) })
} }
......
...@@ -13,7 +13,7 @@ type ConsensusEngine interface { ...@@ -13,7 +13,7 @@ type ConsensusEngine interface {
IsListening() bool IsListening() bool
Listeners() []p2p.Listener Listeners() []p2p.Listener
NodeInfo() *p2p.NodeInfo NodeInfo() *p2p.NodeInfo
Peers() []Peer Peers() []*Peer
// Private Validator // Private Validator
PublicValidatorKey() crypto.PubKey PublicValidatorKey() crypto.PubKey
......
...@@ -3,6 +3,6 @@ package types ...@@ -3,6 +3,6 @@ package types
import "github.com/tendermint/go-p2p" import "github.com/tendermint/go-p2p"
type Peer struct { type Peer struct {
p2p.NodeInfo `json:"node_info"` NodeInfo *p2p.NodeInfo `json:"node_info"`
IsOutbound bool `json:"is_outbound"` IsOutbound bool `json:"is_outbound"`
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
package types package types
import ( import (
"github.com/tendermint/go-p2p" // NodeInfo (drop this!) // NodeInfo (drop this!)
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
account "github.com/eris-ltd/eris-db/account" account "github.com/eris-ltd/eris-db/account"
...@@ -105,15 +105,6 @@ type ( ...@@ -105,15 +105,6 @@ type (
// *********************************** Network *********************************** // *********************************** Network ***********************************
// NetworkInfo
NetworkInfo struct {
ClientVersion string `json:"client_version"`
Moniker string `json:"moniker"`
Listening bool `json:"listening"`
Listeners []string `json:"listeners"`
Peers []*Peer `json:"peers"`
}
ClientVersion struct { ClientVersion struct {
ClientVersion string `json:"client_version"` ClientVersion string `json:"client_version"`
} }
...@@ -130,12 +121,6 @@ type ( ...@@ -130,12 +121,6 @@ type (
Listeners []string `json:"listeners"` Listeners []string `json:"listeners"`
} }
// used in Peers and BlockchainInfo
Peer struct {
nodeInfo *p2p.NodeInfo `json:"node_info"`
IsOutbound bool `json:"is_outbound"`
}
// *********************************** Transactions *********************************** // *********************************** Transactions ***********************************
// Call or CallCode // Call or CallCode
......
...@@ -40,7 +40,6 @@ type Pipe interface { ...@@ -40,7 +40,6 @@ type Pipe interface {
Blockchain() blockchain_types.Blockchain Blockchain() blockchain_types.Blockchain
Events() event.EventEmitter Events() event.EventEmitter
NameReg() NameReg NameReg() NameReg
Net() Net
Transactor() Transactor Transactor() Transactor
// Hash of Genesis state // Hash of Genesis state
GenesisHash() []byte GenesisHash() []byte
...@@ -68,16 +67,6 @@ type NameReg interface { ...@@ -68,16 +67,6 @@ type NameReg interface {
Entries([]*event.FilterData) (*types.ResultListNames, error) Entries([]*event.FilterData) (*types.ResultListNames, error)
} }
type Net interface {
Info() (*types.NetworkInfo, error)
ClientVersion() (string, error)
Moniker() (string, error)
Listening() (bool, error)
Listeners() ([]string, error)
Peers() ([]*types.Peer, error)
Peer(string) (*types.Peer, error)
}
type Transactor interface { type Transactor interface {
Call(fromAddress, toAddress, data []byte) (*types.Call, error) Call(fromAddress, toAddress, data []byte) (*types.Call, error)
CallCode(fromAddress, code, data []byte) (*types.Call, error) CallCode(fromAddress, code, data []byte) (*types.Call, error)
......
...@@ -55,7 +55,6 @@ type erisMintPipe struct { ...@@ -55,7 +55,6 @@ type erisMintPipe struct {
consensusEngine consensus_types.ConsensusEngine consensusEngine consensus_types.ConsensusEngine
events edb_event.EventEmitter events edb_event.EventEmitter
namereg *namereg namereg *namereg
network *network
transactor *transactor transactor *transactor
// Genesis cache // Genesis cache
genesisDoc *state_types.GenesisDoc genesisDoc *state_types.GenesisDoc
...@@ -111,8 +110,6 @@ func NewErisMintPipe(moduleConfig *config.ModuleConfig, ...@@ -111,8 +110,6 @@ func NewErisMintPipe(moduleConfig *config.ModuleConfig,
// genesis cache // genesis cache
genesisDoc: genesisDoc, genesisDoc: genesisDoc,
genesisState: nil, genesisState: nil,
// TODO: What network-level information do we need?
network: newNetwork(),
// consensus and blockchain should both be loaded into the pipe by a higher // consensus and blockchain should both be loaded into the pipe by a higher
// authority - this is a sort of dependency injection pattern // authority - this is a sort of dependency injection pattern
consensusEngine: nil, consensusEngine: nil,
...@@ -189,10 +186,6 @@ func (pipe *erisMintPipe) NameReg() definitions.NameReg { ...@@ -189,10 +186,6 @@ func (pipe *erisMintPipe) NameReg() definitions.NameReg {
return pipe.namereg return pipe.namereg
} }
func (pipe *erisMintPipe) Net() definitions.Net {
return pipe.network
}
func (pipe *erisMintPipe) Transactor() definitions.Transactor { func (pipe *erisMintPipe) Transactor() definitions.Transactor {
return pipe.transactor return pipe.transactor
} }
......
...@@ -70,9 +70,9 @@ type ResultUnsubscribe struct { ...@@ -70,9 +70,9 @@ type ResultUnsubscribe struct {
} }
type ResultNetInfo struct { type ResultNetInfo struct {
Listening bool `json:"listening"` Listening bool `json:"listening"`
Listeners []string `json:"listeners"` Listeners []string `json:"listeners"`
Peers []consensus_types.Peer `json:"peers"` Peers []*consensus_types.Peer `json:"peers"`
} }
type ResultListValidators struct { type ResultListValidators struct {
...@@ -83,7 +83,7 @@ type ResultListValidators struct { ...@@ -83,7 +83,7 @@ type ResultListValidators struct {
type ResultDumpConsensusState struct { type ResultDumpConsensusState struct {
ConsensusState *consensus_types.ConsensusState `json:"consensus_state"` ConsensusState *consensus_types.ConsensusState `json:"consensus_state"`
PeerConsensusStates []*ResultPeerConsensusState `json:"peer_consensus_states"` PeerConsensusStates []*ResultPeerConsensusState `json:"peer_consensus_states"`
} }
type ResultPeerConsensusState struct { type ResultPeerConsensusState struct {
......
...@@ -2,11 +2,11 @@ package rpc_v0 ...@@ -2,11 +2,11 @@ package rpc_v0
import ( import (
"github.com/eris-ltd/eris-db/blockchain" "github.com/eris-ltd/eris-db/blockchain"
pipes "github.com/eris-ltd/eris-db/core/pipes"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
definitions "github.com/eris-ltd/eris-db/definitions" definitions "github.com/eris-ltd/eris-db/definitions"
"github.com/eris-ltd/eris-db/event" "github.com/eris-ltd/eris-db/event"
rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/rpc"
"github.com/eris-ltd/eris-db/rpc/v0/shared"
"github.com/eris-ltd/eris-db/txs" "github.com/eris-ltd/eris-db/txs"
) )
...@@ -205,7 +205,7 @@ func (erisDbMethods *ErisDbMethods) AccountStorageAt(request *rpc.RPCRequest, re ...@@ -205,7 +205,7 @@ func (erisDbMethods *ErisDbMethods) AccountStorageAt(request *rpc.RPCRequest, re
// *************************************** Blockchain ************************************ // *************************************** Blockchain ************************************
func (erisDbMethods *ErisDbMethods) BlockchainInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) BlockchainInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
return pipes.BlockchainInfo(erisDbMethods.pipe), 0, nil return shared.BlockchainInfo(erisDbMethods.pipe), 0, nil
} }
func (erisDbMethods *ErisDbMethods) ChainId(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) ChainId(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
...@@ -266,50 +266,32 @@ func (erisDbMethods *ErisDbMethods) Validators(request *rpc.RPCRequest, requeste ...@@ -266,50 +266,32 @@ func (erisDbMethods *ErisDbMethods) Validators(request *rpc.RPCRequest, requeste
// *************************************** Net ************************************ // *************************************** Net ************************************
func (erisDbMethods *ErisDbMethods) NetworkInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) NetworkInfo(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
info, errC := erisDbMethods.pipe.Net().Info() info := shared.NetInfo(erisDbMethods.pipe)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return info, 0, nil return info, 0, nil
} }
func (erisDbMethods *ErisDbMethods) ClientVersion(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) ClientVersion(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
version, errC := erisDbMethods.pipe.Net().ClientVersion() version := shared.ClientVersion(erisDbMethods.pipe)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return &core_types.ClientVersion{version}, 0, nil return &core_types.ClientVersion{version}, 0, nil
} }
func (erisDbMethods *ErisDbMethods) Moniker(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) Moniker(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
moniker, errC := erisDbMethods.pipe.Net().Moniker() moniker := shared.Moniker(erisDbMethods.pipe)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return &core_types.Moniker{moniker}, 0, nil return &core_types.Moniker{moniker}, 0, nil
} }
func (erisDbMethods *ErisDbMethods) Listening(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) Listening(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
listening, errC := erisDbMethods.pipe.Net().Listening() listening := shared.Listening(erisDbMethods.pipe)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return &core_types.Listening{listening}, 0, nil return &core_types.Listening{listening}, 0, nil
} }
func (erisDbMethods *ErisDbMethods) Listeners(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) Listeners(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
listeners, errC := erisDbMethods.pipe.Net().Listeners() listeners := shared.Listeners(erisDbMethods.pipe)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return &core_types.Listeners{listeners}, 0, nil return &core_types.Listeners{listeners}, 0, nil
} }
func (erisDbMethods *ErisDbMethods) Peers(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { func (erisDbMethods *ErisDbMethods) Peers(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) {
peers, errC := erisDbMethods.pipe.Net().Peers() peers := erisDbMethods.pipe.GetConsensusEngine().Peers()
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return peers, 0, nil return peers, 0, nil
} }
...@@ -320,10 +302,7 @@ func (erisDbMethods *ErisDbMethods) Peer(request *rpc.RPCRequest, requester inte ...@@ -320,10 +302,7 @@ func (erisDbMethods *ErisDbMethods) Peer(request *rpc.RPCRequest, requester inte
return nil, rpc.INVALID_PARAMS, err return nil, rpc.INVALID_PARAMS, err
} }
address := param.Address address := param.Address
peer, errC := erisDbMethods.pipe.Net().Peer(address) peer := shared.Peer(erisDbMethods.pipe, address)
if errC != nil {
return nil, rpc.INTERNAL_ERROR, errC
}
return peer, 0, nil return peer, 0, nil
} }
......
...@@ -9,11 +9,11 @@ import ( ...@@ -9,11 +9,11 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/eris-ltd/eris-db/blockchain" "github.com/eris-ltd/eris-db/blockchain"
"github.com/eris-ltd/eris-db/core/pipes"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
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"
rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/rpc"
"github.com/eris-ltd/eris-db/rpc/v0/shared"
server "github.com/eris-ltd/eris-db/server" server "github.com/eris-ltd/eris-db/server"
"github.com/eris-ltd/eris-db/txs" "github.com/eris-ltd/eris-db/txs"
"github.com/eris-ltd/eris-db/util" "github.com/eris-ltd/eris-db/util"
...@@ -165,7 +165,7 @@ func (restServer *RestServer) handleStorageAt(c *gin.Context) { ...@@ -165,7 +165,7 @@ func (restServer *RestServer) handleStorageAt(c *gin.Context) {
// ********************************* Blockchain ********************************* // ********************************* Blockchain *********************************
func (restServer *RestServer) handleBlockchainInfo(c *gin.Context) { func (restServer *RestServer) handleBlockchainInfo(c *gin.Context) {
bci := pipes.BlockchainInfo(restServer.pipe) bci := shared.BlockchainInfo(restServer.pipe)
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(bci, c.Writer) restServer.codec.Encode(bci, c.Writer)
} }
...@@ -297,65 +297,44 @@ func (restServer *RestServer) handleNameRegEntry(c *gin.Context) { ...@@ -297,65 +297,44 @@ func (restServer *RestServer) handleNameRegEntry(c *gin.Context) {
// ********************************* Network ********************************* // ********************************* Network *********************************
func (restServer *RestServer) handleNetworkInfo(c *gin.Context) { func (restServer *RestServer) handleNetworkInfo(c *gin.Context) {
nInfo, err := restServer.pipe.Net().Info() nInfo := shared.NetInfo(restServer.pipe)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(nInfo, c.Writer) restServer.codec.Encode(nInfo, c.Writer)
} }
func (restServer *RestServer) handleClientVersion(c *gin.Context) { func (restServer *RestServer) handleClientVersion(c *gin.Context) {
version, err := restServer.pipe.Net().ClientVersion() version := shared.ClientVersion(restServer.pipe)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(&core_types.ClientVersion{version}, c.Writer) restServer.codec.Encode(&core_types.ClientVersion{version}, c.Writer)
} }
func (restServer *RestServer) handleMoniker(c *gin.Context) { func (restServer *RestServer) handleMoniker(c *gin.Context) {
moniker, err := restServer.pipe.Net().Moniker() moniker := shared.Moniker(restServer.pipe)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(&core_types.Moniker{moniker}, c.Writer) restServer.codec.Encode(&core_types.Moniker{moniker}, c.Writer)
} }
func (restServer *RestServer) handleListening(c *gin.Context) { func (restServer *RestServer) handleListening(c *gin.Context) {
listening, err := restServer.pipe.Net().Listening() listening := shared.Listening(restServer.pipe)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(&core_types.Listening{listening}, c.Writer) restServer.codec.Encode(&core_types.Listening{listening}, c.Writer)
} }
func (restServer *RestServer) handleListeners(c *gin.Context) { func (restServer *RestServer) handleListeners(c *gin.Context) {
listeners, err := restServer.pipe.Net().Listeners() listeners := shared.Listeners(restServer.pipe)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(&core_types.Listeners{listeners}, c.Writer) restServer.codec.Encode(&core_types.Listeners{listeners}, c.Writer)
} }
func (restServer *RestServer) handlePeers(c *gin.Context) { func (restServer *RestServer) handlePeers(c *gin.Context) {
peers, err := restServer.pipe.Net().Peers() peers := restServer.pipe.GetConsensusEngine().Peers()
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(peers, c.Writer) restServer.codec.Encode(peers, c.Writer)
} }
func (restServer *RestServer) handlePeer(c *gin.Context) { func (restServer *RestServer) handlePeer(c *gin.Context) {
address := c.MustGet("address").(string) address := c.MustGet("address").(string)
peer, err := restServer.pipe.Net().Peer(address) peer := shared.Peer(restServer.pipe, address)
if err != nil {
c.AbortWithError(500, err)
}
c.Writer.WriteHeader(200) c.Writer.WriteHeader(200)
restServer.codec.Encode(peer, c.Writer) restServer.codec.Encode(peer, c.Writer)
} }
......
...@@ -16,62 +16,69 @@ ...@@ -16,62 +16,69 @@
// Net is part of the pipe for ErisMint and provides the implementation // Net is part of the pipe for ErisMint and provides the implementation
// for the pipe to call into the ErisMint application // for the pipe to call into the ErisMint application
package erismint package shared
import ( import (
core_types "github.com/eris-ltd/eris-db/core/types" consensus_types "github.com/eris-ltd/eris-db/consensus/types"
"github.com/eris-ltd/eris-db/definitions"
) )
// TODO-RPC!
// The network structure
type network struct {
}
func newNetwork() *network {
return &network{}
}
//------------------------------------------------------------------------------
// Tendermint Pipe implementation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Eris-DB v0 Pipe implementation
// Get the complete net info. // Get the complete pipe info.
func (this *network) Info() (*core_types.NetworkInfo, error) { func NetInfo(pipe definitions.Pipe) *NetworkInfo {
return &core_types.NetworkInfo{}, nil thisNode := pipe.GetConsensusEngine().NodeInfo()
listeners := []string{}
for _, listener := range pipe.GetConsensusEngine().Listeners() {
listeners = append(listeners, listener.String())
}
return &NetworkInfo{
ClientVersion: thisNode.Version,
Moniker: thisNode.Moniker,
Listening: pipe.GetConsensusEngine().IsListening(),
Listeners: listeners,
Peers: pipe.GetConsensusEngine().Peers(),
}
} }
// Get the client version // Get the client version
func (this *network) ClientVersion() (string, error) { func ClientVersion(pipe definitions.Pipe) string {
return "not-fully-loaded-yet", nil return pipe.GetConsensusEngine().NodeInfo().Version
} }
// Get the moniker // Get the moniker
func (this *network) Moniker() (string, error) { func Moniker(pipe definitions.Pipe) string {
return "rekinom", nil return pipe.GetConsensusEngine().NodeInfo().Moniker
} }
// Is the network currently listening for connections. // Is the network currently listening for connections.
func (this *network) Listening() (bool, error) { func Listening(pipe definitions.Pipe) bool {
return false, nil return pipe.GetConsensusEngine().IsListening()
} }
// Is the network currently listening for connections. // Is the network currently listening for connections.
func (this *network) Listeners() ([]string, error) { func Listeners(pipe definitions.Pipe) []string {
return []string{}, nil listeners := []string{}
for _, listener := range pipe.GetConsensusEngine().Listeners() {
listeners = append(listeners, listener.String())
}
return listeners
} }
// Get a list of all peers. func Peer(pipe definitions.Pipe, address string) *consensus_types.Peer {
func (this *network) Peers() ([]*core_types.Peer, error) { for _, peer := range pipe.GetConsensusEngine().Peers() {
return []*core_types.Peer{}, nil if peer.NodeInfo.RemoteAddr == address {
return peer
}
}
return nil
} }
// Get a peer. TODO Need to do something about the address. // NetworkInfo
func (this *network) Peer(address string) (*core_types.Peer, error) { type NetworkInfo struct {
return &core_types.Peer{}, nil ClientVersion string `json:"client_version"`
Moniker string `json:"moniker"`
Listening bool `json:"listening"`
Listeners []string `json:"listeners"`
Peers []*consensus_types.Peer `json:"peers"`
} }
//------------------------------------------------------------------------------
//
package pipes package shared
// Shared extension methods for Pipe and its derivatives // Shared extension methods for Pipe and its derivatives
......
...@@ -9,6 +9,8 @@ import ( ...@@ -9,6 +9,8 @@ import (
"runtime" "runtime"
"testing" "testing"
consensus_types "github.com/eris-ltd/eris-db/consensus/types"
account "github.com/eris-ltd/eris-db/account" account "github.com/eris-ltd/eris-db/account"
core_types "github.com/eris-ltd/eris-db/core/types" core_types "github.com/eris-ltd/eris-db/core/types"
event "github.com/eris-ltd/eris-db/event" event "github.com/eris-ltd/eris-db/event"
...@@ -18,6 +20,7 @@ import ( ...@@ -18,6 +20,7 @@ import (
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/eris-ltd/eris-db/rpc/v0/shared"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/tendermint/log15" "github.com/tendermint/log15"
...@@ -41,7 +44,7 @@ type MockSuite struct { ...@@ -41,7 +44,7 @@ type MockSuite struct {
testData *td.TestData testData *td.TestData
} }
func (this *MockSuite) SetupSuite() { func (mockSuite *MockSuite) SetupSuite() {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
// Load the supporting objects. // Load the supporting objects.
testData := td.LoadTestData() testData := td.LoadTestData()
...@@ -58,262 +61,262 @@ func (this *MockSuite) SetupSuite() { ...@@ -58,262 +61,262 @@ func (this *MockSuite) SetupSuite() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
this.serveProcess = proc mockSuite.serveProcess = proc
this.codec = rpc_v0.NewTCodec() mockSuite.codec = rpc_v0.NewTCodec()
this.testData = testData mockSuite.testData = testData
this.sUrl = "http://localhost:31402" mockSuite.sUrl = "http://localhost:31402"
} }
func (this *MockSuite) TearDownSuite() { func (mockSuite *MockSuite) TearDownSuite() {
sec := this.serveProcess.StopEventChannel() sec := mockSuite.serveProcess.StopEventChannel()
this.serveProcess.Stop(0) mockSuite.serveProcess.Stop(0)
<-sec <-sec
} }
// ********************************************* Accounts ********************************************* // ********************************************* Accounts *********************************************
func (this *MockSuite) TestGetAccounts() { func (mockSuite *MockSuite) TestGetAccounts() {
resp := this.get("/accounts") resp := mockSuite.get("/accounts")
ret := &core_types.AccountList{} ret := &core_types.AccountList{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetAccounts.Output) mockSuite.Equal(mockSuite.testData.GetAccounts.Output, ret)
} }
func (this *MockSuite) TestGetAccount() { func (mockSuite *MockSuite) TestGetAccount() {
addr := hex.EncodeToString(this.testData.GetAccount.Input.Address) addr := hex.EncodeToString(mockSuite.testData.GetAccount.Input.Address)
resp := this.get("/accounts/" + addr) resp := mockSuite.get("/accounts/" + addr)
ret := &account.Account{} ret := &account.Account{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetAccount.Output) mockSuite.Equal(mockSuite.testData.GetAccount.Output, ret)
} }
func (this *MockSuite) TestGetStorage() { func (mockSuite *MockSuite) TestGetStorage() {
addr := hex.EncodeToString(this.testData.GetStorage.Input.Address) addr := hex.EncodeToString(mockSuite.testData.GetStorage.Input.Address)
resp := this.get("/accounts/" + addr + "/storage") resp := mockSuite.get("/accounts/" + addr + "/storage")
ret := &core_types.Storage{} ret := &core_types.Storage{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetStorage.Output) mockSuite.Equal(mockSuite.testData.GetStorage.Output, ret)
} }
func (this *MockSuite) TestGetStorageAt() { func (mockSuite *MockSuite) TestGetStorageAt() {
addr := hex.EncodeToString(this.testData.GetStorageAt.Input.Address) addr := hex.EncodeToString(mockSuite.testData.GetStorageAt.Input.Address)
key := hex.EncodeToString(this.testData.GetStorageAt.Input.Key) key := hex.EncodeToString(mockSuite.testData.GetStorageAt.Input.Key)
resp := this.get("/accounts/" + addr + "/storage/" + key) resp := mockSuite.get("/accounts/" + addr + "/storage/" + key)
ret := &core_types.StorageItem{} ret := &core_types.StorageItem{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetStorageAt.Output) mockSuite.Equal(mockSuite.testData.GetStorageAt.Output, ret)
} }
// ********************************************* Blockchain ********************************************* // ********************************************* Blockchain *********************************************
func (this *MockSuite) TestGetBlockchainInfo() { func (mockSuite *MockSuite) TestGetBlockchainInfo() {
resp := this.get("/blockchain") resp := mockSuite.get("/blockchain")
ret := &core_types.BlockchainInfo{} ret := &core_types.BlockchainInfo{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetBlockchainInfo.Output, ret) mockSuite.Equal(mockSuite.testData.GetBlockchainInfo.Output, ret)
} }
func (this *MockSuite) TestGetChainId() { func (mockSuite *MockSuite) TestGetChainId() {
resp := this.get("/blockchain/chain_id") resp := mockSuite.get("/blockchain/chain_id")
ret := &core_types.ChainId{} ret := &core_types.ChainId{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetChainId.Output, ret) mockSuite.Equal(mockSuite.testData.GetChainId.Output, ret)
} }
func (this *MockSuite) TestGetGenesisHash() { func (mockSuite *MockSuite) TestGetGenesisHash() {
resp := this.get("/blockchain/genesis_hash") resp := mockSuite.get("/blockchain/genesis_hash")
ret := &core_types.GenesisHash{} ret := &core_types.GenesisHash{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetGenesisHash.Output, ret) mockSuite.Equal(mockSuite.testData.GetGenesisHash.Output, ret)
} }
func (this *MockSuite) TestLatestBlockHeight() { func (mockSuite *MockSuite) TestLatestBlockHeight() {
resp := this.get("/blockchain/latest_block_height") resp := mockSuite.get("/blockchain/latest_block_height")
ret := &core_types.LatestBlockHeight{} ret := &core_types.LatestBlockHeight{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetLatestBlockHeight.Output, ret) mockSuite.Equal(mockSuite.testData.GetLatestBlockHeight.Output, ret)
} }
func (this *MockSuite) TestBlocks() { func (mockSuite *MockSuite) TestBlocks() {
resp := this.get("/blockchain/blocks") resp := mockSuite.get("/blockchain/blocks")
ret := &core_types.Blocks{} ret := &core_types.Blocks{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetBlocks.Output, ret) mockSuite.Equal(mockSuite.testData.GetBlocks.Output, ret)
} }
// ********************************************* Consensus ********************************************* // ********************************************* Consensus *********************************************
// TODO: re-enable these when implemented // TODO: re-enable these when implemented
//func (this *MockSuite) TestGetConsensusState() { //func (mockSuite *MockSuite) TestGetConsensusState() {
// resp := this.get("/consensus") // resp := mockSuite.get("/consensus")
// ret := &core_types.ConsensusState{} // ret := &core_types.ConsensusState{}
// errD := this.codec.Decode(ret, resp.Body) // errD := mockSuite.codec.Decode(ret, resp.Body)
// this.NoError(errD) // mockSuite.NoError(errD)
// ret.StartTime = "" // ret.StartTime = ""
// this.Equal(this.testData.GetConsensusState.Output, ret) // mockSuite.Equal(mockSuite.testData.GetConsensusState.Output, ret)
//} //}
// //
//func (this *MockSuite) TestGetValidators() { //func (mockSuite *MockSuite) TestGetValidators() {
// resp := this.get("/consensus/validators") // resp := mockSuite.get("/consensus/validators")
// ret := &core_types.ValidatorList{} // ret := &core_types.ValidatorList{}
// errD := this.codec.Decode(ret, resp.Body) // errD := mockSuite.codec.Decode(ret, resp.Body)
// this.NoError(errD) // mockSuite.NoError(errD)
// this.Equal(this.testData.GetValidators.Output, ret) // mockSuite.Equal(mockSuite.testData.GetValidators.Output, ret)
//} //}
// ********************************************* NameReg ********************************************* // ********************************************* NameReg *********************************************
func (this *MockSuite) TestGetNameRegEntry() { func (mockSuite *MockSuite) TestGetNameRegEntry() {
resp := this.get("/namereg/" + this.testData.GetNameRegEntry.Input.Name) resp := mockSuite.get("/namereg/" + mockSuite.testData.GetNameRegEntry.Input.Name)
ret := &core_types.NameRegEntry{} ret := &core_types.NameRegEntry{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetNameRegEntry.Output, ret) mockSuite.Equal(mockSuite.testData.GetNameRegEntry.Output, ret)
} }
func (this *MockSuite) TestGetNameRegEntries() { func (mockSuite *MockSuite) TestGetNameRegEntries() {
resp := this.get("/namereg") resp := mockSuite.get("/namereg")
ret := &core_types.ResultListNames{} ret := &core_types.ResultListNames{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(this.testData.GetNameRegEntries.Output, ret) mockSuite.Equal(mockSuite.testData.GetNameRegEntries.Output, ret)
} }
// ********************************************* Network ********************************************* // ********************************************* Network *********************************************
func (this *MockSuite) TestGetNetworkInfo() { func (mockSuite *MockSuite) TestGetNetworkInfo() {
resp := this.get("/network") resp := mockSuite.get("/network")
ret := &core_types.NetworkInfo{} ret := &shared.NetworkInfo{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetNetworkInfo.Output) mockSuite.Equal(mockSuite.testData.GetNetworkInfo.Output, ret)
} }
func (this *MockSuite) TestGetClientVersion() { func (mockSuite *MockSuite) TestGetClientVersion() {
resp := this.get("/network/client_version") resp := mockSuite.get("/network/client_version")
ret := &core_types.ClientVersion{} ret := &core_types.ClientVersion{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetClientVersion.Output) mockSuite.Equal(mockSuite.testData.GetClientVersion.Output, ret)
} }
func (this *MockSuite) TestGetMoniker() { func (mockSuite *MockSuite) TestGetMoniker() {
resp := this.get("/network/moniker") resp := mockSuite.get("/network/moniker")
ret := &core_types.Moniker{} ret := &core_types.Moniker{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetMoniker.Output) mockSuite.Equal(mockSuite.testData.GetMoniker.Output, ret)
} }
func (this *MockSuite) TestIsListening() { func (mockSuite *MockSuite) TestIsListening() {
resp := this.get("/network/listening") resp := mockSuite.get("/network/listening")
ret := &core_types.Listening{} ret := &core_types.Listening{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.IsListening.Output) mockSuite.Equal(mockSuite.testData.IsListening.Output, ret)
} }
func (this *MockSuite) TestGetListeners() { func (mockSuite *MockSuite) TestGetListeners() {
resp := this.get("/network/listeners") resp := mockSuite.get("/network/listeners")
ret := &core_types.Listeners{} ret := &core_types.Listeners{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetListeners.Output) mockSuite.Equal(mockSuite.testData.GetListeners.Output, ret)
} }
func (this *MockSuite) TestGetPeers() { func (mockSuite *MockSuite) TestGetPeers() {
resp := this.get("/network/peers") resp := mockSuite.get("/network/peers")
ret := []*core_types.Peer{} ret := []*consensus_types.Peer{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetPeers.Output) mockSuite.Equal(mockSuite.testData.GetPeers.Output, ret)
} }
/* /*
func (this *MockSuite) TestGetPeer() { func (mockSuite *MockSuite) TestGetPeer() {
addr := this.testData.GetPeer.Input.Address addr := mockSuite.testData.GetPeer.Input.Address
resp := this.get("/network/peer/" + addr) resp := mockSuite.get("/network/peer/" + addr)
ret := []*core_types.Peer{} ret := []*core_types.Peer{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetPeers.Output) mockSuite.Equal(mockSuite.testData.GetPeers.Output)
} }
*/ */
// ********************************************* Transactions ********************************************* // ********************************************* Transactions *********************************************
func (this *MockSuite) TestTransactCreate() { func (mockSuite *MockSuite) TestTransactCreate() {
resp := this.postJson("/unsafe/txpool", this.testData.TransactCreate.Input) resp := mockSuite.postJson("/unsafe/txpool", mockSuite.testData.TransactCreate.Input)
ret := &txs.Receipt{} ret := &txs.Receipt{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.TransactCreate.Output) mockSuite.Equal(mockSuite.testData.TransactCreate.Output, ret)
} }
func (this *MockSuite) TestTransact() { func (mockSuite *MockSuite) TestTransact() {
resp := this.postJson("/unsafe/txpool", this.testData.Transact.Input) resp := mockSuite.postJson("/unsafe/txpool", mockSuite.testData.Transact.Input)
ret := &txs.Receipt{} ret := &txs.Receipt{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.Transact.Output) mockSuite.Equal(mockSuite.testData.Transact.Output, ret)
} }
func (this *MockSuite) TestTransactNameReg() { func (mockSuite *MockSuite) TestTransactNameReg() {
resp := this.postJson("/unsafe/namereg/txpool", this.testData.TransactNameReg.Input) resp := mockSuite.postJson("/unsafe/namereg/txpool", mockSuite.testData.TransactNameReg.Input)
ret := &txs.Receipt{} ret := &txs.Receipt{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.TransactNameReg.Output) mockSuite.Equal(mockSuite.testData.TransactNameReg.Output, ret)
} }
func (this *MockSuite) TestGetUnconfirmedTxs() { func (mockSuite *MockSuite) TestGetUnconfirmedTxs() {
resp := this.get("/txpool") resp := mockSuite.get("/txpool")
ret := &txs.UnconfirmedTxs{} ret := &txs.UnconfirmedTxs{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.GetUnconfirmedTxs.Output) mockSuite.Equal(mockSuite.testData.GetUnconfirmedTxs.Output, ret)
} }
func (this *MockSuite) TestCallCode() { func (mockSuite *MockSuite) TestCallCode() {
resp := this.postJson("/codecalls", this.testData.CallCode.Input) resp := mockSuite.postJson("/codecalls", mockSuite.testData.CallCode.Input)
ret := &core_types.Call{} ret := &core_types.Call{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.CallCode.Output) mockSuite.Equal(mockSuite.testData.CallCode.Output, ret)
} }
func (this *MockSuite) TestCall() { func (mockSuite *MockSuite) TestCall() {
resp := this.postJson("/calls", this.testData.Call.Input) resp := mockSuite.postJson("/calls", mockSuite.testData.Call.Input)
ret := &core_types.Call{} ret := &core_types.Call{}
errD := this.codec.Decode(ret, resp.Body) errD := mockSuite.codec.Decode(ret, resp.Body)
this.NoError(errD) mockSuite.NoError(errD)
this.Equal(ret, this.testData.CallCode.Output) mockSuite.Equal(mockSuite.testData.CallCode.Output, ret)
} }
// ********************************************* Utilities ********************************************* // ********************************************* Utilities *********************************************
func (this *MockSuite) get(endpoint string) *http.Response { func (mockSuite *MockSuite) get(endpoint string) *http.Response {
resp, errG := http.Get(this.sUrl + endpoint) resp, errG := http.Get(mockSuite.sUrl + endpoint)
this.NoError(errG) mockSuite.NoError(errG)
this.Equal(200, resp.StatusCode) mockSuite.Equal(200, resp.StatusCode)
return resp return resp
} }
func (this *MockSuite) postJson(endpoint string, v interface{}) *http.Response { func (mockSuite *MockSuite) postJson(endpoint string, v interface{}) *http.Response {
bts, errE := this.codec.EncodeBytes(v) bts, errE := mockSuite.codec.EncodeBytes(v)
this.NoError(errE) mockSuite.NoError(errE)
resp, errP := http.Post(this.sUrl+endpoint, "application/json", bytes.NewBuffer(bts)) resp, errP := http.Post(mockSuite.sUrl+endpoint, "application/json", bytes.NewBuffer(bts))
this.NoError(errP) mockSuite.NoError(errP)
this.Equal(200, resp.StatusCode) mockSuite.Equal(200, resp.StatusCode)
return resp return resp
} }
......
...@@ -28,7 +28,6 @@ type MockPipe struct { ...@@ -28,7 +28,6 @@ type MockPipe struct {
consensusEngine consensus_types.ConsensusEngine consensusEngine consensus_types.ConsensusEngine
events event.EventEmitter events event.EventEmitter
namereg definitions.NameReg namereg definitions.NameReg
net definitions.Net
transactor definitions.Transactor transactor definitions.Transactor
} }
...@@ -39,7 +38,6 @@ func NewMockPipe(td *td.TestData) definitions.Pipe { ...@@ -39,7 +38,6 @@ func NewMockPipe(td *td.TestData) definitions.Pipe {
consensusEngine := &consensusEngine{td} consensusEngine := &consensusEngine{td}
eventer := &eventer{td} eventer := &eventer{td}
namereg := &namereg{td} namereg := &namereg{td}
net := &network{td}
transactor := &transactor{td} transactor := &transactor{td}
return &MockPipe{ return &MockPipe{
td, td,
...@@ -48,7 +46,6 @@ func NewMockPipe(td *td.TestData) definitions.Pipe { ...@@ -48,7 +46,6 @@ func NewMockPipe(td *td.TestData) definitions.Pipe {
consensusEngine, consensusEngine,
eventer, eventer,
namereg, namereg,
net,
transactor, transactor,
} }
} }
...@@ -74,10 +71,6 @@ func (pipe *MockPipe) NameReg() definitions.NameReg { ...@@ -74,10 +71,6 @@ func (pipe *MockPipe) NameReg() definitions.NameReg {
return pipe.namereg return pipe.namereg
} }
func (pipe *MockPipe) Net() definitions.Net {
return pipe.net
}
func (pipe *MockPipe) Transactor() definitions.Transactor { func (pipe *MockPipe) Transactor() definitions.Transactor {
return pipe.transactor return pipe.transactor
} }
...@@ -176,27 +169,36 @@ func (cons *consensusEngine) BroadcastTransaction(transaction []byte, ...@@ -176,27 +169,36 @@ func (cons *consensusEngine) BroadcastTransaction(transaction []byte,
} }
func (cons *consensusEngine) IsListening() bool { func (cons *consensusEngine) IsListening() bool {
return true return cons.testData.IsListening.Output.Listening
} }
func (cons *consensusEngine) Listeners() []p2p.Listener { func (cons *consensusEngine) Listeners() []p2p.Listener {
return make([]p2p.Listener, 0) p2pListeners := make([]p2p.Listener, 0)
for _, name := range cons.testData.GetListeners.Output.Listeners {
p2pListeners = append(p2pListeners, p2p.NewDefaultListener("tcp", name, true))
}
return p2pListeners
} }
func (cons *consensusEngine) NodeInfo() *p2p.NodeInfo { func (cons *consensusEngine) NodeInfo() *p2p.NodeInfo {
return &p2p.NodeInfo{} return &p2p.NodeInfo{
Version: cons.testData.GetNetworkInfo.Output.ClientVersion,
Moniker: cons.testData.GetNetworkInfo.Output.Moniker,
}
} }
func (cons *consensusEngine) Peers() []consensus_types.Peer { func (cons *consensusEngine) Peers() []*consensus_types.Peer {
return make([]consensus_types.Peer, 0) return cons.testData.GetPeers.Output
} }
func (cons *consensusEngine) PublicValidatorKey() crypto.PubKey { func (cons *consensusEngine) PublicValidatorKey() crypto.PubKey {
return crypto.PubKeyEd25519{ 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,
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,
} }
} }
...@@ -246,40 +248,6 @@ func (nmreg *namereg) Entries(filters []*event.FilterData) (*core_types.ResultLi ...@@ -246,40 +248,6 @@ func (nmreg *namereg) Entries(filters []*event.FilterData) (*core_types.ResultLi
return nmreg.testData.GetNameRegEntries.Output, nil return nmreg.testData.GetNameRegEntries.Output, nil
} }
// Net
type network struct {
testData *td.TestData
}
func (net *network) Info() (*core_types.NetworkInfo, error) {
return net.testData.GetNetworkInfo.Output, nil
}
func (net *network) ClientVersion() (string, error) {
return net.testData.GetClientVersion.Output.ClientVersion, nil
}
func (net *network) Moniker() (string, error) {
return net.testData.GetMoniker.Output.Moniker, nil
}
func (net *network) Listening() (bool, error) {
return net.testData.IsListening.Output.Listening, nil
}
func (net *network) Listeners() ([]string, error) {
return net.testData.GetListeners.Output.Listeners, nil
}
func (net *network) Peers() ([]*core_types.Peer, error) {
return net.testData.GetPeers.Output, nil
}
func (net *network) Peer(address string) (*core_types.Peer, error) {
// return net.testData.GetPeer.Output, nil
return nil, nil
}
// Txs // Txs
type transactor struct { type transactor struct {
testData *td.TestData testData *td.TestData
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
event "github.com/eris-ltd/eris-db/event" event "github.com/eris-ltd/eris-db/event"
stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types"
rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0"
"github.com/eris-ltd/eris-db/rpc/v0/shared"
transaction "github.com/eris-ltd/eris-db/txs" transaction "github.com/eris-ltd/eris-db/txs"
mintTypes "github.com/tendermint/tendermint/types" mintTypes "github.com/tendermint/tendermint/types"
) )
...@@ -605,7 +606,7 @@ type ( ...@@ -605,7 +606,7 @@ type (
} }
GetNetworkInfoData struct { GetNetworkInfoData struct {
Output *core_types.NetworkInfo `json:"output"` Output *shared.NetworkInfo `json:"output"`
} }
GetClientVersionData struct { GetClientVersionData struct {
...@@ -625,12 +626,12 @@ type ( ...@@ -625,12 +626,12 @@ type (
} }
GetPeersData struct { GetPeersData struct {
Output []*core_types.Peer `json:"output"` Output []*consensus_types.Peer `json:"output"`
} }
GetPeerData struct { GetPeerData struct {
Input *rpc_v0.PeerParam `json:"input"` Input *rpc_v0.PeerParam `json:"input"`
Output *core_types.Peer `json:"output"` Output *consensus_types.Peer `json:"output"`
} }
TransactData struct { TransactData struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment