mock

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	MockPeerID peer.ID
}

func (Conn) Close

func (m Conn) Close() error

func (Conn) ConnState

func (m Conn) ConnState() libp2pnetwork.ConnectionState

func (Conn) GetStreams

func (m Conn) GetStreams() []libp2pnetwork.Stream

func (Conn) ID

func (m Conn) ID() string

func (Conn) IsClosed

func (m Conn) IsClosed() bool

func (Conn) LocalMultiaddr

func (m Conn) LocalMultiaddr() ma.Multiaddr

func (Conn) LocalPeer

func (m Conn) LocalPeer() peer.ID

func (Conn) LocalPrivateKey

func (m Conn) LocalPrivateKey() crypto.PrivKey

func (Conn) NewStream

func (m Conn) NewStream(ctx context.Context) (libp2pnetwork.Stream, error)

func (Conn) RemoteMultiaddr

func (m Conn) RemoteMultiaddr() ma.Multiaddr

func (Conn) RemotePeer

func (m Conn) RemotePeer() peer.ID

func (Conn) RemotePublicKey

func (m Conn) RemotePublicKey() crypto.PubKey

func (Conn) Scope

func (m Conn) Scope() libp2pnetwork.ConnScope

func (Conn) Stat

func (m Conn) Stat() libp2pnetwork.ConnStats

type IDService

type IDService struct {
	MockIdentifyWait chan struct{}
}

func (IDService) Close

func (m IDService) Close() error

func (IDService) IdentifyConn

func (m IDService) IdentifyConn(conn libp2pnetwork.Conn)

func (IDService) IdentifyWait

func (m IDService) IdentifyWait(conn libp2pnetwork.Conn) <-chan struct{}

func (IDService) ObservedAddrsFor

func (m IDService) ObservedAddrsFor(local ma.Multiaddr) []ma.Multiaddr

func (IDService) OwnObservedAddrs

func (m IDService) OwnObservedAddrs() []ma.Multiaddr

func (IDService) Start

func (m IDService) Start()

type MockConnectionIndex

type MockConnectionIndex struct {
	LimitValue bool
}

MockConnectionIndex is a mock implementation of the ConnectionIndex interface

func (*MockConnectionIndex) AtLimit added in v1.2.2

func (m *MockConnectionIndex) AtLimit(dir network.Direction) bool

AtLimit returns the mock value for Limit

func (*MockConnectionIndex) CanConnect

func (m *MockConnectionIndex) CanConnect(id peer.ID) bool

CanConnect panics if called

func (*MockConnectionIndex) Connectedness

func (m *MockConnectionIndex) Connectedness(id peer.ID) network.Connectedness

Connectedness panics if called

func (*MockConnectionIndex) IsBad

func (m *MockConnectionIndex) IsBad(logger *zap.Logger, id peer.ID) bool

IsBad panics if called

type Net

type Net struct {
	MockPeerstore peerstore.Peerstore
}

func (Net) Close

func (m Net) Close() error

func (Net) ClosePeer

func (m Net) ClosePeer(id peer.ID) error

func (Net) Connectedness

func (m Net) Connectedness(id peer.ID) libp2pnetwork.Connectedness

func (Net) Conns

func (m Net) Conns() []libp2pnetwork.Conn

func (Net) ConnsToPeer

func (m Net) ConnsToPeer(p peer.ID) []libp2pnetwork.Conn

func (Net) DialPeer

func (m Net) DialPeer(ctx context.Context, id peer.ID) (libp2pnetwork.Conn, error)

func (Net) InterfaceListenAddresses

func (m Net) InterfaceListenAddresses() ([]ma.Multiaddr, error)

func (Net) Listen

func (m Net) Listen(multiaddr ...ma.Multiaddr) error

func (Net) ListenAddresses

func (m Net) ListenAddresses() []ma.Multiaddr

func (Net) LocalPeer

func (m Net) LocalPeer() peer.ID

func (Net) NewStream

func (m Net) NewStream(ctx context.Context, id peer.ID) (libp2pnetwork.Stream, error)

func (Net) Notify

func (m Net) Notify(notifiee libp2pnetwork.Notifiee)

func (Net) Peers

func (m Net) Peers() []peer.ID

func (Net) Peerstore

func (m Net) Peerstore() peerstore.Peerstore

func (Net) ResourceManager

func (m Net) ResourceManager() libp2pnetwork.ResourceManager

func (Net) SetStreamHandler

func (m Net) SetStreamHandler(handler libp2pnetwork.StreamHandler)

func (Net) StopNotify

func (m Net) StopNotify(notifiee libp2pnetwork.Notifiee)

type NodeInfoIndex

type NodeInfoIndex struct {
	MockNodeInfo   *records.NodeInfo
	MockSelfSealed []byte
}

func (NodeInfoIndex) NodeInfo

func (m NodeInfoIndex) NodeInfo(id peer.ID) *records.NodeInfo

func (NodeInfoIndex) Self

func (m NodeInfoIndex) Self() *records.NodeInfo

func (NodeInfoIndex) SelfSealed

func (m NodeInfoIndex) SelfSealed(sender, recipient peer.ID, permissioned bool, operatorPrivateKey *rsa.PrivateKey) ([]byte, error)

func (NodeInfoIndex) SetNodeInfo

func (m NodeInfoIndex) SetNodeInfo(id peer.ID, node *records.NodeInfo)

func (NodeInfoIndex) UpdateSelfRecord

func (m NodeInfoIndex) UpdateSelfRecord(newInfo *records.NodeInfo)

type NodeStorage

type NodeStorage struct {
	MockGetPrivateKey               *rsa.PrivateKey
	RegisteredOperatorPublicKeyPEMs []string
}

func (NodeStorage) Begin

func (m NodeStorage) Begin() basedb.Txn

func (NodeStorage) BeginRead

func (m NodeStorage) BeginRead() basedb.ReadTxn

func (NodeStorage) BumpNonce

func (m NodeStorage) BumpNonce(txn basedb.ReadWriter, owner common.Address) error

func (NodeStorage) DeleteConfig

func (m NodeStorage) DeleteConfig(rw basedb.ReadWriter) error

func (NodeStorage) DeleteOperatorData

func (m NodeStorage) DeleteOperatorData(txn basedb.ReadWriter, id spectypes.OperatorID) error

func (NodeStorage) DeleteRecipientData

func (m NodeStorage) DeleteRecipientData(txn basedb.ReadWriter, owner common.Address) error

func (NodeStorage) DropOperators

func (m NodeStorage) DropOperators() error

func (NodeStorage) DropRecipients

func (m NodeStorage) DropRecipients() error

func (NodeStorage) DropRegistryData

func (m NodeStorage) DropRegistryData() error

func (NodeStorage) DropShares

func (m NodeStorage) DropShares() error

func (NodeStorage) GetConfig

func (m NodeStorage) GetConfig(rw basedb.ReadWriter) (*storage.ConfigLock, bool, error)

func (NodeStorage) GetLastProcessedBlock

func (m NodeStorage) GetLastProcessedBlock(txn basedb.Reader) (*big.Int, bool, error)

func (NodeStorage) GetNextNonce

func (m NodeStorage) GetNextNonce(txn basedb.Reader, owner common.Address) (registrystorage.Nonce, error)

func (NodeStorage) GetOperatorData

func (NodeStorage) GetOperatorDataByPubKey

func (m NodeStorage) GetOperatorDataByPubKey(txn basedb.Reader, operatorPublicKeyPEM []byte) (*registrystorage.OperatorData, bool, error)

func (NodeStorage) GetOperatorsPrefix

func (m NodeStorage) GetOperatorsPrefix() []byte

func (NodeStorage) GetPrivateKey

func (m NodeStorage) GetPrivateKey() (*rsa.PrivateKey, bool, error)

func (NodeStorage) GetRecipientData

func (m NodeStorage) GetRecipientData(txn basedb.Reader, owner common.Address) (*registrystorage.RecipientData, bool, error)

func (NodeStorage) GetRecipientDataMany

func (m NodeStorage) GetRecipientDataMany(txn basedb.Reader, owners []common.Address) (map[common.Address]bellatrix.ExecutionAddress, error)

func (NodeStorage) GetRecipientsPrefix

func (m NodeStorage) GetRecipientsPrefix() []byte

func (NodeStorage) ListOperators

func (m NodeStorage) ListOperators(txn basedb.Reader, from uint64, to uint64) ([]registrystorage.OperatorData, error)

func (NodeStorage) OperatorsExist

func (m NodeStorage) OperatorsExist(r basedb.Reader, ids []spectypes.OperatorID) (bool, error)

func (NodeStorage) SaveConfig

func (m NodeStorage) SaveConfig(rw basedb.ReadWriter, config *storage.ConfigLock) error

func (NodeStorage) SaveLastProcessedBlock

func (m NodeStorage) SaveLastProcessedBlock(txn basedb.ReadWriter, offset *big.Int) error

func (NodeStorage) SaveOperatorData

func (m NodeStorage) SaveOperatorData(txn basedb.ReadWriter, operatorData *registrystorage.OperatorData) (bool, error)

func (NodeStorage) SaveRecipientData

func (m NodeStorage) SaveRecipientData(txn basedb.ReadWriter, recipientData *registrystorage.RecipientData) (*registrystorage.RecipientData, error)

func (NodeStorage) SetupPrivateKey

func (m NodeStorage) SetupPrivateKey(operatorKeyBase64 string) ([]byte, error)

func (NodeStorage) Shares

func (m NodeStorage) Shares() registrystorage.Shares

type Peerstore

type Peerstore struct {
	ExistingPIDs               []peer.ID
	MockFirstSupportedProtocol libp2p_protocol.ID
}

func (Peerstore) AddAddr

func (p Peerstore) AddAddr(pid peer.ID, addr ma.Multiaddr, ttl time.Duration)

func (Peerstore) AddAddrs

func (p Peerstore) AddAddrs(pid peer.ID, addrs []ma.Multiaddr, ttl time.Duration)

func (Peerstore) AddPrivKey

func (p Peerstore) AddPrivKey(id peer.ID, key crypto.PrivKey) error

func (Peerstore) AddProtocols

func (p Peerstore) AddProtocols(id peer.ID, s ...libp2p_protocol.ID) error

func (Peerstore) AddPubKey

func (p Peerstore) AddPubKey(id peer.ID, key crypto.PubKey) error

func (Peerstore) AddrStream

func (p Peerstore) AddrStream(ctx context.Context, id peer.ID) <-chan ma.Multiaddr

func (Peerstore) Addrs

func (p Peerstore) Addrs(pid peer.ID) []ma.Multiaddr

func (Peerstore) ClearAddrs

func (p Peerstore) ClearAddrs(pid peer.ID)

func (Peerstore) Close

func (p Peerstore) Close() error

func (Peerstore) FirstSupportedProtocol

func (p Peerstore) FirstSupportedProtocol(id peer.ID, s ...libp2p_protocol.ID) (libp2p_protocol.ID, error)

func (Peerstore) Get

func (p Peerstore) Get(pid peer.ID, key string) (interface{}, error)

func (Peerstore) GetProtocols

func (p Peerstore) GetProtocols(id peer.ID) ([]libp2p_protocol.ID, error)

func (Peerstore) LatencyEWMA

func (p Peerstore) LatencyEWMA(id peer.ID) time.Duration

func (Peerstore) PeerInfo

func (p Peerstore) PeerInfo(id peer.ID) peer.AddrInfo

func (Peerstore) Peers

func (p Peerstore) Peers() peer.IDSlice

func (Peerstore) PeersWithAddrs

func (p Peerstore) PeersWithAddrs() peer.IDSlice

func (Peerstore) PeersWithKeys

func (p Peerstore) PeersWithKeys() peer.IDSlice

func (Peerstore) PrivKey

func (p Peerstore) PrivKey(id peer.ID) crypto.PrivKey

func (Peerstore) PubKey

func (p Peerstore) PubKey(id peer.ID) crypto.PubKey

func (Peerstore) Put

func (p Peerstore) Put(pid peer.ID, key string, val interface{}) error

func (Peerstore) RecordLatency

func (p Peerstore) RecordLatency(id peer.ID, duration time.Duration)

func (Peerstore) RemovePeer

func (p Peerstore) RemovePeer(id peer.ID)

func (Peerstore) RemoveProtocols

func (p Peerstore) RemoveProtocols(id peer.ID, s ...libp2p_protocol.ID) error

func (Peerstore) SetAddr

func (p Peerstore) SetAddr(pid peer.ID, addr ma.Multiaddr, ttl time.Duration)

func (Peerstore) SetAddrs

func (p Peerstore) SetAddrs(pid peer.ID, addrs []ma.Multiaddr, ttl time.Duration)

func (Peerstore) SetProtocols

func (p Peerstore) SetProtocols(id peer.ID, s ...libp2p_protocol.ID) error

func (Peerstore) SupportsProtocols

func (p Peerstore) SupportsProtocols(id peer.ID, s ...libp2p_protocol.ID) ([]libp2p_protocol.ID, error)

func (Peerstore) UpdateAddrs

func (p Peerstore) UpdateAddrs(pid peer.ID, oldTTL time.Duration, newTTL time.Duration)

type StreamController

type StreamController struct {
	MockRequest []byte
}

func (StreamController) HandleStream

func (m StreamController) HandleStream(logger *zap.Logger, stream core.Stream) ([]byte, streams.StreamResponder, func(), error)

func (StreamController) Request

func (m StreamController) Request(logger *zap.Logger, peerID peer.ID, protocol protocol.ID, msg []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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