mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
5569a68452
* Value assigned to a variable is never read before being overwritten * The result of append is not used anywhere * Suspicious assignment of range-loop vars detected * Unused method receiver detected * Revert "Auxiliary commit to revert individual files from 54edcb445484a2e5d79612e19af8e949b8861253" This reverts commit bbd1e1beabf7b0c5cfc4f514dcc820062ad6c063. * Method modifies receiver * Fix test * Duplicate imports detected * Incorrectly formatted error string * Types of function parameters can be combined * One more "Unused method receiver detected" * Unused parameter detected in function
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) (bool, error) {
|
|
return true, nil
|
|
}
|
|
|
|
// AddPingMethod .
|
|
func (_ MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error) {}
|