Documentation
¶
Overview ¶
Package testing includes useful utilities for mocking a beacon node's p2p service for unit tests.
Index ¶
- Constants
- type FakeP2P
- func (*FakeP2P) AddConnectionHandler(_, _ func(ctx context.Context, id peer.ID) error)
- func (*FakeP2P) AddDisconnectionHandler(_ func(ctx context.Context, id peer.ID) error)
- func (*FakeP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error)
- func (*FakeP2P) Broadcast(_ context.Context, _ proto.Message) error
- func (*FakeP2P) BroadcastAttestation(_ context.Context, _ uint64, _ ethpb.Att) error
- func (*FakeP2P) BroadcastBlob(_ context.Context, _ uint64, _ *ethpb.BlobSidecar) error
- func (*FakeP2P) BroadcastDataColumnSidecars(_ context.Context, _ []blocks.VerifiedRODataColumn) error
- func (*FakeP2P) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
- func (*FakeP2P) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
- func (*FakeP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
- func (*FakeP2P) CustodyGroupCount(context.Context) (uint64, error)
- func (*FakeP2P) CustodyGroupCountFromPeer(peer.ID) uint64
- func (*FakeP2P) Disconnect(_ peer.ID) error
- func (*FakeP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error)
- func (*FakeP2P) ENR() *enr.Record
- func (*FakeP2P) EarliestAvailableSlot(context.Context) (primitives.Slot, error)
- func (*FakeP2P) Encoding() encoder.NetworkEncoding
- func (*FakeP2P) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, ...) error
- func (*FakeP2P) Host() host.Host
- func (*FakeP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
- func (*FakeP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool)
- func (*FakeP2P) InterceptPeerDial(peer.ID) (allow bool)
- func (*FakeP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool)
- func (*FakeP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
- func (*FakeP2P) JoinTopic(_ string, _ ...pubsub.TopicOpt) (*pubsub.Topic, error)
- func (*FakeP2P) LeaveTopic(_ string) error
- func (*FakeP2P) Metadata() metadata.Metadata
- func (*FakeP2P) MetadataSeq() uint64
- func (*FakeP2P) NodeID() enode.ID
- func (*FakeP2P) PeerID() peer.ID
- func (*FakeP2P) Peers() *peers.Status
- func (*FakeP2P) PubSub() *pubsub.PubSub
- func (*FakeP2P) PublishToTopic(_ context.Context, _ string, _ []byte, _ ...pubsub.PubOpt) error
- func (*FakeP2P) RefreshPersistentSubnets()
- func (*FakeP2P) Send(_ context.Context, _ any, _ string, _ peer.ID) (network.Stream, error)
- func (*FakeP2P) SetStreamHandler(_ string, _ network.StreamHandler)
- func (*FakeP2P) SubscribeToTopic(_ string, _ ...pubsub.SubOpt) (*pubsub.Subscription, error)
- func (s *FakeP2P) UpdateCustodyInfo(earliestAvailableSlot primitives.Slot, custodyGroupCount uint64) (primitives.Slot, uint64, error)
- func (*FakeP2P) UpdateEarliestAvailableSlot(earliestAvailableSlot primitives.Slot) error
- type MockBroadcaster
- func (m *MockBroadcaster) Broadcast(_ context.Context, msg proto.Message) error
- func (m *MockBroadcaster) BroadcastAttestation(_ context.Context, _ uint64, a ethpb.Att) error
- func (m *MockBroadcaster) BroadcastBlob(context.Context, uint64, *ethpb.BlobSidecar) error
- func (m *MockBroadcaster) BroadcastDataColumnSidecars(context.Context, []blocks.VerifiedRODataColumn) error
- func (m *MockBroadcaster) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
- func (m *MockBroadcaster) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
- func (m *MockBroadcaster) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
- func (m *MockBroadcaster) NumAttestations() int
- func (m *MockBroadcaster) NumMessages() int
- type MockHost
- func (m *MockHost) Addrs() []ma.Multiaddr
- func (*MockHost) Close() error
- func (*MockHost) ConnManager() connmgr.ConnManager
- func (*MockHost) Connect(_ context.Context, _ peer.AddrInfo) error
- func (*MockHost) EventBus() event.Bus
- func (*MockHost) ID() peer.ID
- func (*MockHost) Mux() protocol.Switch
- func (*MockHost) Network() network.Network
- func (*MockHost) NewStream(_ context.Context, _ peer.ID, _ ...protocol.ID) (network.Stream, error)
- func (*MockHost) Peerstore() peerstore.Peerstore
- func (*MockHost) RemoveStreamHandler(_ protocol.ID)
- func (*MockHost) SetStreamHandler(_ protocol.ID, _ network.StreamHandler)
- func (*MockHost) SetStreamHandlerMatch(protocol.ID, func(id protocol.ID) bool, network.StreamHandler)
- type MockIterator
- type MockListener
- func (m *MockListener) Close()
- func (m *MockListener) LocalNode() *enode.LocalNode
- func (m *MockListener) Lookup(id enode.ID) []*enode.Node
- func (m *MockListener) Ping(node *enode.Node) error
- func (m *MockListener) RandomNodes() enode.Iterator
- func (m *MockListener) RebootListener() error
- func (m *MockListener) RequestENR(node *enode.Node) (*enode.Node, error)
- func (m *MockListener) Resolve(node *enode.Node) *enode.Node
- func (m *MockListener) Self() *enode.Node
- type MockMetadataProvider
- type MockPeerManager
- func (*MockPeerManager) AddPingMethod(_ func(ctx context.Context, id peer.ID) error)
- func (*MockPeerManager) Disconnect(peer.ID) error
- func (m *MockPeerManager) DiscoveryAddresses() ([]multiaddr.Multiaddr, error)
- func (m *MockPeerManager) ENR() *enr.Record
- func (*MockPeerManager) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, ...) error
- func (m *MockPeerManager) Host() host.Host
- func (m MockPeerManager) NodeID() enode.ID
- func (m *MockPeerManager) PeerID() peer.ID
- func (*MockPeerManager) RefreshPersistentSubnets()
- type MockPeersProvider
- type TestP2P
- func (p *TestP2P) AddConnectionHandler(f, _ func(ctx context.Context, id peer.ID) error)
- func (p *TestP2P) AddDisconnectionHandler(f func(ctx context.Context, id peer.ID) error)
- func (*TestP2P) AddPingMethod(_ func(ctx context.Context, id peer.ID) error)
- func (p *TestP2P) Broadcast(_ context.Context, _ proto.Message) error
- func (p *TestP2P) BroadcastAttestation(_ context.Context, _ uint64, _ ethpb.Att) error
- func (p *TestP2P) BroadcastBlob(context.Context, uint64, *ethpb.BlobSidecar) error
- func (p *TestP2P) BroadcastDataColumnSidecars(context.Context, []blocks.VerifiedRODataColumn) error
- func (p *TestP2P) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
- func (p *TestP2P) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
- func (p *TestP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
- func (p *TestP2P) Connect(b *TestP2P)
- func (s *TestP2P) CustodyGroupCount(context.Context) (uint64, error)
- func (s *TestP2P) CustodyGroupCountFromPeer(pid peer.ID) uint64
- func (p *TestP2P) Disconnect(pid peer.ID) error
- func (*TestP2P) DiscoveryAddresses() ([]multiaddr.Multiaddr, error)
- func (p *TestP2P) ENR() *enr.Record
- func (s *TestP2P) EarliestAvailableSlot(context.Context) (primitives.Slot, error)
- func (*TestP2P) Encoding() encoder.NetworkEncoding
- func (*TestP2P) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, ...) error
- func (p *TestP2P) ForkDigest() ([4]byte, error)
- func (p *TestP2P) Host() host.Host
- func (*TestP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
- func (*TestP2P) InterceptAddrDial(peer.ID, multiaddr.Multiaddr) (allow bool)
- func (*TestP2P) InterceptPeerDial(peer.ID) (allow bool)
- func (*TestP2P) InterceptSecured(network.Direction, peer.ID, network.ConnMultiaddrs) (allow bool)
- func (*TestP2P) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
- func (p *TestP2P) JoinTopic(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error)
- func (p *TestP2P) LeaveTopic(topic string) error
- func (p *TestP2P) Metadata() metadata.Metadata
- func (p *TestP2P) MetadataSeq() uint64
- func (p *TestP2P) NodeID() enode.ID
- func (p *TestP2P) PeerID() peer.ID
- func (p *TestP2P) Peers() *peers.Status
- func (p *TestP2P) PubSub() *pubsub.PubSub
- func (p *TestP2P) PublishToTopic(ctx context.Context, topic string, data []byte, opts ...pubsub.PubOpt) error
- func (p *TestP2P) ReceivePubSub(topic string, msg proto.Message)
- func (p *TestP2P) ReceiveRPC(topic string, msg proto.Message)
- func (*TestP2P) RefreshPersistentSubnets()
- func (p *TestP2P) Send(ctx context.Context, msg any, topic string, pid peer.ID) (network.Stream, error)
- func (p *TestP2P) SetStreamHandler(topic string, handler network.StreamHandler)
- func (*TestP2P) Started() bool
- func (p *TestP2P) SubscribeToTopic(topic string, opts ...pubsub.SubOpt) (*pubsub.Subscription, error)
- func (s *TestP2P) UpdateCustodyInfo(earliestAvailableSlot primitives.Slot, custodyGroupCount uint64) (primitives.Slot, uint64, error)
- func (s *TestP2P) UpdateEarliestAvailableSlot(earliestAvailableSlot primitives.Slot) error
Constants ¶
const ( MockRawPeerId0 = "16Uiu2HAkyWZ4Ni1TpvDS8dPxsozmHY85KaiFjodQuV6Tz5tkHVeR" MockRawPeerId1 = "16Uiu2HAm4HgJ9N1o222xK61o7LSgToYWoAy1wNTJRkh9gLZapVAy" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeP2P ¶
type FakeP2P struct {
}
FakeP2P stack
func (*FakeP2P) AddConnectionHandler ¶
AddConnectionHandler -- fake.
func (*FakeP2P) AddDisconnectionHandler ¶
AddDisconnectionHandler -- fake.
func (*FakeP2P) AddPingMethod ¶
AddPingMethod -- fake.
func (*FakeP2P) BroadcastAttestation ¶
BroadcastAttestation -- fake.
func (*FakeP2P) BroadcastBlob ¶
BroadcastBlob -- fake.
func (*FakeP2P) BroadcastDataColumnSidecars ¶
func (*FakeP2P) BroadcastDataColumnSidecars(_ context.Context, _ []blocks.VerifiedRODataColumn) error
BroadcastDataColumnSidecar -- fake.
func (*FakeP2P) BroadcastLightClientFinalityUpdate ¶
func (*FakeP2P) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
BroadcastLightClientFinalityUpdate -- fake.
func (*FakeP2P) BroadcastLightClientOptimisticUpdate ¶
func (*FakeP2P) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
BroadcastLightClientOptimisticUpdate -- fake.
func (*FakeP2P) BroadcastSyncCommitteeMessage ¶
func (*FakeP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
BroadcastSyncCommitteeMessage -- fake.
func (*FakeP2P) CustodyGroupCount ¶
CustodyGroupCount -- fake.
func (*FakeP2P) CustodyGroupCountFromPeer ¶
CustodyGroupCountFromPeer -- fake.
func (*FakeP2P) DiscoveryAddresses ¶
DiscoveryAddresses -- fake
func (*FakeP2P) EarliestAvailableSlot ¶
EarliestAvailableSlot -- fake.
func (*FakeP2P) FindAndDialPeersWithSubnets ¶
func (*FakeP2P) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, digest [fieldparams.VersionLength]byte, minimumPeersPerSubnet int, subnets map[uint64]bool) error
FindAndDialPeersWithSubnets mocks the p2p func.
func (*FakeP2P) InterceptAccept ¶
func (*FakeP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
InterceptAccept -- fake.
func (*FakeP2P) InterceptAddrDial ¶
InterceptAddrDial -- fake.
func (*FakeP2P) InterceptPeerDial ¶
InterceptPeerDial -- fake.
func (*FakeP2P) InterceptSecured ¶
InterceptSecured -- fake.
func (*FakeP2P) InterceptUpgraded ¶
InterceptUpgraded -- fake.
func (*FakeP2P) PublishToTopic ¶
PublishToTopic -- fake.
func (*FakeP2P) RefreshPersistentSubnets ¶
func (*FakeP2P) RefreshPersistentSubnets()
RefreshPersistentSubnets mocks the p2p func.
func (*FakeP2P) SetStreamHandler ¶
func (*FakeP2P) SetStreamHandler(_ string, _ network.StreamHandler)
SetStreamHandler -- fake.
func (*FakeP2P) SubscribeToTopic ¶
SubscribeToTopic -- fake.
func (*FakeP2P) UpdateCustodyInfo ¶
func (s *FakeP2P) UpdateCustodyInfo(earliestAvailableSlot primitives.Slot, custodyGroupCount uint64) (primitives.Slot, uint64, error)
UpdateCustodyInfo -- fake.
func (*FakeP2P) UpdateEarliestAvailableSlot ¶
func (*FakeP2P) UpdateEarliestAvailableSlot(earliestAvailableSlot primitives.Slot) error
UpdateEarliestAvailableSlot -- fake.
type MockBroadcaster ¶
type MockBroadcaster struct {
BroadcastCalled atomic.Bool
BroadcastMessages []proto.Message
BroadcastAttestations []ethpb.Att
// contains filtered or unexported fields
}
MockBroadcaster implements p2p.Broadcaster for testing.
func (*MockBroadcaster) BroadcastAttestation ¶
BroadcastAttestation records a broadcast occurred.
func (*MockBroadcaster) BroadcastBlob ¶
func (m *MockBroadcaster) BroadcastBlob(context.Context, uint64, *ethpb.BlobSidecar) error
BroadcastBlob broadcasts a blob for mock.
func (*MockBroadcaster) BroadcastDataColumnSidecars ¶
func (m *MockBroadcaster) BroadcastDataColumnSidecars(context.Context, []blocks.VerifiedRODataColumn) error
BroadcastDataColumnSidecar broadcasts a data column for mock.
func (*MockBroadcaster) BroadcastLightClientFinalityUpdate ¶
func (m *MockBroadcaster) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
BroadcastLightClientFinalityUpdate records a broadcast occurred.
func (*MockBroadcaster) BroadcastLightClientOptimisticUpdate ¶
func (m *MockBroadcaster) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
BroadcastLightClientOptimisticUpdate records a broadcast occurred.
func (*MockBroadcaster) BroadcastSyncCommitteeMessage ¶
func (m *MockBroadcaster) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
BroadcastSyncCommitteeMessage records a broadcast occurred.
func (*MockBroadcaster) NumAttestations ¶
func (m *MockBroadcaster) NumAttestations() int
NumAttestations returns the number of attestations broadcasted.
func (*MockBroadcaster) NumMessages ¶
func (m *MockBroadcaster) NumMessages() int
NumMessages returns the number of messages broadcasted.
type MockHost ¶
MockHost is a fake implementation of libp2p2's Host interface.
func (*MockHost) RemoveStreamHandler ¶
RemoveStreamHandler --
func (*MockHost) SetStreamHandler ¶
func (*MockHost) SetStreamHandler(_ protocol.ID, _ network.StreamHandler)
SetStreamHandler --
func (*MockHost) SetStreamHandlerMatch ¶
func (*MockHost) SetStreamHandlerMatch(protocol.ID, func(id protocol.ID) bool, network.StreamHandler)
SetStreamHandlerMatch --
type MockIterator ¶
MockIterator is a mock implementation of enode.Iterator for testing
func NewMockIterator ¶
func NewMockIterator(nodes []*enode.Node) *MockIterator
func (*MockIterator) Close ¶
func (m *MockIterator) Close()
func (*MockIterator) Next ¶
func (m *MockIterator) Next() bool
func (*MockIterator) Node ¶
func (m *MockIterator) Node() *enode.Node
type MockListener ¶
type MockListener struct {
LocalNodeFunc func() *enode.LocalNode
SelfFunc func() *enode.Node
RandomNodesFunc func() enode.Iterator
LookupFunc func(enode.ID) []*enode.Node
ResolveFunc func(*enode.Node) *enode.Node
PingFunc func(*enode.Node) error
RequestENRFunc func(*enode.Node) (*enode.Node, error)
RebootFunc func() error
CloseFunc func()
// contains filtered or unexported fields
}
MockListener is a mock implementation of the Listener and ListenerRebooter interfaces that can be used in tests. It provides configurable behavior for all methods.
func NewMockListener ¶
func NewMockListener(localNode *enode.LocalNode, iterator enode.Iterator) *MockListener
NewMockListener creates a new MockListener with default implementations
func (*MockListener) Close ¶
func (m *MockListener) Close()
func (*MockListener) LocalNode ¶
func (m *MockListener) LocalNode() *enode.LocalNode
func (*MockListener) RandomNodes ¶
func (m *MockListener) RandomNodes() enode.Iterator
func (*MockListener) RebootListener ¶
func (m *MockListener) RebootListener() error
func (*MockListener) RequestENR ¶
func (*MockListener) Self ¶
func (m *MockListener) Self() *enode.Node
type MockMetadataProvider ¶
MockMetadataProvider is a fake implementation of the MetadataProvider interface.
func (*MockMetadataProvider) Metadata ¶
func (m *MockMetadataProvider) Metadata() metadata.Metadata
Metadata --
func (*MockMetadataProvider) MetadataSeq ¶
func (m *MockMetadataProvider) MetadataSeq() uint64
MetadataSeq --
type MockPeerManager ¶
type MockPeerManager struct {
Enr *enr.Record
PID peer.ID
BHost host.Host
DiscoveryAddr []multiaddr.Multiaddr
FailDiscoveryAddr bool
}
MockPeerManager is mock of the PeerManager interface.
func (*MockPeerManager) AddPingMethod ¶
AddPingMethod .
func (*MockPeerManager) DiscoveryAddresses ¶
func (m *MockPeerManager) DiscoveryAddresses() ([]multiaddr.Multiaddr, error)
DiscoveryAddresses .
func (*MockPeerManager) FindAndDialPeersWithSubnets ¶
func (*MockPeerManager) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, digest [fieldparams.VersionLength]byte, minimumPeersPerSubnet int, subnets map[uint64]bool) error
FindAndDialPeersWithSubnet .
func (*MockPeerManager) RefreshPersistentSubnets ¶
func (*MockPeerManager) RefreshPersistentSubnets()
RefreshPersistentSubnets .
type MockPeersProvider ¶
type MockPeersProvider struct {
// contains filtered or unexported fields
}
MockPeersProvider implements PeersProvider for testing.
func (*MockPeersProvider) ClearPeers ¶
func (m *MockPeersProvider) ClearPeers()
ClearPeers removes all known peers.
func (*MockPeersProvider) Peers ¶
func (m *MockPeersProvider) Peers() *peers.Status
Peers provides access the peer status.
type TestP2P ¶
type TestP2P struct {
BHost host.Host
EnodeID enode.ID
BroadcastCalled atomic.Bool
DelaySend bool
Digest [4]byte
LocalMetadata metadata.Metadata
// contains filtered or unexported fields
}
TestP2P represents a p2p implementation that can be used for testing.
func NewTestP2P ¶
NewTestP2P initializes a new p2p test service.
func NewTestP2PWithPubsubOptions ¶ added in v7.1.3
func NewTestP2PWithPubsubOptions(t *testing.T, pubsubOpts []pubsub.Option, userOptions ...config.Option) *TestP2P
NewTestP2PWithPubsubOptions initializes a new p2p test service with custom pubsub options.
func (*TestP2P) AddConnectionHandler ¶
AddConnectionHandler handles the connection with a newly connected peer.
func (*TestP2P) AddDisconnectionHandler ¶
AddDisconnectionHandler --
func (*TestP2P) AddPingMethod ¶
AddPingMethod mocks the p2p func.
func (*TestP2P) BroadcastAttestation ¶
BroadcastAttestation broadcasts an attestation.
func (*TestP2P) BroadcastBlob ¶
BroadcastBlob broadcasts a blob for mock.
func (*TestP2P) BroadcastDataColumnSidecars ¶
BroadcastDataColumnSidecar broadcasts a data column for mock.
func (*TestP2P) BroadcastLightClientFinalityUpdate ¶
func (p *TestP2P) BroadcastLightClientFinalityUpdate(_ context.Context, _ interfaces.LightClientFinalityUpdate) error
BroadcastLightClientFinalityUpdate broadcasts a finality update for mock.
func (*TestP2P) BroadcastLightClientOptimisticUpdate ¶
func (p *TestP2P) BroadcastLightClientOptimisticUpdate(_ context.Context, _ interfaces.LightClientOptimisticUpdate) error
BroadcastLightClientOptimisticUpdate broadcasts an optimistic update for mock.
func (*TestP2P) BroadcastSyncCommitteeMessage ¶
func (p *TestP2P) BroadcastSyncCommitteeMessage(_ context.Context, _ uint64, _ *ethpb.SyncCommitteeMessage) error
BroadcastSyncCommitteeMessage broadcasts a sync committee message.
func (*TestP2P) CustodyGroupCount ¶
CustodyGroupCount .
func (*TestP2P) CustodyGroupCountFromPeer ¶
CustodyGroupCountFromPeer retrieves custody group count from a peer. It first tries to get the custody group count from the peer's metadata, then falls back to the ENR value if the metadata is not available, then falls back to the minimum number of custody groups an honest node should custodiy and serve samples from if ENR is not available.
func (*TestP2P) Disconnect ¶
Disconnect from a peer.
func (*TestP2P) DiscoveryAddresses ¶
DiscoveryAddresses --
func (*TestP2P) EarliestAvailableSlot ¶
EarliestAvailableSlot .
func (*TestP2P) Encoding ¶
func (*TestP2P) Encoding() encoder.NetworkEncoding
Encoding returns ssz encoding.
func (*TestP2P) FindAndDialPeersWithSubnets ¶
func (*TestP2P) FindAndDialPeersWithSubnets(ctx context.Context, topicFormat string, digest [fieldparams.VersionLength]byte, minimumPeersPerSubnet int, subnets map[uint64]bool) error
FindAndDialPeersWithSubnets mocks the p2p func.
func (*TestP2P) ForkDigest ¶
ForkDigest mocks the p2p func.
func (*TestP2P) InterceptAccept ¶
func (*TestP2P) InterceptAccept(_ network.ConnMultiaddrs) (allow bool)
InterceptAccept .
func (*TestP2P) InterceptAddrDial ¶
InterceptAddrDial .
func (*TestP2P) InterceptPeerDial ¶
InterceptPeerDial .
func (*TestP2P) InterceptSecured ¶
InterceptSecured .
func (*TestP2P) InterceptUpgraded ¶
InterceptUpgraded .
func (*TestP2P) LeaveTopic ¶
LeaveTopic closes topic and removes corresponding handler from list of joined topics. This method will return error if there are outstanding event handlers or subscriptions.
func (*TestP2P) MetadataSeq ¶
MetadataSeq mocks metadata sequence number.
func (*TestP2P) PubSub ¶
PubSub returns reference underlying floodsub. This test library uses floodsub to ensure all connected peers receive the message.
func (*TestP2P) PublishToTopic ¶
func (p *TestP2P) PublishToTopic(ctx context.Context, topic string, data []byte, opts ...pubsub.PubOpt) error
PublishToTopic publishes message to previously joined topic.
func (*TestP2P) ReceivePubSub ¶
ReceivePubSub simulates an incoming message over pubsub on a given topic.
func (*TestP2P) ReceiveRPC ¶
ReceiveRPC simulates an incoming RPC.
func (*TestP2P) RefreshPersistentSubnets ¶
func (*TestP2P) RefreshPersistentSubnets()
RefreshPersistentSubnets mocks the p2p func.
func (*TestP2P) Send ¶
func (p *TestP2P) Send(ctx context.Context, msg any, topic string, pid peer.ID) (network.Stream, error)
Send a message to a specific peer.
func (*TestP2P) SetStreamHandler ¶
func (p *TestP2P) SetStreamHandler(topic string, handler network.StreamHandler)
SetStreamHandler for RPC.
func (*TestP2P) SubscribeToTopic ¶
func (p *TestP2P) SubscribeToTopic(topic string, opts ...pubsub.SubOpt) (*pubsub.Subscription, error)
SubscribeToTopic joins (if necessary) and subscribes to PubSub topic.
func (*TestP2P) UpdateCustodyInfo ¶
func (s *TestP2P) UpdateCustodyInfo(earliestAvailableSlot primitives.Slot, custodyGroupCount uint64) (primitives.Slot, uint64, error)
UpdateCustodyInfo .
func (*TestP2P) UpdateEarliestAvailableSlot ¶
func (s *TestP2P) UpdateEarliestAvailableSlot(earliestAvailableSlot primitives.Slot) error
UpdateEarliestAvailableSlot .