mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-19 13:46:17 +00:00
This cleans up the `Router` code and adds a bunch of tests. These sorts of systems are a real pain to test, since they have a bunch of asynchronous goroutines living their own lives, so the test coverage is decent but not fantastic. Luckily we've been able to move all of the complex peer management and transport logic outside of the router, as synchronous components that are much easier to test, so the core router logic is fairly small and simple. This also provides some initial test tooling in `p2p/p2ptest` that automatically sets up in-memory networks and channels for use in integration tests. It also includes channel-oriented test asserters in `p2p/p2ptest/require.go`, but these have primarily been written for router testing and should probably be adapted or extended for reactor testing.
207 lines
4.2 KiB
Go
207 lines
4.2 KiB
Go
// Code generated by mockery v2.5.1. DO NOT EDIT.
|
|
|
|
package mocks
|
|
|
|
import (
|
|
context "context"
|
|
|
|
conn "github.com/tendermint/tendermint/p2p/conn"
|
|
|
|
crypto "github.com/tendermint/tendermint/crypto"
|
|
|
|
mock "github.com/stretchr/testify/mock"
|
|
|
|
p2p "github.com/tendermint/tendermint/p2p"
|
|
)
|
|
|
|
// Connection is an autogenerated mock type for the Connection type
|
|
type Connection struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Close provides a mock function with given fields:
|
|
func (_m *Connection) Close() error {
|
|
ret := _m.Called()
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func() error); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// FlushClose provides a mock function with given fields:
|
|
func (_m *Connection) FlushClose() error {
|
|
ret := _m.Called()
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func() error); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Handshake provides a mock function with given fields: _a0, _a1, _a2
|
|
func (_m *Connection) Handshake(_a0 context.Context, _a1 p2p.NodeInfo, _a2 crypto.PrivKey) (p2p.NodeInfo, crypto.PubKey, error) {
|
|
ret := _m.Called(_a0, _a1, _a2)
|
|
|
|
var r0 p2p.NodeInfo
|
|
if rf, ok := ret.Get(0).(func(context.Context, p2p.NodeInfo, crypto.PrivKey) p2p.NodeInfo); ok {
|
|
r0 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
r0 = ret.Get(0).(p2p.NodeInfo)
|
|
}
|
|
|
|
var r1 crypto.PubKey
|
|
if rf, ok := ret.Get(1).(func(context.Context, p2p.NodeInfo, crypto.PrivKey) crypto.PubKey); ok {
|
|
r1 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
if ret.Get(1) != nil {
|
|
r1 = ret.Get(1).(crypto.PubKey)
|
|
}
|
|
}
|
|
|
|
var r2 error
|
|
if rf, ok := ret.Get(2).(func(context.Context, p2p.NodeInfo, crypto.PrivKey) error); ok {
|
|
r2 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
r2 = ret.Error(2)
|
|
}
|
|
|
|
return r0, r1, r2
|
|
}
|
|
|
|
// LocalEndpoint provides a mock function with given fields:
|
|
func (_m *Connection) LocalEndpoint() p2p.Endpoint {
|
|
ret := _m.Called()
|
|
|
|
var r0 p2p.Endpoint
|
|
if rf, ok := ret.Get(0).(func() p2p.Endpoint); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(p2p.Endpoint)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// ReceiveMessage provides a mock function with given fields:
|
|
func (_m *Connection) ReceiveMessage() (p2p.ChannelID, []byte, error) {
|
|
ret := _m.Called()
|
|
|
|
var r0 p2p.ChannelID
|
|
if rf, ok := ret.Get(0).(func() p2p.ChannelID); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(p2p.ChannelID)
|
|
}
|
|
|
|
var r1 []byte
|
|
if rf, ok := ret.Get(1).(func() []byte); ok {
|
|
r1 = rf()
|
|
} else {
|
|
if ret.Get(1) != nil {
|
|
r1 = ret.Get(1).([]byte)
|
|
}
|
|
}
|
|
|
|
var r2 error
|
|
if rf, ok := ret.Get(2).(func() error); ok {
|
|
r2 = rf()
|
|
} else {
|
|
r2 = ret.Error(2)
|
|
}
|
|
|
|
return r0, r1, r2
|
|
}
|
|
|
|
// RemoteEndpoint provides a mock function with given fields:
|
|
func (_m *Connection) RemoteEndpoint() p2p.Endpoint {
|
|
ret := _m.Called()
|
|
|
|
var r0 p2p.Endpoint
|
|
if rf, ok := ret.Get(0).(func() p2p.Endpoint); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(p2p.Endpoint)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// SendMessage provides a mock function with given fields: _a0, _a1
|
|
func (_m *Connection) SendMessage(_a0 p2p.ChannelID, _a1 []byte) (bool, error) {
|
|
ret := _m.Called(_a0, _a1)
|
|
|
|
var r0 bool
|
|
if rf, ok := ret.Get(0).(func(p2p.ChannelID, []byte) bool); ok {
|
|
r0 = rf(_a0, _a1)
|
|
} else {
|
|
r0 = ret.Get(0).(bool)
|
|
}
|
|
|
|
var r1 error
|
|
if rf, ok := ret.Get(1).(func(p2p.ChannelID, []byte) error); ok {
|
|
r1 = rf(_a0, _a1)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// Status provides a mock function with given fields:
|
|
func (_m *Connection) Status() conn.ConnectionStatus {
|
|
ret := _m.Called()
|
|
|
|
var r0 conn.ConnectionStatus
|
|
if rf, ok := ret.Get(0).(func() conn.ConnectionStatus); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(conn.ConnectionStatus)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// String provides a mock function with given fields:
|
|
func (_m *Connection) String() string {
|
|
ret := _m.Called()
|
|
|
|
var r0 string
|
|
if rf, ok := ret.Get(0).(func() string); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(string)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// TrySendMessage provides a mock function with given fields: _a0, _a1
|
|
func (_m *Connection) TrySendMessage(_a0 p2p.ChannelID, _a1 []byte) (bool, error) {
|
|
ret := _m.Called(_a0, _a1)
|
|
|
|
var r0 bool
|
|
if rf, ok := ret.Get(0).(func(p2p.ChannelID, []byte) bool); ok {
|
|
r0 = rf(_a0, _a1)
|
|
} else {
|
|
r0 = ret.Get(0).(bool)
|
|
}
|
|
|
|
var r1 error
|
|
if rf, ok := ret.Get(1).(func(p2p.ChannelID, []byte) error); ok {
|
|
r1 = rf(_a0, _a1)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|