From c83158f7a2cf9d3939604bf78aeecb1ba81e3e05 Mon Sep 17 00:00:00 2001 From: Moses Narrow Date: Sat, 16 Dec 2023 18:55:41 -0600 Subject: [PATCH] update / generate mocks with golang-mockery v2.35.4-1 --- pkg/app/appevent/utils.go | 4 +- pkg/mocks/API.go | 1457 +++++++++++++++++++++++++ pkg/mocks/APIClient.go | 151 +++ pkg/mocks/Autoconnector.go | 42 + pkg/mocks/Client.go | 57 + pkg/mocks/ConnectFn.go | 44 + pkg/mocks/Dialer.go | 72 ++ pkg/mocks/DiscoveryClient.go | 121 ++ pkg/mocks/EnvMaker.go | 50 + pkg/mocks/Handshake.go | 54 + pkg/mocks/HealthCheckable.go | 52 + pkg/mocks/Hook.go | 43 + pkg/mocks/IDReserver.go | 130 +++ pkg/mocks/Listener.go | 157 +++ pkg/mocks/LogStore.go | 137 +++ pkg/mocks/Metrics.go | 59 + pkg/mocks/Networker.go | 163 +++ pkg/mocks/PKTable.go | 91 ++ pkg/mocks/ProcManager.go | 336 ++++++ pkg/mocks/RPCClient.go | 75 ++ pkg/mocks/RPCIngressClient.go | 292 +++++ pkg/mocks/RouteGroupDialer.go | 60 + pkg/mocks/RouteSetupHook.go | 43 + pkg/mocks/Router.go | 291 +++++ pkg/mocks/SettlementHS.go | 48 + pkg/mocks/Store.go | 50 + pkg/mocks/Table.go | 174 +++ pkg/mocks/Transport.go | 275 +++++ pkg/mocks/Updater.go | 34 + pkg/mocks/UserStore.go | 109 ++ pkg/mocks/closeFn.go | 38 + pkg/mocks/dialFunc.go | 55 + pkg/mocks/handlerFunc.go | 33 + pkg/mocks/initFn.go | 45 + pkg/mocks/sendServicePacketFn.go | 33 + pkg/mocks/valuesFunc.go | 54 + pkg/skyenv/skyenv.go | 4 +- pkg/transport/errors.go | 4 +- pkg/utclient/mock_api_client.go | 2 +- pkg/util/osutil/privileges_windows.go | 4 +- pkg/visor/csrf.go | 3 +- 41 files changed, 4939 insertions(+), 7 deletions(-) create mode 100644 pkg/mocks/API.go create mode 100644 pkg/mocks/APIClient.go create mode 100644 pkg/mocks/Autoconnector.go create mode 100644 pkg/mocks/Client.go create mode 100644 pkg/mocks/ConnectFn.go create mode 100644 pkg/mocks/Dialer.go create mode 100644 pkg/mocks/DiscoveryClient.go create mode 100644 pkg/mocks/EnvMaker.go create mode 100644 pkg/mocks/Handshake.go create mode 100644 pkg/mocks/HealthCheckable.go create mode 100644 pkg/mocks/Hook.go create mode 100644 pkg/mocks/IDReserver.go create mode 100644 pkg/mocks/Listener.go create mode 100644 pkg/mocks/LogStore.go create mode 100644 pkg/mocks/Metrics.go create mode 100644 pkg/mocks/Networker.go create mode 100644 pkg/mocks/PKTable.go create mode 100644 pkg/mocks/ProcManager.go create mode 100644 pkg/mocks/RPCClient.go create mode 100644 pkg/mocks/RPCIngressClient.go create mode 100644 pkg/mocks/RouteGroupDialer.go create mode 100644 pkg/mocks/RouteSetupHook.go create mode 100644 pkg/mocks/Router.go create mode 100644 pkg/mocks/SettlementHS.go create mode 100644 pkg/mocks/Store.go create mode 100644 pkg/mocks/Table.go create mode 100644 pkg/mocks/Transport.go create mode 100644 pkg/mocks/Updater.go create mode 100644 pkg/mocks/UserStore.go create mode 100644 pkg/mocks/closeFn.go create mode 100644 pkg/mocks/dialFunc.go create mode 100644 pkg/mocks/handlerFunc.go create mode 100644 pkg/mocks/initFn.go create mode 100644 pkg/mocks/sendServicePacketFn.go create mode 100644 pkg/mocks/valuesFunc.go diff --git a/pkg/app/appevent/utils.go b/pkg/app/appevent/utils.go index 9997c1fb80..e92875161e 100644 --- a/pkg/app/appevent/utils.go +++ b/pkg/app/appevent/utils.go @@ -1,7 +1,9 @@ // Package appevent pkg/app/appevent/utils.go package appevent -import "context" +import ( + "context" +) // SendTCPDial sends tcp dial event func (eb *Broadcaster) SendTCPDial(ctx context.Context, remoteNet, remoteAddr string) { //nolint:all diff --git a/pkg/mocks/API.go b/pkg/mocks/API.go new file mode 100644 index 0000000000..a6429d2519 --- /dev/null +++ b/pkg/mocks/API.go @@ -0,0 +1,1457 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + appcommon "github.com/skycoin/skywire/pkg/app/appcommon" + appnet "github.com/skycoin/skywire/pkg/app/appnet" + + appserver "github.com/skycoin/skywire/pkg/app/appserver" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + routing "github.com/skycoin/skywire/pkg/routing" + + servicedisc "github.com/skycoin/skywire/pkg/servicedisc" + + time "time" + + transport "github.com/skycoin/skywire/pkg/transport" + + uuid "github.com/google/uuid" + + visor "github.com/skycoin/skywire/pkg/visor" + + visorconfig "github.com/skycoin/skywire/pkg/visor/visorconfig" +) + +// API is an autogenerated mock type for the API type +type API struct { + mock.Mock +} + +// AddApp provides a mock function with given fields: appName, binaryName +func (_m *API) AddApp(appName string, binaryName string) error { + ret := _m.Called(appName, binaryName) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, binaryName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// AddTransport provides a mock function with given fields: remote, tpType, timeout +func (_m *API) AddTransport(remote cipher.PubKey, tpType string, timeout time.Duration) (*visor.TransportSummary, error) { + ret := _m.Called(remote, tpType, timeout) + + var r0 *visor.TransportSummary + var r1 error + if rf, ok := ret.Get(0).(func(cipher.PubKey, string, time.Duration) (*visor.TransportSummary, error)); ok { + return rf(remote, tpType, timeout) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey, string, time.Duration) *visor.TransportSummary); ok { + r0 = rf(remote, tpType, timeout) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.TransportSummary) + } + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey, string, time.Duration) error); ok { + r1 = rf(remote, tpType, timeout) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// App provides a mock function with given fields: appName +func (_m *API) App(appName string) (*appserver.AppState, error) { + ret := _m.Called(appName) + + var r0 *appserver.AppState + var r1 error + if rf, ok := ret.Get(0).(func(string) (*appserver.AppState, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) *appserver.AppState); ok { + r0 = rf(appName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*appserver.AppState) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Apps provides a mock function with given fields: +func (_m *API) Apps() ([]*appserver.AppState, error) { + ret := _m.Called() + + var r0 []*appserver.AppState + var r1 error + if rf, ok := ret.Get(0).(func() ([]*appserver.AppState, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []*appserver.AppState); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*appserver.AppState) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Connect provides a mock function with given fields: remotePK, remotePort, localPort +func (_m *API) Connect(remotePK cipher.PubKey, remotePort int, localPort int) (uuid.UUID, error) { + ret := _m.Called(remotePK, remotePort, localPort) + + var r0 uuid.UUID + var r1 error + if rf, ok := ret.Get(0).(func(cipher.PubKey, int, int) (uuid.UUID, error)); ok { + return rf(remotePK, remotePort, localPort) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey, int, int) uuid.UUID); ok { + r0 = rf(remotePK, remotePort, localPort) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(uuid.UUID) + } + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey, int, int) error); ok { + r1 = rf(remotePK, remotePort, localPort) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteRewardAddress provides a mock function with given fields: +func (_m *API) DeleteRewardAddress() 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 +} + +// DeregisterApp provides a mock function with given fields: procKey +func (_m *API) DeregisterApp(procKey appcommon.ProcKey) error { + ret := _m.Called(procKey) + + var r0 error + if rf, ok := ret.Get(0).(func(appcommon.ProcKey) error); ok { + r0 = rf(procKey) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeregisterHTTPPort provides a mock function with given fields: localPort +func (_m *API) DeregisterHTTPPort(localPort int) error { + ret := _m.Called(localPort) + + var r0 error + if rf, ok := ret.Get(0).(func(int) error); ok { + r0 = rf(localPort) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DialPing provides a mock function with given fields: config +func (_m *API) DialPing(config visor.PingConfig) error { + ret := _m.Called(config) + + var r0 error + if rf, ok := ret.Get(0).(func(visor.PingConfig) error); ok { + r0 = rf(config) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Disconnect provides a mock function with given fields: id +func (_m *API) Disconnect(id uuid.UUID) error { + ret := _m.Called(id) + + var r0 error + if rf, ok := ret.Get(0).(func(uuid.UUID) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DiscoverTransportByID provides a mock function with given fields: id +func (_m *API) DiscoverTransportByID(id uuid.UUID) (*transport.Entry, error) { + ret := _m.Called(id) + + var r0 *transport.Entry + var r1 error + if rf, ok := ret.Get(0).(func(uuid.UUID) (*transport.Entry, error)); ok { + return rf(id) + } + if rf, ok := ret.Get(0).(func(uuid.UUID) *transport.Entry); ok { + r0 = rf(id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*transport.Entry) + } + } + + if rf, ok := ret.Get(1).(func(uuid.UUID) error); ok { + r1 = rf(id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DiscoverTransportsByPK provides a mock function with given fields: pk +func (_m *API) DiscoverTransportsByPK(pk cipher.PubKey) ([]*transport.Entry, error) { + ret := _m.Called(pk) + + var r0 []*transport.Entry + var r1 error + if rf, ok := ret.Get(0).(func(cipher.PubKey) ([]*transport.Entry, error)); ok { + return rf(pk) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey) []*transport.Entry); ok { + r0 = rf(pk) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*transport.Entry) + } + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey) error); ok { + r1 = rf(pk) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DoCustomSetting provides a mock function with given fields: appName, customSetting +func (_m *API) DoCustomSetting(appName string, customSetting map[string]string) error { + ret := _m.Called(appName, customSetting) + + var r0 error + if rf, ok := ret.Get(0).(func(string, map[string]string) error); ok { + r0 = rf(appName, customSetting) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FetchUptimeTrackerData provides a mock function with given fields: pk +func (_m *API) FetchUptimeTrackerData(pk string) ([]byte, error) { + ret := _m.Called(pk) + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]byte, error)); ok { + return rf(pk) + } + if rf, ok := ret.Get(0).(func(string) []byte); ok { + r0 = rf(pk) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(pk) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAppConnectionsSummary provides a mock function with given fields: appName +func (_m *API) GetAppConnectionsSummary(appName string) ([]appserver.ConnectionSummary, error) { + ret := _m.Called(appName) + + var r0 []appserver.ConnectionSummary + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]appserver.ConnectionSummary, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) []appserver.ConnectionSummary); ok { + r0 = rf(appName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]appserver.ConnectionSummary) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAppError provides a mock function with given fields: appName +func (_m *API) GetAppError(appName string) (string, error) { + ret := _m.Called(appName) + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string) (string, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetAppStats provides a mock function with given fields: appName +func (_m *API) GetAppStats(appName string) (appserver.AppStats, error) { + ret := _m.Called(appName) + + var r0 appserver.AppStats + var r1 error + if rf, ok := ret.Get(0).(func(string) (appserver.AppStats, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) appserver.AppStats); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(appserver.AppStats) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetLogRotationInterval provides a mock function with given fields: +func (_m *API) GetLogRotationInterval() (visorconfig.Duration, error) { + ret := _m.Called() + + var r0 visorconfig.Duration + var r1 error + if rf, ok := ret.Get(0).(func() (visorconfig.Duration, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() visorconfig.Duration); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(visorconfig.Duration) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetPersistentTransports provides a mock function with given fields: +func (_m *API) GetPersistentTransports() ([]transport.PersistentTransports, error) { + ret := _m.Called() + + var r0 []transport.PersistentTransports + var r1 error + if rf, ok := ret.Get(0).(func() ([]transport.PersistentTransports, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []transport.PersistentTransports); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]transport.PersistentTransports) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRewardAddress provides a mock function with given fields: +func (_m *API) GetRewardAddress() (string, error) { + ret := _m.Called() + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Health provides a mock function with given fields: +func (_m *API) Health() (*visor.HealthInfo, error) { + ret := _m.Called() + + var r0 *visor.HealthInfo + var r1 error + if rf, ok := ret.Get(0).(func() (*visor.HealthInfo, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *visor.HealthInfo); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.HealthInfo) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IsDMSGClientReady provides a mock function with given fields: +func (_m *API) IsDMSGClientReady() (bool, error) { + ret := _m.Called() + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func() (bool, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// List provides a mock function with given fields: +func (_m *API) List() (map[uuid.UUID]*appnet.ForwardConn, error) { + ret := _m.Called() + + var r0 map[uuid.UUID]*appnet.ForwardConn + var r1 error + if rf, ok := ret.Get(0).(func() (map[uuid.UUID]*appnet.ForwardConn, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() map[uuid.UUID]*appnet.ForwardConn); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[uuid.UUID]*appnet.ForwardConn) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListHTTPPorts provides a mock function with given fields: +func (_m *API) ListHTTPPorts() ([]int, error) { + ret := _m.Called() + + var r0 []int + var r1 error + if rf, ok := ret.Get(0).(func() ([]int, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []int); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]int) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LogsSince provides a mock function with given fields: timestamp, appName +func (_m *API) LogsSince(timestamp time.Time, appName string) ([]string, error) { + ret := _m.Called(timestamp, appName) + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(time.Time, string) ([]string, error)); ok { + return rf(timestamp, appName) + } + if rf, ok := ret.Get(0).(func(time.Time, string) []string); ok { + r0 = rf(timestamp, appName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(time.Time, string) error); ok { + r1 = rf(timestamp, appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Overview provides a mock function with given fields: +func (_m *API) Overview() (*visor.Overview, error) { + ret := _m.Called() + + var r0 *visor.Overview + var r1 error + if rf, ok := ret.Get(0).(func() (*visor.Overview, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *visor.Overview); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.Overview) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ping provides a mock function with given fields: config +func (_m *API) Ping(config visor.PingConfig) ([]time.Duration, error) { + ret := _m.Called(config) + + var r0 []time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(visor.PingConfig) ([]time.Duration, error)); ok { + return rf(config) + } + if rf, ok := ret.Get(0).(func(visor.PingConfig) []time.Duration); ok { + r0 = rf(config) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]time.Duration) + } + } + + if rf, ok := ret.Get(1).(func(visor.PingConfig) error); ok { + r1 = rf(config) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ports provides a mock function with given fields: +func (_m *API) Ports() (map[string]visor.PortDetail, error) { + ret := _m.Called() + + var r0 map[string]visor.PortDetail + var r1 error + if rf, ok := ret.Get(0).(func() (map[string]visor.PortDetail, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() map[string]visor.PortDetail); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]visor.PortDetail) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ProxyServers provides a mock function with given fields: version, country +func (_m *API) ProxyServers(version string, country string) ([]servicedisc.Service, error) { + ret := _m.Called(version, country) + + var r0 []servicedisc.Service + var r1 error + if rf, ok := ret.Get(0).(func(string, string) ([]servicedisc.Service, error)); ok { + return rf(version, country) + } + if rf, ok := ret.Get(0).(func(string, string) []servicedisc.Service); ok { + r0 = rf(version, country) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]servicedisc.Service) + } + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(version, country) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RegisterApp provides a mock function with given fields: procConf +func (_m *API) RegisterApp(procConf appcommon.ProcConfig) (appcommon.ProcKey, error) { + ret := _m.Called(procConf) + + var r0 appcommon.ProcKey + var r1 error + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) (appcommon.ProcKey, error)); ok { + return rf(procConf) + } + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) appcommon.ProcKey); ok { + r0 = rf(procConf) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(appcommon.ProcKey) + } + } + + if rf, ok := ret.Get(1).(func(appcommon.ProcConfig) error); ok { + r1 = rf(procConf) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RegisterHTTPPort provides a mock function with given fields: localPort +func (_m *API) RegisterHTTPPort(localPort int) error { + ret := _m.Called(localPort) + + var r0 error + if rf, ok := ret.Get(0).(func(int) error); ok { + r0 = rf(localPort) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Reload provides a mock function with given fields: +func (_m *API) Reload() 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 +} + +// RemoteVisors provides a mock function with given fields: +func (_m *API) RemoteVisors() ([]string, error) { + ret := _m.Called() + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func() ([]string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RemoveRoutingRule provides a mock function with given fields: key +func (_m *API) RemoveRoutingRule(key routing.RouteID) error { + ret := _m.Called(key) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.RouteID) error); ok { + r0 = rf(key) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// RemoveTransport provides a mock function with given fields: tid +func (_m *API) RemoveTransport(tid uuid.UUID) error { + ret := _m.Called(tid) + + var r0 error + if rf, ok := ret.Get(0).(func(uuid.UUID) error); ok { + r0 = rf(tid) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// RestartApp provides a mock function with given fields: appName +func (_m *API) RestartApp(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// RouteGroups provides a mock function with given fields: +func (_m *API) RouteGroups() ([]visor.RouteGroupInfo, error) { + ret := _m.Called() + + var r0 []visor.RouteGroupInfo + var r1 error + if rf, ok := ret.Get(0).(func() ([]visor.RouteGroupInfo, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []visor.RouteGroupInfo); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]visor.RouteGroupInfo) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RoutingRule provides a mock function with given fields: key +func (_m *API) RoutingRule(key routing.RouteID) (routing.Rule, error) { + ret := _m.Called(key) + + var r0 routing.Rule + var r1 error + if rf, ok := ret.Get(0).(func(routing.RouteID) (routing.Rule, error)); ok { + return rf(key) + } + if rf, ok := ret.Get(0).(func(routing.RouteID) routing.Rule); ok { + r0 = rf(key) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(routing.Rule) + } + } + + if rf, ok := ret.Get(1).(func(routing.RouteID) error); ok { + r1 = rf(key) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RoutingRules provides a mock function with given fields: +func (_m *API) RoutingRules() ([]routing.Rule, error) { + ret := _m.Called() + + var r0 []routing.Rule + var r1 error + if rf, ok := ret.Get(0).(func() ([]routing.Rule, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []routing.Rule); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.Rule) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RuntimeLogs provides a mock function with given fields: +func (_m *API) RuntimeLogs() (string, error) { + ret := _m.Called() + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SaveRoutingRule provides a mock function with given fields: rule +func (_m *API) SaveRoutingRule(rule routing.Rule) error { + ret := _m.Called(rule) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.Rule) error); ok { + r0 = rf(rule) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppAddress provides a mock function with given fields: appName, address +func (_m *API) SetAppAddress(appName string, address string) error { + ret := _m.Called(appName, address) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, address) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppDNS provides a mock function with given fields: appName, dnsaddr +func (_m *API) SetAppDNS(appName string, dnsaddr string) error { + ret := _m.Called(appName, dnsaddr) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, dnsaddr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppDetailedStatus provides a mock function with given fields: appName, state +func (_m *API) SetAppDetailedStatus(appName string, state string) error { + ret := _m.Called(appName, state) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, state) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppError provides a mock function with given fields: appName, stateErr +func (_m *API) SetAppError(appName string, stateErr string) error { + ret := _m.Called(appName, stateErr) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, stateErr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppKillswitch provides a mock function with given fields: appName, killswitch +func (_m *API) SetAppKillswitch(appName string, killswitch bool) error { + ret := _m.Called(appName, killswitch) + + var r0 error + if rf, ok := ret.Get(0).(func(string, bool) error); ok { + r0 = rf(appName, killswitch) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppNetworkInterface provides a mock function with given fields: appName, netifc +func (_m *API) SetAppNetworkInterface(appName string, netifc string) error { + ret := _m.Called(appName, netifc) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, netifc) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppPK provides a mock function with given fields: appName, pk +func (_m *API) SetAppPK(appName string, pk cipher.PubKey) error { + ret := _m.Called(appName, pk) + + var r0 error + if rf, ok := ret.Get(0).(func(string, cipher.PubKey) error); ok { + r0 = rf(appName, pk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppPassword provides a mock function with given fields: appName, password +func (_m *API) SetAppPassword(appName string, password string) error { + ret := _m.Called(appName, password) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, password) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAppSecure provides a mock function with given fields: appName, isSecure +func (_m *API) SetAppSecure(appName string, isSecure bool) error { + ret := _m.Called(appName, isSecure) + + var r0 error + if rf, ok := ret.Get(0).(func(string, bool) error); ok { + r0 = rf(appName, isSecure) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetAutoStart provides a mock function with given fields: appName, autostart +func (_m *API) SetAutoStart(appName string, autostart bool) error { + ret := _m.Called(appName, autostart) + + var r0 error + if rf, ok := ret.Get(0).(func(string, bool) error); ok { + r0 = rf(appName, autostart) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetLogRotationInterval provides a mock function with given fields: _a0 +func (_m *API) SetLogRotationInterval(_a0 visorconfig.Duration) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(visorconfig.Duration) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetMinHops provides a mock function with given fields: _a0 +func (_m *API) SetMinHops(_a0 uint16) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetPersistentTransports provides a mock function with given fields: _a0 +func (_m *API) SetPersistentTransports(_a0 []transport.PersistentTransports) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func([]transport.PersistentTransports) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetPublicAutoconnect provides a mock function with given fields: pAc +func (_m *API) SetPublicAutoconnect(pAc bool) error { + ret := _m.Called(pAc) + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(pAc) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetRewardAddress provides a mock function with given fields: _a0 +func (_m *API) SetRewardAddress(_a0 string) (string, error) { + ret := _m.Called(_a0) + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string) (string, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Shutdown provides a mock function with given fields: +func (_m *API) Shutdown() 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 +} + +// StartApp provides a mock function with given fields: appName +func (_m *API) StartApp(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StartSkysocksClient provides a mock function with given fields: pk +func (_m *API) StartSkysocksClient(pk string) error { + ret := _m.Called(pk) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(pk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StartVPNClient provides a mock function with given fields: pk +func (_m *API) StartVPNClient(pk cipher.PubKey) error { + ret := _m.Called(pk) + + var r0 error + if rf, ok := ret.Get(0).(func(cipher.PubKey) error); ok { + r0 = rf(pk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StopApp provides a mock function with given fields: appName +func (_m *API) StopApp(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StopPing provides a mock function with given fields: pk +func (_m *API) StopPing(pk cipher.PubKey) error { + ret := _m.Called(pk) + + var r0 error + if rf, ok := ret.Get(0).(func(cipher.PubKey) error); ok { + r0 = rf(pk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StopSkysocksClients provides a mock function with given fields: +func (_m *API) StopSkysocksClients() 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 +} + +// StopVPNClient provides a mock function with given fields: appName +func (_m *API) StopVPNClient(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Summary provides a mock function with given fields: +func (_m *API) Summary() (*visor.Summary, error) { + ret := _m.Called() + + var r0 *visor.Summary + var r1 error + if rf, ok := ret.Get(0).(func() (*visor.Summary, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *visor.Summary); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.Summary) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TestVisor provides a mock function with given fields: config +func (_m *API) TestVisor(config visor.PingConfig) ([]visor.TestResult, error) { + ret := _m.Called(config) + + var r0 []visor.TestResult + var r1 error + if rf, ok := ret.Get(0).(func(visor.PingConfig) ([]visor.TestResult, error)); ok { + return rf(config) + } + if rf, ok := ret.Get(0).(func(visor.PingConfig) []visor.TestResult); ok { + r0 = rf(config) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]visor.TestResult) + } + } + + if rf, ok := ret.Get(1).(func(visor.PingConfig) error); ok { + r1 = rf(config) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Transport provides a mock function with given fields: tid +func (_m *API) Transport(tid uuid.UUID) (*visor.TransportSummary, error) { + ret := _m.Called(tid) + + var r0 *visor.TransportSummary + var r1 error + if rf, ok := ret.Get(0).(func(uuid.UUID) (*visor.TransportSummary, error)); ok { + return rf(tid) + } + if rf, ok := ret.Get(0).(func(uuid.UUID) *visor.TransportSummary); ok { + r0 = rf(tid) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.TransportSummary) + } + } + + if rf, ok := ret.Get(1).(func(uuid.UUID) error); ok { + r1 = rf(tid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TransportTypes provides a mock function with given fields: +func (_m *API) TransportTypes() ([]string, error) { + ret := _m.Called() + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func() ([]string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Transports provides a mock function with given fields: types, pks, logs +func (_m *API) Transports(types []string, pks []cipher.PubKey, logs bool) ([]*visor.TransportSummary, error) { + ret := _m.Called(types, pks, logs) + + var r0 []*visor.TransportSummary + var r1 error + if rf, ok := ret.Get(0).(func([]string, []cipher.PubKey, bool) ([]*visor.TransportSummary, error)); ok { + return rf(types, pks, logs) + } + if rf, ok := ret.Get(0).(func([]string, []cipher.PubKey, bool) []*visor.TransportSummary); ok { + r0 = rf(types, pks, logs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*visor.TransportSummary) + } + } + + if rf, ok := ret.Get(1).(func([]string, []cipher.PubKey, bool) error); ok { + r1 = rf(types, pks, logs) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Uptime provides a mock function with given fields: +func (_m *API) Uptime() (float64, error) { + ret := _m.Called() + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// VPNServers provides a mock function with given fields: version, country +func (_m *API) VPNServers(version string, country string) ([]servicedisc.Service, error) { + ret := _m.Called(version, country) + + var r0 []servicedisc.Service + var r1 error + if rf, ok := ret.Get(0).(func(string, string) ([]servicedisc.Service, error)); ok { + return rf(version, country) + } + if rf, ok := ret.Get(0).(func(string, string) []servicedisc.Service); ok { + r0 = rf(version, country) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]servicedisc.Service) + } + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(version, country) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewAPI creates a new instance of API. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewAPI(t interface { + mock.TestingT + Cleanup(func()) +}) *API { + mock := &API{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/APIClient.go b/pkg/mocks/APIClient.go new file mode 100644 index 0000000000..5e9967763d --- /dev/null +++ b/pkg/mocks/APIClient.go @@ -0,0 +1,151 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + addrresolver "github.com/skycoin/skywire/pkg/transport/network/addrresolver" + + context "context" + + mock "github.com/stretchr/testify/mock" + + pfilter "github.com/AudriusButkevicius/pfilter" +) + +// APIClient is an autogenerated mock type for the APIClient type +type APIClient struct { + mock.Mock +} + +// Addresses provides a mock function with given fields: ctx +func (_m *APIClient) Addresses(ctx context.Context) string { + ret := _m.Called(ctx) + + var r0 string + if rf, ok := ret.Get(0).(func(context.Context) string); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// BindSTCPR provides a mock function with given fields: ctx, port +func (_m *APIClient) BindSTCPR(ctx context.Context, port string) error { + ret := _m.Called(ctx, port) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, port) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// BindSUDPH provides a mock function with given fields: filter, handshake +func (_m *APIClient) BindSUDPH(filter *pfilter.PacketFilter, handshake addrresolver.Handshake) (<-chan addrresolver.RemoteVisor, error) { + ret := _m.Called(filter, handshake) + + var r0 <-chan addrresolver.RemoteVisor + var r1 error + if rf, ok := ret.Get(0).(func(*pfilter.PacketFilter, addrresolver.Handshake) (<-chan addrresolver.RemoteVisor, error)); ok { + return rf(filter, handshake) + } + if rf, ok := ret.Get(0).(func(*pfilter.PacketFilter, addrresolver.Handshake) <-chan addrresolver.RemoteVisor); ok { + r0 = rf(filter, handshake) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(<-chan addrresolver.RemoteVisor) + } + } + + if rf, ok := ret.Get(1).(func(*pfilter.PacketFilter, addrresolver.Handshake) error); ok { + r1 = rf(filter, handshake) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Close provides a mock function with given fields: +func (_m *APIClient) 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 +} + +// Resolve provides a mock function with given fields: ctx, netType, pk +func (_m *APIClient) Resolve(ctx context.Context, netType string, pk cipher.PubKey) (addrresolver.VisorData, error) { + ret := _m.Called(ctx, netType, pk) + + var r0 addrresolver.VisorData + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, cipher.PubKey) (addrresolver.VisorData, error)); ok { + return rf(ctx, netType, pk) + } + if rf, ok := ret.Get(0).(func(context.Context, string, cipher.PubKey) addrresolver.VisorData); ok { + r0 = rf(ctx, netType, pk) + } else { + r0 = ret.Get(0).(addrresolver.VisorData) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, cipher.PubKey) error); ok { + r1 = rf(ctx, netType, pk) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Transports provides a mock function with given fields: ctx +func (_m *APIClient) Transports(ctx context.Context) (map[cipher.PubKey][]string, error) { + ret := _m.Called(ctx) + + var r0 map[cipher.PubKey][]string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (map[cipher.PubKey][]string, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) map[cipher.PubKey][]string); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[cipher.PubKey][]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewAPIClient creates a new instance of APIClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewAPIClient(t interface { + mock.TestingT + Cleanup(func()) +}) *APIClient { + mock := &APIClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Autoconnector.go b/pkg/mocks/Autoconnector.go new file mode 100644 index 0000000000..75d8c00a09 --- /dev/null +++ b/pkg/mocks/Autoconnector.go @@ -0,0 +1,42 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// Autoconnector is an autogenerated mock type for the Autoconnector type +type Autoconnector struct { + mock.Mock +} + +// Run provides a mock function with given fields: _a0 +func (_m *Autoconnector) Run(_a0 context.Context) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewAutoconnector creates a new instance of Autoconnector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewAutoconnector(t interface { + mock.TestingT + Cleanup(func()) +}) *Autoconnector { + mock := &Autoconnector{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Client.go b/pkg/mocks/Client.go new file mode 100644 index 0000000000..27fe48a918 --- /dev/null +++ b/pkg/mocks/Client.go @@ -0,0 +1,57 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + rfclient "github.com/skycoin/skywire/pkg/routefinder/rfclient" + mock "github.com/stretchr/testify/mock" + + routing "github.com/skycoin/skywire/pkg/routing" +) + +// Client is an autogenerated mock type for the Client type +type Client struct { + mock.Mock +} + +// FindRoutes provides a mock function with given fields: ctx, rts, opts +func (_m *Client) FindRoutes(ctx context.Context, rts []routing.PathEdges, opts *rfclient.RouteOptions) (map[routing.PathEdges][][]routing.Hop, error) { + ret := _m.Called(ctx, rts, opts) + + var r0 map[routing.PathEdges][][]routing.Hop + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []routing.PathEdges, *rfclient.RouteOptions) (map[routing.PathEdges][][]routing.Hop, error)); ok { + return rf(ctx, rts, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, []routing.PathEdges, *rfclient.RouteOptions) map[routing.PathEdges][][]routing.Hop); ok { + r0 = rf(ctx, rts, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[routing.PathEdges][][]routing.Hop) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []routing.PathEdges, *rfclient.RouteOptions) error); ok { + r1 = rf(ctx, rts, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewClient(t interface { + mock.TestingT + Cleanup(func()) +}) *Client { + mock := &Client{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/ConnectFn.go b/pkg/mocks/ConnectFn.go new file mode 100644 index 0000000000..d5ab5797e4 --- /dev/null +++ b/pkg/mocks/ConnectFn.go @@ -0,0 +1,44 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" +) + +// ConnectFn is an autogenerated mock type for the ConnectFn type +type ConnectFn struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, _a1 +func (_m *ConnectFn) Execute(_a0 context.Context, _a1 cipher.PubKey) error { + ret := _m.Called(_a0, _a1) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewConnectFn creates a new instance of ConnectFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConnectFn(t interface { + mock.TestingT + Cleanup(func()) +}) *ConnectFn { + mock := &ConnectFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Dialer.go b/pkg/mocks/Dialer.go new file mode 100644 index 0000000000..d29dde8214 --- /dev/null +++ b/pkg/mocks/Dialer.go @@ -0,0 +1,72 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + net "net" +) + +// Dialer is an autogenerated mock type for the Dialer type +type Dialer struct { + mock.Mock +} + +// Dial provides a mock function with given fields: ctx, remote, port +func (_m *Dialer) Dial(ctx context.Context, remote cipher.PubKey, port uint16) (net.Conn, error) { + ret := _m.Called(ctx, remote, port) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, uint16) (net.Conn, error)); ok { + return rf(ctx, remote, port) + } + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, uint16) net.Conn); ok { + r0 = rf(ctx, remote, port) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, cipher.PubKey, uint16) error); ok { + r1 = rf(ctx, remote, port) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Type provides a mock function with given fields: +func (_m *Dialer) Type() 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 +} + +// NewDialer creates a new instance of Dialer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDialer(t interface { + mock.TestingT + Cleanup(func()) +}) *Dialer { + mock := &Dialer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/DiscoveryClient.go b/pkg/mocks/DiscoveryClient.go new file mode 100644 index 0000000000..a14fa46458 --- /dev/null +++ b/pkg/mocks/DiscoveryClient.go @@ -0,0 +1,121 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + transport "github.com/skycoin/skywire/pkg/transport" + + uuid "github.com/google/uuid" +) + +// DiscoveryClient is an autogenerated mock type for the DiscoveryClient type +type DiscoveryClient struct { + mock.Mock +} + +// DeleteTransport provides a mock function with given fields: ctx, id +func (_m *DiscoveryClient) DeleteTransport(ctx context.Context, id uuid.UUID) error { + ret := _m.Called(ctx, id) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetTransportByID provides a mock function with given fields: ctx, id +func (_m *DiscoveryClient) GetTransportByID(ctx context.Context, id uuid.UUID) (*transport.Entry, error) { + ret := _m.Called(ctx, id) + + var r0 *transport.Entry + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*transport.Entry, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *transport.Entry); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*transport.Entry) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetTransportsByEdge provides a mock function with given fields: ctx, pk +func (_m *DiscoveryClient) GetTransportsByEdge(ctx context.Context, pk cipher.PubKey) ([]*transport.Entry, error) { + ret := _m.Called(ctx, pk) + + var r0 []*transport.Entry + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey) ([]*transport.Entry, error)); ok { + return rf(ctx, pk) + } + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey) []*transport.Entry); ok { + r0 = rf(ctx, pk) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*transport.Entry) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, cipher.PubKey) error); ok { + r1 = rf(ctx, pk) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RegisterTransports provides a mock function with given fields: ctx, entries +func (_m *DiscoveryClient) RegisterTransports(ctx context.Context, entries ...*transport.SignedEntry) error { + _va := make([]interface{}, len(entries)) + for _i := range entries { + _va[_i] = entries[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, ...*transport.SignedEntry) error); ok { + r0 = rf(ctx, entries...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewDiscoveryClient creates a new instance of DiscoveryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDiscoveryClient(t interface { + mock.TestingT + Cleanup(func()) +}) *DiscoveryClient { + mock := &DiscoveryClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/EnvMaker.go b/pkg/mocks/EnvMaker.go new file mode 100644 index 0000000000..1188dbe6dd --- /dev/null +++ b/pkg/mocks/EnvMaker.go @@ -0,0 +1,50 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// EnvMaker is an autogenerated mock type for the EnvMaker type +type EnvMaker struct { + mock.Mock +} + +// Execute provides a mock function with given fields: +func (_m *EnvMaker) Execute() ([]string, error) { + ret := _m.Called() + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func() ([]string, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewEnvMaker creates a new instance of EnvMaker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEnvMaker(t interface { + mock.TestingT + Cleanup(func()) +}) *EnvMaker { + mock := &EnvMaker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Handshake.go b/pkg/mocks/Handshake.go new file mode 100644 index 0000000000..bbce789622 --- /dev/null +++ b/pkg/mocks/Handshake.go @@ -0,0 +1,54 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + net "net" + + mock "github.com/stretchr/testify/mock" +) + +// Handshake is an autogenerated mock type for the Handshake type +type Handshake struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0 +func (_m *Handshake) Execute(_a0 net.Conn) (net.Conn, error) { + ret := _m.Called(_a0) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(net.Conn) (net.Conn, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(net.Conn) net.Conn); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(net.Conn) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewHandshake creates a new instance of Handshake. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewHandshake(t interface { + mock.TestingT + Cleanup(func()) +}) *Handshake { + mock := &Handshake{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/HealthCheckable.go b/pkg/mocks/HealthCheckable.go new file mode 100644 index 0000000000..76cdd74305 --- /dev/null +++ b/pkg/mocks/HealthCheckable.go @@ -0,0 +1,52 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// HealthCheckable is an autogenerated mock type for the HealthCheckable type +type HealthCheckable struct { + mock.Mock +} + +// Health provides a mock function with given fields: ctx +func (_m *HealthCheckable) Health(ctx context.Context) (int, error) { + ret := _m.Called(ctx) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) int); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewHealthCheckable creates a new instance of HealthCheckable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewHealthCheckable(t interface { + mock.TestingT + Cleanup(func()) +}) *HealthCheckable { + mock := &HealthCheckable{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Hook.go b/pkg/mocks/Hook.go new file mode 100644 index 0000000000..263bce4cfb --- /dev/null +++ b/pkg/mocks/Hook.go @@ -0,0 +1,43 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + logging "github.com/skycoin/skywire-utilities/pkg/logging" + mock "github.com/stretchr/testify/mock" +) + +// Hook is an autogenerated mock type for the Hook type +type Hook struct { + mock.Mock +} + +// Execute provides a mock function with given fields: ctx, log +func (_m *Hook) Execute(ctx context.Context, log *logging.Logger) error { + ret := _m.Called(ctx, log) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *logging.Logger) error); ok { + r0 = rf(ctx, log) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewHook creates a new instance of Hook. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewHook(t interface { + mock.TestingT + Cleanup(func()) +}) *Hook { + mock := &Hook{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/IDReserver.go b/pkg/mocks/IDReserver.go new file mode 100644 index 0000000000..e432156169 --- /dev/null +++ b/pkg/mocks/IDReserver.go @@ -0,0 +1,130 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + router "github.com/skycoin/skywire/pkg/router" + + routing "github.com/skycoin/skywire/pkg/routing" +) + +// IDReserver is an autogenerated mock type for the IDReserver type +type IDReserver struct { + mock.Mock +} + +// Client provides a mock function with given fields: pk +func (_m *IDReserver) Client(pk cipher.PubKey) *router.Client { + ret := _m.Called(pk) + + var r0 *router.Client + if rf, ok := ret.Get(0).(func(cipher.PubKey) *router.Client); ok { + r0 = rf(pk) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*router.Client) + } + } + + return r0 +} + +// Close provides a mock function with given fields: +func (_m *IDReserver) 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 +} + +// PopID provides a mock function with given fields: pk +func (_m *IDReserver) PopID(pk cipher.PubKey) (routing.RouteID, bool) { + ret := _m.Called(pk) + + var r0 routing.RouteID + var r1 bool + if rf, ok := ret.Get(0).(func(cipher.PubKey) (routing.RouteID, bool)); ok { + return rf(pk) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey) routing.RouteID); ok { + r0 = rf(pk) + } else { + r0 = ret.Get(0).(routing.RouteID) + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey) bool); ok { + r1 = rf(pk) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// ReserveIDs provides a mock function with given fields: ctx +func (_m *IDReserver) ReserveIDs(ctx context.Context) error { + ret := _m.Called(ctx) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// String provides a mock function with given fields: +func (_m *IDReserver) 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 +} + +// TotalIDs provides a mock function with given fields: +func (_m *IDReserver) TotalIDs() int { + ret := _m.Called() + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// NewIDReserver creates a new instance of IDReserver. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIDReserver(t interface { + mock.TestingT + Cleanup(func()) +}) *IDReserver { + mock := &IDReserver{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Listener.go b/pkg/mocks/Listener.go new file mode 100644 index 0000000000..2cf6a81d2b --- /dev/null +++ b/pkg/mocks/Listener.go @@ -0,0 +1,157 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + mock "github.com/stretchr/testify/mock" + + net "net" + + network "github.com/skycoin/skywire/pkg/transport/network" +) + +// Listener is an autogenerated mock type for the Listener type +type Listener struct { + mock.Mock +} + +// Accept provides a mock function with given fields: +func (_m *Listener) Accept() (net.Conn, error) { + ret := _m.Called() + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func() (net.Conn, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() net.Conn); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// AcceptTransport provides a mock function with given fields: +func (_m *Listener) AcceptTransport() (network.Transport, error) { + ret := _m.Called() + + var r0 network.Transport + var r1 error + if rf, ok := ret.Get(0).(func() (network.Transport, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() network.Transport); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(network.Transport) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Addr provides a mock function with given fields: +func (_m *Listener) Addr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// Close provides a mock function with given fields: +func (_m *Listener) 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 +} + +// Network provides a mock function with given fields: +func (_m *Listener) Network() network.Type { + ret := _m.Called() + + var r0 network.Type + if rf, ok := ret.Get(0).(func() network.Type); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(network.Type) + } + + return r0 +} + +// PK provides a mock function with given fields: +func (_m *Listener) PK() cipher.PubKey { + ret := _m.Called() + + var r0 cipher.PubKey + if rf, ok := ret.Get(0).(func() cipher.PubKey); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(cipher.PubKey) + } + } + + return r0 +} + +// Port provides a mock function with given fields: +func (_m *Listener) Port() uint16 { + ret := _m.Called() + + var r0 uint16 + if rf, ok := ret.Get(0).(func() uint16); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint16) + } + + return r0 +} + +// NewListener creates a new instance of Listener. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewListener(t interface { + mock.TestingT + Cleanup(func()) +}) *Listener { + mock := &Listener{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/LogStore.go b/pkg/mocks/LogStore.go new file mode 100644 index 0000000000..d1f0a32297 --- /dev/null +++ b/pkg/mocks/LogStore.go @@ -0,0 +1,137 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + logrus "github.com/sirupsen/logrus" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// LogStore is an autogenerated mock type for the LogStore type +type LogStore struct { + mock.Mock +} + +// Fire provides a mock function with given fields: entry +func (_m *LogStore) Fire(entry *logrus.Entry) error { + ret := _m.Called(entry) + + var r0 error + if rf, ok := ret.Get(0).(func(*logrus.Entry) error); ok { + r0 = rf(entry) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Flush provides a mock function with given fields: +func (_m *LogStore) Flush() 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 +} + +// Levels provides a mock function with given fields: +func (_m *LogStore) Levels() []logrus.Level { + ret := _m.Called() + + var r0 []logrus.Level + if rf, ok := ret.Get(0).(func() []logrus.Level); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]logrus.Level) + } + } + + return r0 +} + +// LogsSince provides a mock function with given fields: t +func (_m *LogStore) LogsSince(t time.Time) ([]string, error) { + ret := _m.Called(t) + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(time.Time) ([]string, error)); ok { + return rf(t) + } + if rf, ok := ret.Get(0).(func(time.Time) []string); ok { + r0 = rf(t) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(time.Time) error); ok { + r1 = rf(t) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Store provides a mock function with given fields: t, s +func (_m *LogStore) Store(t time.Time, s string) error { + ret := _m.Called(t, s) + + var r0 error + if rf, ok := ret.Get(0).(func(time.Time, string) error); ok { + r0 = rf(t, s) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Write provides a mock function with given fields: p +func (_m *LogStore) Write(p []byte) (int, error) { + ret := _m.Called(p) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok { + return rf(p) + } + if rf, ok := ret.Get(0).(func([]byte) int); ok { + r0 = rf(p) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(p) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewLogStore creates a new instance of LogStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLogStore(t interface { + mock.TestingT + Cleanup(func()) +}) *LogStore { + mock := &LogStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Metrics.go b/pkg/mocks/Metrics.go new file mode 100644 index 0000000000..57344560d1 --- /dev/null +++ b/pkg/mocks/Metrics.go @@ -0,0 +1,59 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + routing "github.com/skycoin/skywire/pkg/routing" + mock "github.com/stretchr/testify/mock" +) + +// Metrics is an autogenerated mock type for the Metrics type +type Metrics struct { + mock.Mock +} + +// RecordRequest provides a mock function with given fields: +func (_m *Metrics) RecordRequest() func(*routing.EdgeRules, *error) { + ret := _m.Called() + + var r0 func(*routing.EdgeRules, *error) + if rf, ok := ret.Get(0).(func() func(*routing.EdgeRules, *error)); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(func(*routing.EdgeRules, *error)) + } + } + + return r0 +} + +// RecordRoute provides a mock function with given fields: +func (_m *Metrics) RecordRoute() func(*error) { + ret := _m.Called() + + var r0 func(*error) + if rf, ok := ret.Get(0).(func() func(*error)); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(func(*error)) + } + } + + return r0 +} + +// NewMetrics creates a new instance of Metrics. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMetrics(t interface { + mock.TestingT + Cleanup(func()) +}) *Metrics { + mock := &Metrics{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Networker.go b/pkg/mocks/Networker.go new file mode 100644 index 0000000000..a7a32ee3b5 --- /dev/null +++ b/pkg/mocks/Networker.go @@ -0,0 +1,163 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + appnet "github.com/skycoin/skywire/pkg/app/appnet" + + context "context" + + mock "github.com/stretchr/testify/mock" + + net "net" +) + +// Networker is an autogenerated mock type for the Networker type +type Networker struct { + mock.Mock +} + +// Dial provides a mock function with given fields: addr +func (_m *Networker) Dial(addr appnet.Addr) (net.Conn, error) { + ret := _m.Called(addr) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(appnet.Addr) (net.Conn, error)); ok { + return rf(addr) + } + if rf, ok := ret.Get(0).(func(appnet.Addr) net.Conn); ok { + r0 = rf(addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(appnet.Addr) error); ok { + r1 = rf(addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DialContext provides a mock function with given fields: ctx, addr +func (_m *Networker) DialContext(ctx context.Context, addr appnet.Addr) (net.Conn, error) { + ret := _m.Called(ctx, addr) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, appnet.Addr) (net.Conn, error)); ok { + return rf(ctx, addr) + } + if rf, ok := ret.Get(0).(func(context.Context, appnet.Addr) net.Conn); ok { + r0 = rf(ctx, addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, appnet.Addr) error); ok { + r1 = rf(ctx, addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Listen provides a mock function with given fields: addr +func (_m *Networker) Listen(addr appnet.Addr) (net.Listener, error) { + ret := _m.Called(addr) + + var r0 net.Listener + var r1 error + if rf, ok := ret.Get(0).(func(appnet.Addr) (net.Listener, error)); ok { + return rf(addr) + } + if rf, ok := ret.Get(0).(func(appnet.Addr) net.Listener); ok { + r0 = rf(addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Listener) + } + } + + if rf, ok := ret.Get(1).(func(appnet.Addr) error); ok { + r1 = rf(addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListenContext provides a mock function with given fields: ctx, addr +func (_m *Networker) ListenContext(ctx context.Context, addr appnet.Addr) (net.Listener, error) { + ret := _m.Called(ctx, addr) + + var r0 net.Listener + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, appnet.Addr) (net.Listener, error)); ok { + return rf(ctx, addr) + } + if rf, ok := ret.Get(0).(func(context.Context, appnet.Addr) net.Listener); ok { + r0 = rf(ctx, addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Listener) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, appnet.Addr) error); ok { + r1 = rf(ctx, addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Ping provides a mock function with given fields: pk, addr +func (_m *Networker) Ping(pk cipher.PubKey, addr appnet.Addr) (net.Conn, error) { + ret := _m.Called(pk, addr) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(cipher.PubKey, appnet.Addr) (net.Conn, error)); ok { + return rf(pk, addr) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey, appnet.Addr) net.Conn); ok { + r0 = rf(pk, addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey, appnet.Addr) error); ok { + r1 = rf(pk, addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewNetworker creates a new instance of Networker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewNetworker(t interface { + mock.TestingT + Cleanup(func()) +}) *Networker { + mock := &Networker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/PKTable.go b/pkg/mocks/PKTable.go new file mode 100644 index 0000000000..3201cd50df --- /dev/null +++ b/pkg/mocks/PKTable.go @@ -0,0 +1,91 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + mock "github.com/stretchr/testify/mock" +) + +// PKTable is an autogenerated mock type for the PKTable type +type PKTable struct { + mock.Mock +} + +// Addr provides a mock function with given fields: pk +func (_m *PKTable) Addr(pk cipher.PubKey) (string, bool) { + ret := _m.Called(pk) + + var r0 string + var r1 bool + if rf, ok := ret.Get(0).(func(cipher.PubKey) (string, bool)); ok { + return rf(pk) + } + if rf, ok := ret.Get(0).(func(cipher.PubKey) string); ok { + r0 = rf(pk) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(cipher.PubKey) bool); ok { + r1 = rf(pk) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// Count provides a mock function with given fields: +func (_m *PKTable) Count() int { + ret := _m.Called() + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// PubKey provides a mock function with given fields: addr +func (_m *PKTable) PubKey(addr string) (cipher.PubKey, bool) { + ret := _m.Called(addr) + + var r0 cipher.PubKey + var r1 bool + if rf, ok := ret.Get(0).(func(string) (cipher.PubKey, bool)); ok { + return rf(addr) + } + if rf, ok := ret.Get(0).(func(string) cipher.PubKey); ok { + r0 = rf(addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(cipher.PubKey) + } + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(addr) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// NewPKTable creates a new instance of PKTable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPKTable(t interface { + mock.TestingT + Cleanup(func()) +}) *PKTable { + mock := &PKTable{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/ProcManager.go b/pkg/mocks/ProcManager.go new file mode 100644 index 0000000000..1213619d92 --- /dev/null +++ b/pkg/mocks/ProcManager.go @@ -0,0 +1,336 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + appcommon "github.com/skycoin/skywire/pkg/app/appcommon" + appserver "github.com/skycoin/skywire/pkg/app/appserver" + + mock "github.com/stretchr/testify/mock" + + net "net" + + routing "github.com/skycoin/skywire/pkg/routing" +) + +// ProcManager is an autogenerated mock type for the ProcManager type +type ProcManager struct { + mock.Mock +} + +// Addr provides a mock function with given fields: +func (_m *ProcManager) Addr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// Close provides a mock function with given fields: +func (_m *ProcManager) 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 +} + +// ConnectionsSummary provides a mock function with given fields: appName +func (_m *ProcManager) ConnectionsSummary(appName string) ([]appserver.ConnectionSummary, error) { + ret := _m.Called(appName) + + var r0 []appserver.ConnectionSummary + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]appserver.ConnectionSummary, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) []appserver.ConnectionSummary); ok { + r0 = rf(appName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]appserver.ConnectionSummary) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Deregister provides a mock function with given fields: key +func (_m *ProcManager) Deregister(key appcommon.ProcKey) error { + ret := _m.Called(key) + + var r0 error + if rf, ok := ret.Get(0).(func(appcommon.ProcKey) error); ok { + r0 = rf(key) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DetailedStatus provides a mock function with given fields: appName +func (_m *ProcManager) DetailedStatus(appName string) (string, error) { + ret := _m.Called(appName) + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string) (string, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ErrorByName provides a mock function with given fields: appName +func (_m *ProcManager) ErrorByName(appName string) (string, bool) { + ret := _m.Called(appName) + + var r0 string + var r1 bool + if rf, ok := ret.Get(0).(func(string) (string, bool)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(appName) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// GetAppPort provides a mock function with given fields: appName +func (_m *ProcManager) GetAppPort(appName string) (routing.Port, error) { + ret := _m.Called(appName) + + var r0 routing.Port + var r1 error + if rf, ok := ret.Get(0).(func(string) (routing.Port, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) routing.Port); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(routing.Port) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ProcByName provides a mock function with given fields: appName +func (_m *ProcManager) ProcByName(appName string) (*appserver.Proc, bool) { + ret := _m.Called(appName) + + var r0 *appserver.Proc + var r1 bool + if rf, ok := ret.Get(0).(func(string) (*appserver.Proc, bool)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) *appserver.Proc); ok { + r0 = rf(appName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*appserver.Proc) + } + } + + if rf, ok := ret.Get(1).(func(string) bool); ok { + r1 = rf(appName) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// Range provides a mock function with given fields: next +func (_m *ProcManager) Range(next func(string, *appserver.Proc) bool) { + _m.Called(next) +} + +// Register provides a mock function with given fields: conf +func (_m *ProcManager) Register(conf appcommon.ProcConfig) (appcommon.ProcKey, error) { + ret := _m.Called(conf) + + var r0 appcommon.ProcKey + var r1 error + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) (appcommon.ProcKey, error)); ok { + return rf(conf) + } + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) appcommon.ProcKey); ok { + r0 = rf(conf) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(appcommon.ProcKey) + } + } + + if rf, ok := ret.Get(1).(func(appcommon.ProcConfig) error); ok { + r1 = rf(conf) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SetDetailedStatus provides a mock function with given fields: appName, status +func (_m *ProcManager) SetDetailedStatus(appName string, status string) error { + ret := _m.Called(appName, status) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, status) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetError provides a mock function with given fields: appName, status +func (_m *ProcManager) SetError(appName string, status string) error { + ret := _m.Called(appName, status) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(appName, status) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Start provides a mock function with given fields: conf +func (_m *ProcManager) Start(conf appcommon.ProcConfig) (appcommon.ProcID, error) { + ret := _m.Called(conf) + + var r0 appcommon.ProcID + var r1 error + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) (appcommon.ProcID, error)); ok { + return rf(conf) + } + if rf, ok := ret.Get(0).(func(appcommon.ProcConfig) appcommon.ProcID); ok { + r0 = rf(conf) + } else { + r0 = ret.Get(0).(appcommon.ProcID) + } + + if rf, ok := ret.Get(1).(func(appcommon.ProcConfig) error); ok { + r1 = rf(conf) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Stats provides a mock function with given fields: appName +func (_m *ProcManager) Stats(appName string) (appserver.AppStats, error) { + ret := _m.Called(appName) + + var r0 appserver.AppStats + var r1 error + if rf, ok := ret.Get(0).(func(string) (appserver.AppStats, error)); ok { + return rf(appName) + } + if rf, ok := ret.Get(0).(func(string) appserver.AppStats); ok { + r0 = rf(appName) + } else { + r0 = ret.Get(0).(appserver.AppStats) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(appName) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Stop provides a mock function with given fields: appName +func (_m *ProcManager) Stop(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Wait provides a mock function with given fields: appName +func (_m *ProcManager) Wait(appName string) error { + ret := _m.Called(appName) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appName) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewProcManager creates a new instance of ProcManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewProcManager(t interface { + mock.TestingT + Cleanup(func()) +}) *ProcManager { + mock := &ProcManager{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/RPCClient.go b/pkg/mocks/RPCClient.go new file mode 100644 index 0000000000..c326ddb8e3 --- /dev/null +++ b/pkg/mocks/RPCClient.go @@ -0,0 +1,75 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + appcommon "github.com/skycoin/skywire/pkg/app/appcommon" + appevent "github.com/skycoin/skywire/pkg/app/appevent" + + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// RPCClient is an autogenerated mock type for the RPCClient type +type RPCClient struct { + mock.Mock +} + +// Close provides a mock function with given fields: +func (_m *RPCClient) 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 +} + +// Hello provides a mock function with given fields: +func (_m *RPCClient) Hello() *appcommon.Hello { + ret := _m.Called() + + var r0 *appcommon.Hello + if rf, ok := ret.Get(0).(func() *appcommon.Hello); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*appcommon.Hello) + } + } + + return r0 +} + +// Notify provides a mock function with given fields: ctx, e +func (_m *RPCClient) Notify(ctx context.Context, e *appevent.Event) error { + ret := _m.Called(ctx, e) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *appevent.Event) error); ok { + r0 = rf(ctx, e) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewRPCClient creates a new instance of RPCClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRPCClient(t interface { + mock.TestingT + Cleanup(func()) +}) *RPCClient { + mock := &RPCClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/RPCIngressClient.go b/pkg/mocks/RPCIngressClient.go new file mode 100644 index 0000000000..06fe2f3c1d --- /dev/null +++ b/pkg/mocks/RPCIngressClient.go @@ -0,0 +1,292 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + appnet "github.com/skycoin/skywire/pkg/app/appnet" + + mock "github.com/stretchr/testify/mock" + + routing "github.com/skycoin/skywire/pkg/routing" + + time "time" +) + +// RPCIngressClient is an autogenerated mock type for the RPCIngressClient type +type RPCIngressClient struct { + mock.Mock +} + +// Accept provides a mock function with given fields: lisID +func (_m *RPCIngressClient) Accept(lisID uint16) (uint16, appnet.Addr, error) { + ret := _m.Called(lisID) + + var r0 uint16 + var r1 appnet.Addr + var r2 error + if rf, ok := ret.Get(0).(func(uint16) (uint16, appnet.Addr, error)); ok { + return rf(lisID) + } + if rf, ok := ret.Get(0).(func(uint16) uint16); ok { + r0 = rf(lisID) + } else { + r0 = ret.Get(0).(uint16) + } + + if rf, ok := ret.Get(1).(func(uint16) appnet.Addr); ok { + r1 = rf(lisID) + } else { + r1 = ret.Get(1).(appnet.Addr) + } + + if rf, ok := ret.Get(2).(func(uint16) error); ok { + r2 = rf(lisID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CloseConn provides a mock function with given fields: id +func (_m *RPCIngressClient) CloseConn(id uint16) error { + ret := _m.Called(id) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CloseListener provides a mock function with given fields: id +func (_m *RPCIngressClient) CloseListener(id uint16) error { + ret := _m.Called(id) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Dial provides a mock function with given fields: remote +func (_m *RPCIngressClient) Dial(remote appnet.Addr) (uint16, routing.Port, error) { + ret := _m.Called(remote) + + var r0 uint16 + var r1 routing.Port + var r2 error + if rf, ok := ret.Get(0).(func(appnet.Addr) (uint16, routing.Port, error)); ok { + return rf(remote) + } + if rf, ok := ret.Get(0).(func(appnet.Addr) uint16); ok { + r0 = rf(remote) + } else { + r0 = ret.Get(0).(uint16) + } + + if rf, ok := ret.Get(1).(func(appnet.Addr) routing.Port); ok { + r1 = rf(remote) + } else { + r1 = ret.Get(1).(routing.Port) + } + + if rf, ok := ret.Get(2).(func(appnet.Addr) error); ok { + r2 = rf(remote) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// Listen provides a mock function with given fields: local +func (_m *RPCIngressClient) Listen(local appnet.Addr) (uint16, error) { + ret := _m.Called(local) + + var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(appnet.Addr) (uint16, error)); ok { + return rf(local) + } + if rf, ok := ret.Get(0).(func(appnet.Addr) uint16); ok { + r0 = rf(local) + } else { + r0 = ret.Get(0).(uint16) + } + + if rf, ok := ret.Get(1).(func(appnet.Addr) error); ok { + r1 = rf(local) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Read provides a mock function with given fields: connID, b +func (_m *RPCIngressClient) Read(connID uint16, b []byte) (int, error) { + ret := _m.Called(connID, b) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(uint16, []byte) (int, error)); ok { + return rf(connID, b) + } + if rf, ok := ret.Get(0).(func(uint16, []byte) int); ok { + r0 = rf(connID, b) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(uint16, []byte) error); ok { + r1 = rf(connID, b) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SetAppPort provides a mock function with given fields: appPort +func (_m *RPCIngressClient) SetAppPort(appPort routing.Port) error { + ret := _m.Called(appPort) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.Port) error); ok { + r0 = rf(appPort) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetConnectionDuration provides a mock function with given fields: dur +func (_m *RPCIngressClient) SetConnectionDuration(dur int64) error { + ret := _m.Called(dur) + + var r0 error + if rf, ok := ret.Get(0).(func(int64) error); ok { + r0 = rf(dur) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetDeadline provides a mock function with given fields: connID, d +func (_m *RPCIngressClient) SetDeadline(connID uint16, d time.Time) error { + ret := _m.Called(connID, d) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16, time.Time) error); ok { + r0 = rf(connID, d) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetDetailedStatus provides a mock function with given fields: status +func (_m *RPCIngressClient) SetDetailedStatus(status string) error { + ret := _m.Called(status) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(status) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetError provides a mock function with given fields: appErr +func (_m *RPCIngressClient) SetError(appErr string) error { + ret := _m.Called(appErr) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(appErr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetReadDeadline provides a mock function with given fields: connID, d +func (_m *RPCIngressClient) SetReadDeadline(connID uint16, d time.Time) error { + ret := _m.Called(connID, d) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16, time.Time) error); ok { + r0 = rf(connID, d) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetWriteDeadline provides a mock function with given fields: connID, d +func (_m *RPCIngressClient) SetWriteDeadline(connID uint16, d time.Time) error { + ret := _m.Called(connID, d) + + var r0 error + if rf, ok := ret.Get(0).(func(uint16, time.Time) error); ok { + r0 = rf(connID, d) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Write provides a mock function with given fields: connID, b +func (_m *RPCIngressClient) Write(connID uint16, b []byte) (int, error) { + ret := _m.Called(connID, b) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(uint16, []byte) (int, error)); ok { + return rf(connID, b) + } + if rf, ok := ret.Get(0).(func(uint16, []byte) int); ok { + r0 = rf(connID, b) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(uint16, []byte) error); ok { + r1 = rf(connID, b) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewRPCIngressClient creates a new instance of RPCIngressClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRPCIngressClient(t interface { + mock.TestingT + Cleanup(func()) +}) *RPCIngressClient { + mock := &RPCIngressClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/RouteGroupDialer.go b/pkg/mocks/RouteGroupDialer.go new file mode 100644 index 0000000000..5b18e9f6d5 --- /dev/null +++ b/pkg/mocks/RouteGroupDialer.go @@ -0,0 +1,60 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + dmsg "github.com/skycoin/dmsg/pkg/dmsg" + + logging "github.com/skycoin/skywire-utilities/pkg/logging" + + mock "github.com/stretchr/testify/mock" + + routing "github.com/skycoin/skywire/pkg/routing" +) + +// RouteGroupDialer is an autogenerated mock type for the RouteGroupDialer type +type RouteGroupDialer struct { + mock.Mock +} + +// Dial provides a mock function with given fields: ctx, log, dmsgC, setupNodes, req +func (_m *RouteGroupDialer) Dial(ctx context.Context, log *logging.Logger, dmsgC *dmsg.Client, setupNodes []cipher.PubKey, req routing.BidirectionalRoute) (routing.EdgeRules, error) { + ret := _m.Called(ctx, log, dmsgC, setupNodes, req) + + var r0 routing.EdgeRules + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *logging.Logger, *dmsg.Client, []cipher.PubKey, routing.BidirectionalRoute) (routing.EdgeRules, error)); ok { + return rf(ctx, log, dmsgC, setupNodes, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *logging.Logger, *dmsg.Client, []cipher.PubKey, routing.BidirectionalRoute) routing.EdgeRules); ok { + r0 = rf(ctx, log, dmsgC, setupNodes, req) + } else { + r0 = ret.Get(0).(routing.EdgeRules) + } + + if rf, ok := ret.Get(1).(func(context.Context, *logging.Logger, *dmsg.Client, []cipher.PubKey, routing.BidirectionalRoute) error); ok { + r1 = rf(ctx, log, dmsgC, setupNodes, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewRouteGroupDialer creates a new instance of RouteGroupDialer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRouteGroupDialer(t interface { + mock.TestingT + Cleanup(func()) +}) *RouteGroupDialer { + mock := &RouteGroupDialer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/RouteSetupHook.go b/pkg/mocks/RouteSetupHook.go new file mode 100644 index 0000000000..07bc0bf028 --- /dev/null +++ b/pkg/mocks/RouteSetupHook.go @@ -0,0 +1,43 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + mock "github.com/stretchr/testify/mock" + + transport "github.com/skycoin/skywire/pkg/transport" +) + +// RouteSetupHook is an autogenerated mock type for the RouteSetupHook type +type RouteSetupHook struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, _a1 +func (_m *RouteSetupHook) Execute(_a0 cipher.PubKey, _a1 *transport.Manager) error { + ret := _m.Called(_a0, _a1) + + var r0 error + if rf, ok := ret.Get(0).(func(cipher.PubKey, *transport.Manager) error); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewRouteSetupHook creates a new instance of RouteSetupHook. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRouteSetupHook(t interface { + mock.TestingT + Cleanup(func()) +}) *RouteSetupHook { + mock := &RouteSetupHook{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Router.go b/pkg/mocks/Router.go new file mode 100644 index 0000000000..2f40b9371b --- /dev/null +++ b/pkg/mocks/Router.go @@ -0,0 +1,291 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + net "net" + + router "github.com/skycoin/skywire/pkg/router" + + routing "github.com/skycoin/skywire/pkg/routing" +) + +// Router is an autogenerated mock type for the Router type +type Router struct { + mock.Mock +} + +// AcceptRoutes provides a mock function with given fields: _a0 +func (_m *Router) AcceptRoutes(_a0 context.Context) (net.Conn, error) { + ret := _m.Called(_a0) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (net.Conn, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(context.Context) net.Conn); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Close provides a mock function with given fields: +func (_m *Router) 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 +} + +// DelRules provides a mock function with given fields: _a0 +func (_m *Router) DelRules(_a0 []routing.RouteID) { + _m.Called(_a0) +} + +// DialRoutes provides a mock function with given fields: ctx, rPK, lPort, rPort, opts +func (_m *Router) DialRoutes(ctx context.Context, rPK cipher.PubKey, lPort routing.Port, rPort routing.Port, opts *router.DialOptions) (net.Conn, error) { + ret := _m.Called(ctx, rPK, lPort, rPort, opts) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) (net.Conn, error)); ok { + return rf(ctx, rPK, lPort, rPort, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) net.Conn); ok { + r0 = rf(ctx, rPK, lPort, rPort, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) error); ok { + r1 = rf(ctx, rPK, lPort, rPort, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IntroduceRules provides a mock function with given fields: rules +func (_m *Router) IntroduceRules(rules routing.EdgeRules) error { + ret := _m.Called(rules) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.EdgeRules) error); ok { + r0 = rf(rules) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// PingRoute provides a mock function with given fields: ctx, rPK, lPort, rPort, opts +func (_m *Router) PingRoute(ctx context.Context, rPK cipher.PubKey, lPort routing.Port, rPort routing.Port, opts *router.DialOptions) (net.Conn, error) { + ret := _m.Called(ctx, rPK, lPort, rPort, opts) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) (net.Conn, error)); ok { + return rf(ctx, rPK, lPort, rPort, opts) + } + if rf, ok := ret.Get(0).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) net.Conn); ok { + r0 = rf(ctx, rPK, lPort, rPort, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, cipher.PubKey, routing.Port, routing.Port, *router.DialOptions) error); ok { + r1 = rf(ctx, rPK, lPort, rPort, opts) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ReserveKeys provides a mock function with given fields: n +func (_m *Router) ReserveKeys(n int) ([]routing.RouteID, error) { + ret := _m.Called(n) + + var r0 []routing.RouteID + var r1 error + if rf, ok := ret.Get(0).(func(int) ([]routing.RouteID, error)); ok { + return rf(n) + } + if rf, ok := ret.Get(0).(func(int) []routing.RouteID); ok { + r0 = rf(n) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.RouteID) + } + } + + if rf, ok := ret.Get(1).(func(int) error); ok { + r1 = rf(n) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RoutesCount provides a mock function with given fields: +func (_m *Router) RoutesCount() int { + ret := _m.Called() + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// Rule provides a mock function with given fields: _a0 +func (_m *Router) Rule(_a0 routing.RouteID) (routing.Rule, error) { + ret := _m.Called(_a0) + + var r0 routing.Rule + var r1 error + if rf, ok := ret.Get(0).(func(routing.RouteID) (routing.Rule, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(routing.RouteID) routing.Rule); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(routing.Rule) + } + } + + if rf, ok := ret.Get(1).(func(routing.RouteID) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Rules provides a mock function with given fields: +func (_m *Router) Rules() []routing.Rule { + ret := _m.Called() + + var r0 []routing.Rule + if rf, ok := ret.Get(0).(func() []routing.Rule); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.Rule) + } + } + + return r0 +} + +// SaveRoutingRules provides a mock function with given fields: rules +func (_m *Router) SaveRoutingRules(rules ...routing.Rule) error { + _va := make([]interface{}, len(rules)) + for _i := range rules { + _va[_i] = rules[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 error + if rf, ok := ret.Get(0).(func(...routing.Rule) error); ok { + r0 = rf(rules...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SaveRule provides a mock function with given fields: _a0 +func (_m *Router) SaveRule(_a0 routing.Rule) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.Rule) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Serve provides a mock function with given fields: _a0 +func (_m *Router) Serve(_a0 context.Context) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetupIsTrusted provides a mock function with given fields: _a0 +func (_m *Router) SetupIsTrusted(_a0 cipher.PubKey) bool { + ret := _m.Called(_a0) + + var r0 bool + if rf, ok := ret.Get(0).(func(cipher.PubKey) bool); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// NewRouter creates a new instance of Router. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewRouter(t interface { + mock.TestingT + Cleanup(func()) +}) *Router { + mock := &Router{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/SettlementHS.go b/pkg/mocks/SettlementHS.go new file mode 100644 index 0000000000..c05c620c9e --- /dev/null +++ b/pkg/mocks/SettlementHS.go @@ -0,0 +1,48 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + + mock "github.com/stretchr/testify/mock" + + network "github.com/skycoin/skywire/pkg/transport/network" + + transport "github.com/skycoin/skywire/pkg/transport" +) + +// SettlementHS is an autogenerated mock type for the SettlementHS type +type SettlementHS struct { + mock.Mock +} + +// Execute provides a mock function with given fields: ctx, dc, _a2, sk +func (_m *SettlementHS) Execute(ctx context.Context, dc transport.DiscoveryClient, _a2 network.Transport, sk cipher.SecKey) error { + ret := _m.Called(ctx, dc, _a2, sk) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, transport.DiscoveryClient, network.Transport, cipher.SecKey) error); ok { + r0 = rf(ctx, dc, _a2, sk) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewSettlementHS creates a new instance of SettlementHS. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSettlementHS(t interface { + mock.TestingT + Cleanup(func()) +}) *SettlementHS { + mock := &SettlementHS{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Store.go b/pkg/mocks/Store.go new file mode 100644 index 0000000000..9ee78910c8 --- /dev/null +++ b/pkg/mocks/Store.go @@ -0,0 +1,50 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Store is an autogenerated mock type for the Store type +type Store struct { + mock.Mock +} + +// GetLogs provides a mock function with given fields: +func (_m *Store) GetLogs() ([]string, int64) { + ret := _m.Called() + + var r0 []string + var r1 int64 + if rf, ok := ret.Get(0).(func() ([]string, int64)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []string); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func() int64); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(int64) + } + + return r0, r1 +} + +// NewStore creates a new instance of Store. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStore(t interface { + mock.TestingT + Cleanup(func()) +}) *Store { + mock := &Store{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Table.go b/pkg/mocks/Table.go new file mode 100644 index 0000000000..9f4cbb7b84 --- /dev/null +++ b/pkg/mocks/Table.go @@ -0,0 +1,174 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + routing "github.com/skycoin/skywire/pkg/routing" + mock "github.com/stretchr/testify/mock" +) + +// Table is an autogenerated mock type for the Table type +type Table struct { + mock.Mock +} + +// AllRules provides a mock function with given fields: +func (_m *Table) AllRules() []routing.Rule { + ret := _m.Called() + + var r0 []routing.Rule + if rf, ok := ret.Get(0).(func() []routing.Rule); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.Rule) + } + } + + return r0 +} + +// CollectGarbage provides a mock function with given fields: +func (_m *Table) CollectGarbage() []routing.Rule { + ret := _m.Called() + + var r0 []routing.Rule + if rf, ok := ret.Get(0).(func() []routing.Rule); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.Rule) + } + } + + return r0 +} + +// Count provides a mock function with given fields: +func (_m *Table) Count() int { + ret := _m.Called() + + var r0 int + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +// DelRules provides a mock function with given fields: _a0 +func (_m *Table) DelRules(_a0 []routing.RouteID) { + _m.Called(_a0) +} + +// ReserveKeys provides a mock function with given fields: n +func (_m *Table) ReserveKeys(n int) ([]routing.RouteID, error) { + ret := _m.Called(n) + + var r0 []routing.RouteID + var r1 error + if rf, ok := ret.Get(0).(func(int) ([]routing.RouteID, error)); ok { + return rf(n) + } + if rf, ok := ret.Get(0).(func(int) []routing.RouteID); ok { + r0 = rf(n) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.RouteID) + } + } + + if rf, ok := ret.Get(1).(func(int) error); ok { + r1 = rf(n) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Rule provides a mock function with given fields: _a0 +func (_m *Table) Rule(_a0 routing.RouteID) (routing.Rule, error) { + ret := _m.Called(_a0) + + var r0 routing.Rule + var r1 error + if rf, ok := ret.Get(0).(func(routing.RouteID) (routing.Rule, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(routing.RouteID) routing.Rule); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(routing.Rule) + } + } + + if rf, ok := ret.Get(1).(func(routing.RouteID) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RulesWithDesc provides a mock function with given fields: _a0 +func (_m *Table) RulesWithDesc(_a0 routing.RouteDescriptor) []routing.Rule { + ret := _m.Called(_a0) + + var r0 []routing.Rule + if rf, ok := ret.Get(0).(func(routing.RouteDescriptor) []routing.Rule); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]routing.Rule) + } + } + + return r0 +} + +// SaveRule provides a mock function with given fields: _a0 +func (_m *Table) SaveRule(_a0 routing.Rule) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.Rule) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// UpdateActivity provides a mock function with given fields: _a0 +func (_m *Table) UpdateActivity(_a0 routing.RouteID) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(routing.RouteID) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewTable creates a new instance of Table. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTable(t interface { + mock.TestingT + Cleanup(func()) +}) *Table { + mock := &Table{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Transport.go b/pkg/mocks/Transport.go new file mode 100644 index 0000000000..1537e1bd02 --- /dev/null +++ b/pkg/mocks/Transport.go @@ -0,0 +1,275 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + cipher "github.com/skycoin/skywire-utilities/pkg/cipher" + mock "github.com/stretchr/testify/mock" + + net "net" + + network "github.com/skycoin/skywire/pkg/transport/network" + + time "time" +) + +// Transport is an autogenerated mock type for the Transport type +type Transport struct { + mock.Mock +} + +// Close provides a mock function with given fields: +func (_m *Transport) 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 +} + +// LocalAddr provides a mock function with given fields: +func (_m *Transport) LocalAddr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// LocalPK provides a mock function with given fields: +func (_m *Transport) LocalPK() cipher.PubKey { + ret := _m.Called() + + var r0 cipher.PubKey + if rf, ok := ret.Get(0).(func() cipher.PubKey); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(cipher.PubKey) + } + } + + return r0 +} + +// LocalPort provides a mock function with given fields: +func (_m *Transport) LocalPort() uint16 { + ret := _m.Called() + + var r0 uint16 + if rf, ok := ret.Get(0).(func() uint16); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint16) + } + + return r0 +} + +// LocalRawAddr provides a mock function with given fields: +func (_m *Transport) LocalRawAddr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// Network provides a mock function with given fields: +func (_m *Transport) Network() network.Type { + ret := _m.Called() + + var r0 network.Type + if rf, ok := ret.Get(0).(func() network.Type); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(network.Type) + } + + return r0 +} + +// Read provides a mock function with given fields: b +func (_m *Transport) Read(b []byte) (int, error) { + ret := _m.Called(b) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok { + return rf(b) + } + if rf, ok := ret.Get(0).(func([]byte) int); ok { + r0 = rf(b) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(b) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// RemoteAddr provides a mock function with given fields: +func (_m *Transport) RemoteAddr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// RemotePK provides a mock function with given fields: +func (_m *Transport) RemotePK() cipher.PubKey { + ret := _m.Called() + + var r0 cipher.PubKey + if rf, ok := ret.Get(0).(func() cipher.PubKey); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(cipher.PubKey) + } + } + + return r0 +} + +// RemotePort provides a mock function with given fields: +func (_m *Transport) RemotePort() uint16 { + ret := _m.Called() + + var r0 uint16 + if rf, ok := ret.Get(0).(func() uint16); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint16) + } + + return r0 +} + +// RemoteRawAddr provides a mock function with given fields: +func (_m *Transport) RemoteRawAddr() net.Addr { + ret := _m.Called() + + var r0 net.Addr + if rf, ok := ret.Get(0).(func() net.Addr); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Addr) + } + } + + return r0 +} + +// SetDeadline provides a mock function with given fields: t +func (_m *Transport) SetDeadline(t time.Time) error { + ret := _m.Called(t) + + var r0 error + if rf, ok := ret.Get(0).(func(time.Time) error); ok { + r0 = rf(t) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetReadDeadline provides a mock function with given fields: t +func (_m *Transport) SetReadDeadline(t time.Time) error { + ret := _m.Called(t) + + var r0 error + if rf, ok := ret.Get(0).(func(time.Time) error); ok { + r0 = rf(t) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetWriteDeadline provides a mock function with given fields: t +func (_m *Transport) SetWriteDeadline(t time.Time) error { + ret := _m.Called(t) + + var r0 error + if rf, ok := ret.Get(0).(func(time.Time) error); ok { + r0 = rf(t) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Write provides a mock function with given fields: b +func (_m *Transport) Write(b []byte) (int, error) { + ret := _m.Called(b) + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok { + return rf(b) + } + if rf, ok := ret.Get(0).(func([]byte) int); ok { + r0 = rf(b) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(b) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewTransport creates a new instance of Transport. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTransport(t interface { + mock.TestingT + Cleanup(func()) +}) *Transport { + mock := &Transport{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/Updater.go b/pkg/mocks/Updater.go new file mode 100644 index 0000000000..010ef2ba73 --- /dev/null +++ b/pkg/mocks/Updater.go @@ -0,0 +1,34 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// Updater is an autogenerated mock type for the Updater type +type Updater struct { + mock.Mock +} + +// Start provides a mock function with given fields: +func (_m *Updater) Start() { + _m.Called() +} + +// Stop provides a mock function with given fields: +func (_m *Updater) Stop() { + _m.Called() +} + +// NewUpdater creates a new instance of Updater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUpdater(t interface { + mock.TestingT + Cleanup(func()) +}) *Updater { + mock := &Updater{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/UserStore.go b/pkg/mocks/UserStore.go new file mode 100644 index 0000000000..1baf4b58ed --- /dev/null +++ b/pkg/mocks/UserStore.go @@ -0,0 +1,109 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + usermanager "github.com/skycoin/skywire/pkg/visor/usermanager" + mock "github.com/stretchr/testify/mock" +) + +// UserStore is an autogenerated mock type for the UserStore type +type UserStore struct { + mock.Mock +} + +// AddUser provides a mock function with given fields: user +func (_m *UserStore) AddUser(user usermanager.User) error { + ret := _m.Called(user) + + var r0 error + if rf, ok := ret.Get(0).(func(usermanager.User) error); ok { + r0 = rf(user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Close provides a mock function with given fields: +func (_m *UserStore) 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 +} + +// RemoveUser provides a mock function with given fields: name +func (_m *UserStore) RemoveUser(name string) error { + ret := _m.Called(name) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetUser provides a mock function with given fields: user +func (_m *UserStore) SetUser(user usermanager.User) error { + ret := _m.Called(user) + + var r0 error + if rf, ok := ret.Get(0).(func(usermanager.User) error); ok { + r0 = rf(user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// User provides a mock function with given fields: name +func (_m *UserStore) User(name string) (*usermanager.User, error) { + ret := _m.Called(name) + + var r0 *usermanager.User + var r1 error + if rf, ok := ret.Get(0).(func(string) (*usermanager.User, error)); ok { + return rf(name) + } + if rf, ok := ret.Get(0).(func(string) *usermanager.User); ok { + r0 = rf(name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*usermanager.User) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewUserStore creates a new instance of UserStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUserStore(t interface { + mock.TestingT + Cleanup(func()) +}) *UserStore { + mock := &UserStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/closeFn.go b/pkg/mocks/closeFn.go new file mode 100644 index 0000000000..4935e0c26f --- /dev/null +++ b/pkg/mocks/closeFn.go @@ -0,0 +1,38 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// closeFn is an autogenerated mock type for the closeFn type +type closeFn struct { + mock.Mock +} + +// Execute provides a mock function with given fields: +func (_m *closeFn) Execute() 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 +} + +// newCloseFn creates a new instance of closeFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newCloseFn(t interface { + mock.TestingT + Cleanup(func()) +}) *closeFn { + mock := &closeFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/dialFunc.go b/pkg/mocks/dialFunc.go new file mode 100644 index 0000000000..82838ef0ec --- /dev/null +++ b/pkg/mocks/dialFunc.go @@ -0,0 +1,55 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + net "net" + + mock "github.com/stretchr/testify/mock" +) + +// dialFunc is an autogenerated mock type for the dialFunc type +type dialFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: ctx, addr +func (_m *dialFunc) Execute(ctx context.Context, addr string) (net.Conn, error) { + ret := _m.Called(ctx, addr) + + var r0 net.Conn + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (net.Conn, error)); ok { + return rf(ctx, addr) + } + if rf, ok := ret.Get(0).(func(context.Context, string) net.Conn); ok { + r0 = rf(ctx, addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(net.Conn) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// newDialFunc creates a new instance of dialFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newDialFunc(t interface { + mock.TestingT + Cleanup(func()) +}) *dialFunc { + mock := &dialFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/handlerFunc.go b/pkg/mocks/handlerFunc.go new file mode 100644 index 0000000000..32b315dc4a --- /dev/null +++ b/pkg/mocks/handlerFunc.go @@ -0,0 +1,33 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// handlerFunc is an autogenerated mock type for the handlerFunc type +type handlerFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: w, r, ctx +func (_m *handlerFunc) Execute(w http.ResponseWriter, r *http.Request, ctx *visor.httpCtx) { + _m.Called(w, r, ctx) +} + +// newHandlerFunc creates a new instance of handlerFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newHandlerFunc(t interface { + mock.TestingT + Cleanup(func()) +}) *handlerFunc { + mock := &handlerFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/initFn.go b/pkg/mocks/initFn.go new file mode 100644 index 0000000000..f1a8af821a --- /dev/null +++ b/pkg/mocks/initFn.go @@ -0,0 +1,45 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + context "context" + + logging "github.com/skycoin/skywire-utilities/pkg/logging" + mock "github.com/stretchr/testify/mock" + + visor "github.com/skycoin/skywire/pkg/visor" +) + +// initFn is an autogenerated mock type for the initFn type +type initFn struct { + mock.Mock +} + +// Execute provides a mock function with given fields: _a0, _a1, _a2 +func (_m *initFn) Execute(_a0 context.Context, _a1 *visor.Visor, _a2 *logging.Logger) error { + ret := _m.Called(_a0, _a1, _a2) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *visor.Visor, *logging.Logger) error); ok { + r0 = rf(_a0, _a1, _a2) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// newInitFn creates a new instance of initFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newInitFn(t interface { + mock.TestingT + Cleanup(func()) +}) *initFn { + mock := &initFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/sendServicePacketFn.go b/pkg/mocks/sendServicePacketFn.go new file mode 100644 index 0000000000..d2084aa731 --- /dev/null +++ b/pkg/mocks/sendServicePacketFn.go @@ -0,0 +1,33 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// sendServicePacketFn is an autogenerated mock type for the sendServicePacketFn type +type sendServicePacketFn struct { + mock.Mock +} + +// Execute provides a mock function with given fields: interval +func (_m *sendServicePacketFn) Execute(interval time.Duration) { + _m.Called(interval) +} + +// newSendServicePacketFn creates a new instance of sendServicePacketFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newSendServicePacketFn(t interface { + mock.TestingT + Cleanup(func()) +}) *sendServicePacketFn { + mock := &sendServicePacketFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/mocks/valuesFunc.go b/pkg/mocks/valuesFunc.go new file mode 100644 index 0000000000..764ef64b0c --- /dev/null +++ b/pkg/mocks/valuesFunc.go @@ -0,0 +1,54 @@ +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// valuesFunc is an autogenerated mock type for the valuesFunc type +type valuesFunc struct { + mock.Mock +} + +// Execute provides a mock function with given fields: w, r +func (_m *valuesFunc) Execute(w http.ResponseWriter, r *http.Request) (*visor.httpCtx, bool) { + ret := _m.Called(w, r) + + var r0 *visor.httpCtx + var r1 bool + if rf, ok := ret.Get(0).(func(http.ResponseWriter, *http.Request) (*visor.httpCtx, bool)); ok { + return rf(w, r) + } + if rf, ok := ret.Get(0).(func(http.ResponseWriter, *http.Request) *visor.httpCtx); ok { + r0 = rf(w, r) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*visor.httpCtx) + } + } + + if rf, ok := ret.Get(1).(func(http.ResponseWriter, *http.Request) bool); ok { + r1 = rf(w, r) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// newValuesFunc creates a new instance of valuesFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newValuesFunc(t interface { + mock.TestingT + Cleanup(func()) +}) *valuesFunc { + mock := &valuesFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/skyenv/skyenv.go b/pkg/skyenv/skyenv.go index 2ce8e906bd..2e9a1bca10 100644 --- a/pkg/skyenv/skyenv.go +++ b/pkg/skyenv/skyenv.go @@ -1,7 +1,9 @@ // Package skyenv defines variables and constants package skyenv -import "time" +import ( + "time" +) const ( // config file constants diff --git a/pkg/transport/errors.go b/pkg/transport/errors.go index 8b6e11b2d1..0b5550b094 100644 --- a/pkg/transport/errors.go +++ b/pkg/transport/errors.go @@ -1,7 +1,9 @@ // Package transport pkg/transport/errors.go package transport -import "errors" +import ( + "errors" +) // ErrWrongNetwork is returned if connection's network differs from // the one transport is awaiting. diff --git a/pkg/utclient/mock_api_client.go b/pkg/utclient/mock_api_client.go index 422375e5a3..63b6d3ce46 100644 --- a/pkg/utclient/mock_api_client.go +++ b/pkg/utclient/mock_api_client.go @@ -49,7 +49,7 @@ func (_m *MockAPIClient) UpdateVisorUptime(_a0 context.Context, version string) } // FetchUptimes provide a mock function with given field :_a0 -func (_m *MockAPIClient) FetchUptimes(ctx context.Context, pk string) ([]byte,error){ +func (_m *MockAPIClient) FetchUptimes(ctx context.Context, pk string) ([]byte, error) { ret := _m.Called(ctx) var r0 []byte diff --git a/pkg/util/osutil/privileges_windows.go b/pkg/util/osutil/privileges_windows.go index 3ce775eda1..32ae6459c3 100644 --- a/pkg/util/osutil/privileges_windows.go +++ b/pkg/util/osutil/privileges_windows.go @@ -3,7 +3,9 @@ package osutil -import "syscall" +import ( + "syscall" +) // GainRoot escalates privileges to gain root access, it's not needed on windows func GainRoot() (int, error) { diff --git a/pkg/visor/csrf.go b/pkg/visor/csrf.go index f05580ffb7..c7cc78feca 100644 --- a/pkg/visor/csrf.go +++ b/pkg/visor/csrf.go @@ -2,14 +2,13 @@ package visor import ( - "time" - "crypto/hmac" "crypto/sha256" "encoding/base64" "encoding/json" "errors" "strings" + "time" "github.com/skycoin/skycoin/src/cipher" )