mock

package
v2.2.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAddProtocolFunc

func WithAddProtocolFunc(f func(p2p.ProtocolSpec) error) Option

WithAddProtocolFunc sets the mock implementation of the AddProtocol function

func WithAddressesFunc

func WithAddressesFunc(f func() ([]ma.Multiaddr, error)) Option

WithAddressesFunc sets the mock implementation of the Addresses function

func WithBlocklistFunc

func WithBlocklistFunc(f func(swarm.Address, time.Duration, string) error) Option

func WithBlocklistedPeersFunc

func WithBlocklistedPeersFunc(f func() ([]p2p.BlockListedPeer, error)) Option

WithBlocklistedPeersFunc sets the mock implementation of the BlocklistedPeers function

func WithConnectFunc

func WithConnectFunc(f func(ctx context.Context, addr ma.Multiaddr) (address *bzz.Address, err error)) Option

WithConnectFunc sets the mock implementation of the Connect function

func WithDisconnectFunc

func WithDisconnectFunc(f func(overlay swarm.Address, reason string) error) Option

WithDisconnectFunc sets the mock implementation of the Disconnect function

func WithGetWelcomeMessageFunc

func WithGetWelcomeMessageFunc(f func() string) Option

WithGetWelcomeMessageFunc sets the mock implementation of the GetWelcomeMessage function

func WithPeersFunc

func WithPeersFunc(f func() []p2p.Peer) Option

WithPeersFunc sets the mock implementation of the Peers function

func WithSetWelcomeMessageFunc

func WithSetWelcomeMessageFunc(f func(string) error) Option

WithSetWelcomeMessageFunc sets the mock implementation of the SetWelcomeMessage function

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the mock of a P2P Service

func New

func New(opts ...Option) *Service

New will create a new mock P2P Service with the given options

func (*Service) AddProtocol

func (s *Service) AddProtocol(spec p2p.ProtocolSpec) error

func (*Service) Addresses

func (s *Service) Addresses() ([]ma.Multiaddr, error)

func (*Service) Blocklist

func (s *Service) Blocklist(overlay swarm.Address, duration time.Duration, reason string) error

func (*Service) Blocklisted

func (s *Service) Blocklisted(overlay swarm.Address) (bool, error)

func (*Service) BlocklistedPeers

func (s *Service) BlocklistedPeers() ([]p2p.BlockListedPeer, error)

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (address *bzz.Address, err error)

func (*Service) Disconnect

func (s *Service) Disconnect(overlay swarm.Address, reason string) error

func (*Service) GetWelcomeMessage

func (s *Service) GetWelcomeMessage() string

func (*Service) Halt

func (s *Service) Halt()

func (*Service) NetworkStatus

func (s *Service) NetworkStatus() p2p.NetworkStatus

NetworkStatus implements p2p.NetworkStatuser interface. It always returns p2p.NetworkStatusAvailable.

func (*Service) Peers

func (s *Service) Peers() []p2p.Peer

func (*Service) SetPickyNotifier

func (s *Service) SetPickyNotifier(f p2p.PickyNotifier)

func (*Service) SetWelcomeMessage

func (s *Service) SetWelcomeMessage(val string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL