Browse Source

[tm-monitor] update deps

pull/1943/head
Anton Kaliaev 7 years ago
parent
commit
9181822f65
No known key found for this signature in database GPG Key ID: 7B6881D965918214
7 changed files with 22 additions and 24 deletions
  1. +1
    -1
      tm-monitor/eventmeter/eventmeter.go
  2. +6
    -6
      tm-monitor/glide.lock
  3. +2
    -3
      tm-monitor/glide.yaml
  4. +5
    -6
      tm-monitor/mock/mock.go
  5. +3
    -3
      tm-monitor/monitor/monitor_test.go
  6. +1
    -1
      tm-monitor/monitor/node.go
  7. +4
    -4
      tm-monitor/monitor/node_test.go

+ 1
- 1
tm-monitor/eventmeter/eventmeter.go View File

@ -22,7 +22,7 @@ import (
// Meter for a particular event
// Closure to enable side effects from receiving an event
type EventCallbackFunc func(em *EventMetric, data events.EventData)
type EventCallbackFunc func(em *EventMetric, data interface{})
// Metrics for a given event
type EventMetric struct {


+ 6
- 6
tm-monitor/glide.lock View File

@ -1,5 +1,5 @@
hash: 80c204190057df1e74d32ecd7095e8a1a865c3a06671f1a31d5240e1e3ff2c64
updated: 2017-05-20T17:49:23.646798165-04:00
hash: 30b649bc544a4ebd2b2a6188ce314cb72e6c28be8f3e57ec22e7cb83fd974814
updated: 2017-07-29T18:47:33.199177142Z
imports:
- name: github.com/btcsuite/btcd
version: 583684b21bfbde9b5fc4403916fd7c807feb0289
@ -24,7 +24,7 @@ imports:
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: bfd5150e4e41705ded2129ec33379de1cb90b513
version: 645ef00459ed84a119197bfb8d8205042c6df63d
- name: github.com/rcrowley/go-metrics
version: 1f30fe9094a513ce4c700b9a54458bbb0c96996c
- name: github.com/tendermint/abci
@ -39,13 +39,13 @@ imports:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 7dff40942a64cdeefefa9446b2d104750b349f8a
version: 95b7c9e09c49b91bfbb71bb63dd514eb55450f16
- name: github.com/tendermint/go-wire
version: 5f88da3dbc1a72844e6dfaf274ce87f851d488eb
subpackages:
- data
- name: github.com/tendermint/tendermint
version: 267f134d44e76efb2adef5f0c993da8a5d5bd1b8
version: e9b7221292afe25ce956ea85ab83bb5708eb2992
subpackages:
- config
- p2p
@ -56,7 +56,7 @@ imports:
- rpc/lib/types
- types
- name: github.com/tendermint/tmlibs
version: 306795ae1d8e4f4a10dcc8bdb32a00455843c9d5
version: 2f6f3e6aa70bb19b70a6e73210273fa127041070
subpackages:
- common
- events


+ 2
- 3
tm-monitor/glide.yaml View File

@ -1,8 +1,5 @@
package: github.com/tendermint/tools/tm-monitor
import:
- package: github.com/go-kit/kit
subpackages:
- log
- package: github.com/gorilla/websocket
- package: github.com/pkg/errors
- package: github.com/rcrowley/go-metrics
@ -15,7 +12,9 @@ import:
- rpc/lib/server
- types
- package: github.com/tendermint/tmlibs
version: develop
subpackages:
- common
- events
- log
testImport:


+ 5
- 6
tm-monitor/mock/mock.go View File

@ -1,11 +1,10 @@
package mock
import (
"log"
stdlog "log"
"reflect"
gokitlog "github.com/go-kit/kit/log"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tmlibs/log"
em "github.com/tendermint/tools/tm-monitor/eventmeter"
)
@ -17,7 +16,7 @@ type EventMeter struct {
func (e *EventMeter) Start() error { return nil }
func (e *EventMeter) Stop() {}
func (e *EventMeter) SetLogger(l gokitlog.Logger) {}
func (e *EventMeter) SetLogger(l log.Logger) {}
func (e *EventMeter) RegisterLatencyCallback(cb em.LatencyCallbackFunc) { e.latencyCallback = cb }
func (e *EventMeter) RegisterDisconnectCallback(cb em.DisconnectCallbackFunc) {
e.disconnectCallback = cb
@ -43,13 +42,13 @@ func (e *EventMeter) Call(callback string, args ...interface{}) {
}
type RpcClient struct {
Stubs map[string]ctypes.TMResult
Stubs map[string]interface{}
}
func (c *RpcClient) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) {
s, ok := c.Stubs[method]
if !ok {
log.Fatalf("Call to %s, but no stub is defined for it", method)
stdlog.Fatalf("Call to %s, but no stub is defined for it", method)
}
rv, rt := reflect.ValueOf(result), reflect.TypeOf(result)


+ 3
- 3
tm-monitor/monitor/monitor_test.go View File

@ -61,10 +61,10 @@ func startMonitor(t *testing.T) *monitor.Monitor {
func createValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter) {
emMock = &mock.EventMeter{}
stubs := make(map[string]ctypes.TMResult)
stubs := make(map[string]interface{})
pubKey := crypto.GenPrivKeyEd25519().PubKey()
stubs["validators"] = &ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = &ctypes.ResultStatus{PubKey: pubKey}
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{PubKey: pubKey}
rpcClientMock := &mock.RpcClient{stubs}
n = monitor.NewNodeWithEventMeterAndRpcClient("tcp://127.0.0.1:46657", emMock, rpcClientMock)


+ 1
- 1
tm-monitor/monitor/node.go View File

@ -125,7 +125,7 @@ func (n *Node) Stop() {
// implements eventmeter.EventCallbackFunc
func newBlockCallback(n *Node) em.EventCallbackFunc {
return func(metric *em.EventMetric, data events.EventData) {
return func(metric *em.EventMetric, data interface{}) {
block := data.(tmtypes.TMEventData).Unwrap().(tmtypes.EventDataNewBlockHeader).Header
n.Height = uint64(block.Height)


+ 4
- 4
tm-monitor/monitor/node_test.go View File

@ -37,7 +37,7 @@ func TestNodeNewBlockReceived(t *testing.T) {
n.SendBlocksTo(blockCh)
blockHeader := &tmtypes.Header{Height: 5}
emMock.Call("eventCallback", &em.EventMetric{}, tmtypes.EventDataNewBlockHeader{blockHeader})
emMock.Call("eventCallback", &em.EventMetric{}, tmtypes.TMEventData{tmtypes.EventDataNewBlockHeader{blockHeader}})
assert.Equal(uint64(5), n.Height)
assert.Equal(*blockHeader, <-blockCh)
@ -89,10 +89,10 @@ func TestNumValidators(t *testing.T) {
func startValidatorNode(t *testing.T) (n *monitor.Node, emMock *mock.EventMeter) {
emMock = &mock.EventMeter{}
stubs := make(map[string]ctypes.TMResult)
stubs := make(map[string]interface{})
pubKey := crypto.GenPrivKeyEd25519().PubKey()
stubs["validators"] = &ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = &ctypes.ResultStatus{PubKey: pubKey}
stubs["validators"] = ctypes.ResultValidators{BlockHeight: blockHeight, Validators: []*tmtypes.Validator{tmtypes.NewValidator(pubKey, 0)}}
stubs["status"] = ctypes.ResultStatus{PubKey: pubKey}
rpcClientMock := &mock.RpcClient{stubs}
n = monitor.NewNodeWithEventMeterAndRpcClient("tcp://127.0.0.1:46657", emMock, rpcClientMock)


Loading…
Cancel
Save