mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
6bea17cb54
* Update libp2p to support go 1.19 * gaz * go mod tidy * Only update the minimum deps * go mod tidy * revert .bazelrc * Update go-libp2p to v0.22.0 and update import paths (#11440) * Fix import paths * Fix go-libp2p-peerstore import * Bazel updates * fix * revert some comments changes * revert some comment stuff * fix dependency issues * vendor problematic library * use your brain * remove * tests Co-authored-by: Marco Munizaga <marco@marcopolo.io> Co-authored-by: Nishant Das <nishdas93@gmail.com>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
|
"github.com/libp2p/go-libp2p/core/host"
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
"github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
// MockPeerManager is mock of the PeerManager interface.
|
|
type MockPeerManager struct {
|
|
Enr *enr.Record
|
|
PID peer.ID
|
|
BHost host.Host
|
|
DiscoveryAddr []multiaddr.Multiaddr
|
|
FailDiscoveryAddr bool
|
|
}
|
|
|
|
// Disconnect .
|
|
func (_ *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
|
|
}
|
|
|
|
// DiscoveryAddresses .
|
|
func (m MockPeerManager) DiscoveryAddresses() ([]multiaddr.Multiaddr, error) {
|
|
if m.FailDiscoveryAddr {
|
|
return nil, errors.New("fail")
|
|
}
|
|
return m.DiscoveryAddr, nil
|
|
}
|
|
|
|
// RefreshENR .
|
|
func (_ MockPeerManager) RefreshENR() {}
|
|
|
|
// FindPeersWithSubnet .
|
|
func (_ MockPeerManager) FindPeersWithSubnet(_ context.Context, _ string, _ uint64, _ int) (bool, error) {
|
|
return true, nil
|
|
}
|
|
|
|
// AddPingMethod .
|
|
func (_ MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) {}
|