github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/mock/peer_management.go (about) 1 // Code generated by mockery v2.21.4. DO NOT EDIT. 2 3 package mockp2p 4 5 import ( 6 component "github.com/onflow/flow-go/module/component" 7 channels "github.com/onflow/flow-go/network/channels" 8 9 context "context" 10 11 corenetwork "github.com/libp2p/go-libp2p/core/network" 12 13 host "github.com/libp2p/go-libp2p/core/host" 14 15 kbucket "github.com/libp2p/go-libp2p-kbucket" 16 17 mock "github.com/stretchr/testify/mock" 18 19 network "github.com/onflow/flow-go/network" 20 21 p2p "github.com/onflow/flow-go/network/p2p" 22 23 peer "github.com/libp2p/go-libp2p/core/peer" 24 25 protocol "github.com/libp2p/go-libp2p/core/protocol" 26 27 protocols "github.com/onflow/flow-go/network/p2p/unicast/protocols" 28 ) 29 30 // PeerManagement is an autogenerated mock type for the PeerManagement type 31 type PeerManagement struct { 32 mock.Mock 33 } 34 35 // ConnectToPeer provides a mock function with given fields: ctx, peerInfo 36 func (_m *PeerManagement) ConnectToPeer(ctx context.Context, peerInfo peer.AddrInfo) error { 37 ret := _m.Called(ctx, peerInfo) 38 39 var r0 error 40 if rf, ok := ret.Get(0).(func(context.Context, peer.AddrInfo) error); ok { 41 r0 = rf(ctx, peerInfo) 42 } else { 43 r0 = ret.Error(0) 44 } 45 46 return r0 47 } 48 49 // GetIPPort provides a mock function with given fields: 50 func (_m *PeerManagement) GetIPPort() (string, string, error) { 51 ret := _m.Called() 52 53 var r0 string 54 var r1 string 55 var r2 error 56 if rf, ok := ret.Get(0).(func() (string, string, error)); ok { 57 return rf() 58 } 59 if rf, ok := ret.Get(0).(func() string); ok { 60 r0 = rf() 61 } else { 62 r0 = ret.Get(0).(string) 63 } 64 65 if rf, ok := ret.Get(1).(func() string); ok { 66 r1 = rf() 67 } else { 68 r1 = ret.Get(1).(string) 69 } 70 71 if rf, ok := ret.Get(2).(func() error); ok { 72 r2 = rf() 73 } else { 74 r2 = ret.Error(2) 75 } 76 77 return r0, r1, r2 78 } 79 80 // GetPeersForProtocol provides a mock function with given fields: pid 81 func (_m *PeerManagement) GetPeersForProtocol(pid protocol.ID) peer.IDSlice { 82 ret := _m.Called(pid) 83 84 var r0 peer.IDSlice 85 if rf, ok := ret.Get(0).(func(protocol.ID) peer.IDSlice); ok { 86 r0 = rf(pid) 87 } else { 88 if ret.Get(0) != nil { 89 r0 = ret.Get(0).(peer.IDSlice) 90 } 91 } 92 93 return r0 94 } 95 96 // Host provides a mock function with given fields: 97 func (_m *PeerManagement) Host() host.Host { 98 ret := _m.Called() 99 100 var r0 host.Host 101 if rf, ok := ret.Get(0).(func() host.Host); ok { 102 r0 = rf() 103 } else { 104 if ret.Get(0) != nil { 105 r0 = ret.Get(0).(host.Host) 106 } 107 } 108 109 return r0 110 } 111 112 // ID provides a mock function with given fields: 113 func (_m *PeerManagement) ID() peer.ID { 114 ret := _m.Called() 115 116 var r0 peer.ID 117 if rf, ok := ret.Get(0).(func() peer.ID); ok { 118 r0 = rf() 119 } else { 120 r0 = ret.Get(0).(peer.ID) 121 } 122 123 return r0 124 } 125 126 // ListPeers provides a mock function with given fields: topic 127 func (_m *PeerManagement) ListPeers(topic string) []peer.ID { 128 ret := _m.Called(topic) 129 130 var r0 []peer.ID 131 if rf, ok := ret.Get(0).(func(string) []peer.ID); ok { 132 r0 = rf(topic) 133 } else { 134 if ret.Get(0) != nil { 135 r0 = ret.Get(0).([]peer.ID) 136 } 137 } 138 139 return r0 140 } 141 142 // PeerManagerComponent provides a mock function with given fields: 143 func (_m *PeerManagement) PeerManagerComponent() component.Component { 144 ret := _m.Called() 145 146 var r0 component.Component 147 if rf, ok := ret.Get(0).(func() component.Component); ok { 148 r0 = rf() 149 } else { 150 if ret.Get(0) != nil { 151 r0 = ret.Get(0).(component.Component) 152 } 153 } 154 155 return r0 156 } 157 158 // Publish provides a mock function with given fields: ctx, messageScope 159 func (_m *PeerManagement) Publish(ctx context.Context, messageScope network.OutgoingMessageScope) error { 160 ret := _m.Called(ctx, messageScope) 161 162 var r0 error 163 if rf, ok := ret.Get(0).(func(context.Context, network.OutgoingMessageScope) error); ok { 164 r0 = rf(ctx, messageScope) 165 } else { 166 r0 = ret.Error(0) 167 } 168 169 return r0 170 } 171 172 // RemovePeer provides a mock function with given fields: peerID 173 func (_m *PeerManagement) RemovePeer(peerID peer.ID) error { 174 ret := _m.Called(peerID) 175 176 var r0 error 177 if rf, ok := ret.Get(0).(func(peer.ID) error); ok { 178 r0 = rf(peerID) 179 } else { 180 r0 = ret.Error(0) 181 } 182 183 return r0 184 } 185 186 // RequestPeerUpdate provides a mock function with given fields: 187 func (_m *PeerManagement) RequestPeerUpdate() { 188 _m.Called() 189 } 190 191 // RoutingTable provides a mock function with given fields: 192 func (_m *PeerManagement) RoutingTable() *kbucket.RoutingTable { 193 ret := _m.Called() 194 195 var r0 *kbucket.RoutingTable 196 if rf, ok := ret.Get(0).(func() *kbucket.RoutingTable); ok { 197 r0 = rf() 198 } else { 199 if ret.Get(0) != nil { 200 r0 = ret.Get(0).(*kbucket.RoutingTable) 201 } 202 } 203 204 return r0 205 } 206 207 // Subscribe provides a mock function with given fields: topic, topicValidator 208 func (_m *PeerManagement) Subscribe(topic channels.Topic, topicValidator p2p.TopicValidatorFunc) (p2p.Subscription, error) { 209 ret := _m.Called(topic, topicValidator) 210 211 var r0 p2p.Subscription 212 var r1 error 213 if rf, ok := ret.Get(0).(func(channels.Topic, p2p.TopicValidatorFunc) (p2p.Subscription, error)); ok { 214 return rf(topic, topicValidator) 215 } 216 if rf, ok := ret.Get(0).(func(channels.Topic, p2p.TopicValidatorFunc) p2p.Subscription); ok { 217 r0 = rf(topic, topicValidator) 218 } else { 219 if ret.Get(0) != nil { 220 r0 = ret.Get(0).(p2p.Subscription) 221 } 222 } 223 224 if rf, ok := ret.Get(1).(func(channels.Topic, p2p.TopicValidatorFunc) error); ok { 225 r1 = rf(topic, topicValidator) 226 } else { 227 r1 = ret.Error(1) 228 } 229 230 return r0, r1 231 } 232 233 // Unsubscribe provides a mock function with given fields: topic 234 func (_m *PeerManagement) Unsubscribe(topic channels.Topic) error { 235 ret := _m.Called(topic) 236 237 var r0 error 238 if rf, ok := ret.Get(0).(func(channels.Topic) error); ok { 239 r0 = rf(topic) 240 } else { 241 r0 = ret.Error(0) 242 } 243 244 return r0 245 } 246 247 // WithDefaultUnicastProtocol provides a mock function with given fields: defaultHandler, preferred 248 func (_m *PeerManagement) WithDefaultUnicastProtocol(defaultHandler corenetwork.StreamHandler, preferred []protocols.ProtocolName) error { 249 ret := _m.Called(defaultHandler, preferred) 250 251 var r0 error 252 if rf, ok := ret.Get(0).(func(corenetwork.StreamHandler, []protocols.ProtocolName) error); ok { 253 r0 = rf(defaultHandler, preferred) 254 } else { 255 r0 = ret.Error(0) 256 } 257 258 return r0 259 } 260 261 // WithPeersProvider provides a mock function with given fields: peersProvider 262 func (_m *PeerManagement) WithPeersProvider(peersProvider p2p.PeersProvider) { 263 _m.Called(peersProvider) 264 } 265 266 type mockConstructorTestingTNewPeerManagement interface { 267 mock.TestingT 268 Cleanup(func()) 269 } 270 271 // NewPeerManagement creates a new instance of PeerManagement. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. 272 func NewPeerManagement(t mockConstructorTestingTNewPeerManagement) *PeerManagement { 273 mock := &PeerManagement{} 274 mock.Mock.Test(t) 275 276 t.Cleanup(func() { mock.AssertExpectations(t) }) 277 278 return mock 279 }