2020-06-18 03:53:46 +00:00
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
|
|
|
"github.com/libp2p/go-libp2p-core/host"
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
2020-12-17 18:03:18 +00:00
|
|
|
"github.com/multiformats/go-multiaddr"
|
2020-06-18 03:53:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MockPeerManager is mock of the PeerManager interface.
|
|
|
|
type MockPeerManager struct {
|
|
|
|
Enr *enr.Record
|
|
|
|
PID peer.ID
|
|
|
|
BHost host.Host
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disconnect .
|
|
|
|
func (m *MockPeerManager) Disconnect(peer.ID) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// PeerID .
|
|
|
|
func (m *MockPeerManager) PeerID() peer.ID {
|
|
|
|
return m.PID
|
|
|
|
}
|
|
|
|
|
|
|
|
// Host .
|
|
|
|
func (m *MockPeerManager) Host() host.Host {
|
|
|
|
return m.BHost
|
|
|
|
}
|
|
|
|
|
|
|
|
// ENR .
|
|
|
|
func (m MockPeerManager) ENR() *enr.Record {
|
|
|
|
return m.Enr
|
|
|
|
}
|
|
|
|
|
2021-01-07 13:35:42 +00:00
|
|
|
// DiscoveryAddresses .
|
|
|
|
func (m MockPeerManager) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) {
|
2020-12-17 18:03:18 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2020-06-18 03:53:46 +00:00
|
|
|
// RefreshENR .
|
2020-08-10 16:16:45 +00:00
|
|
|
func (m MockPeerManager) RefreshENR() {}
|
2020-06-18 03:53:46 +00:00
|
|
|
|
|
|
|
// FindPeersWithSubnet .
|
2020-12-12 02:40:56 +00:00
|
|
|
func (m MockPeerManager) FindPeersWithSubnet(_ context.Context, _ string, _, _ uint64) (bool, error) {
|
2020-06-18 03:53:46 +00:00
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddPingMethod .
|
2020-10-12 08:11:05 +00:00
|
|
|
func (m MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) {}
|