Documentation ¶
Index ¶
- func EnsureConnected(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode)
- func EnsureNoPubsubExchangeBetweenGroups(t *testing.T, ctx context.Context, groupA []p2p.LibP2PNode, ...)
- func EnsureNoPubsubMessageExchange(t *testing.T, ctx context.Context, from []p2p.LibP2PNode, to []p2p.LibP2PNode, ...)
- func EnsureNotConnectedBetweenGroups(t *testing.T, ctx context.Context, groupA []p2p.LibP2PNode, ...)
- func EnsurePubsubMessageExchange(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode, ...)
- func EnsureStreamCreationInBothDirections(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode)
- func LetNodesDiscoverEachOther(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode, ...)
- func NetworkingKeyFixtures(t *testing.T) crypto.PrivateKey
- func NodeFixture(t *testing.T, sporkID flow.Identifier, dhtPrefix string, ...) (p2p.LibP2PNode, flow.Identity)
- func NodesFixture(t *testing.T, sporkID flow.Identifier, dhtPrefix string, count int, ...) ([]p2p.LibP2PNode, flow.IdentityList)
- func PeerIdFixture(t *testing.T) peer.ID
- func PeerIdSliceFixture(t *testing.T, n int) peer.IDSlice
- func StartNode(t *testing.T, ctx irrecoverable.SignalerContext, node p2p.LibP2PNode, ...)
- func StartNodes(t *testing.T, ctx irrecoverable.SignalerContext, nodes []p2p.LibP2PNode, ...)
- func StopNode(t *testing.T, node p2p.LibP2PNode, cancel context.CancelFunc, ...)
- func StopNodes(t *testing.T, nodes []p2p.LibP2PNode, cancel context.CancelFunc, ...)
- func StreamHandlerFixture(t *testing.T) (func(s network.Stream), chan string)
- type NodeFixtureParameterOption
- func WithConnectionGater(connGater connmgr.ConnectionGater) NodeFixtureParameterOption
- func WithConnectionManager(connManager connmgr.ConnManager) NodeFixtureParameterOption
- func WithCreateStreamRetryDelay(delay time.Duration) NodeFixtureParameterOption
- func WithDHTOptions(opts ...dht.Option) NodeFixtureParameterOption
- func WithDefaultResourceManager() NodeFixtureParameterOption
- func WithDefaultStreamHandler(handler network.StreamHandler) NodeFixtureParameterOption
- func WithGossipSubRpcInspectorSuite(inspectorSuite p2p.GossipSubInspectorSuite) NodeFixtureParameterOption
- func WithGossipSubTracer(tracer p2p.PubSubTracer) NodeFixtureParameterOption
- func WithLogger(logger zerolog.Logger) NodeFixtureParameterOption
- func WithMetricsCollector(metrics module.NetworkMetrics) NodeFixtureParameterOption
- func WithNetworkingAddress(address string) NodeFixtureParameterOption
- func WithNetworkingPrivateKey(key crypto.PrivateKey) NodeFixtureParameterOption
- func WithPeerManagerEnabled(connectionPruning bool, updateInterval time.Duration, ...) NodeFixtureParameterOption
- func WithPeerScoreParamsOption(cfg *p2p.PeerScoringConfig) NodeFixtureParameterOption
- func WithPeerScoreTracerInterval(interval time.Duration) NodeFixtureParameterOption
- func WithPeerScoringEnabled(idProvider module.IdentityProvider) NodeFixtureParameterOption
- func WithPreferredUnicasts(unicasts []protocols.ProtocolName) NodeFixtureParameterOption
- func WithRole(role flow.Role) NodeFixtureParameterOption
- type NodeFixtureParameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureConnected ¶ added in v0.30.0
EnsureConnected ensures that the given nodes are connected to each other. It fails the test if any of the nodes is not connected to any other node.
func EnsureNoPubsubExchangeBetweenGroups ¶ added in v0.31.0
func EnsureNoPubsubExchangeBetweenGroups(t *testing.T, ctx context.Context, groupA []p2p.LibP2PNode, groupB []p2p.LibP2PNode, messageFactory func() (interface{}, channels.Topic))
EnsureNoPubsubExchangeBetweenGroups ensures that no pubsub message is exchanged between the given groups of nodes.
func EnsureNoPubsubMessageExchange ¶ added in v0.31.0
func EnsureNoPubsubMessageExchange(t *testing.T, ctx context.Context, from []p2p.LibP2PNode, to []p2p.LibP2PNode, messageFactory func() (interface{}, channels.Topic))
EnsureNoPubsubMessageExchange ensures that the no pubsub message is exchanged "from" the given nodes "to" the given nodes.
func EnsureNotConnectedBetweenGroups ¶ added in v0.31.0
func EnsureNotConnectedBetweenGroups(t *testing.T, ctx context.Context, groupA []p2p.LibP2PNode, groupB []p2p.LibP2PNode)
EnsureNotConnectedBetweenGroups ensures no connection exists between the given groups of nodes.
func EnsurePubsubMessageExchange ¶ added in v0.30.0
func EnsurePubsubMessageExchange(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode, messageFactory func() (interface{}, channels.Topic))
EnsurePubsubMessageExchange ensures that the given connected nodes exchange the given message on the given channel through pubsub. Note: EnsureConnected() must be called to connect all nodes before calling this function.
func EnsureStreamCreationInBothDirections ¶ added in v0.30.0
func EnsureStreamCreationInBothDirections(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode)
EnsureStreamCreationInBothDirections ensure that between each pair of nodes in the given list, a stream is created in both directions.
func LetNodesDiscoverEachOther ¶
func LetNodesDiscoverEachOther(t *testing.T, ctx context.Context, nodes []p2p.LibP2PNode, ids flow.IdentityList)
LetNodesDiscoverEachOther connects all nodes to each other on the pubsub mesh.
func NetworkingKeyFixtures ¶
func NetworkingKeyFixtures(t *testing.T) crypto.PrivateKey
NetworkingKeyFixtures is a test helper that generates a ECDSA flow key pair.
func NodeFixture ¶
func NodeFixture( t *testing.T, sporkID flow.Identifier, dhtPrefix string, idProvider module.IdentityProvider, opts ...NodeFixtureParameterOption, ) (p2p.LibP2PNode, flow.Identity)
NodeFixture is a test fixture that creates a single libp2p node with the given key, spork id, and options. It returns the node and its identity.
func NodesFixture ¶
func NodesFixture(t *testing.T, sporkID flow.Identifier, dhtPrefix string, count int, idProvider module.IdentityProvider, opts ...NodeFixtureParameterOption) ([]p2p.LibP2PNode, flow.IdentityList)
NodesFixture is a test fixture that creates a number of libp2p nodes with the given callback function for stream handling. It returns the nodes and their identities.
func PeerIdFixture ¶ added in v0.30.0
PeerIdFixture returns a random peer ID for testing. peer ID is the identifier of a node on the libp2p network.
func PeerIdSliceFixture ¶ added in v0.31.0
PeerIdSliceFixture returns a slice of random peer IDs for testing. peer ID is the identifier of a node on the libp2p network. Args: - t: *testing.T instance - n: number of peer IDs to generate Returns: - peer.IDSlice: slice of peer IDs
func StartNode ¶
func StartNode(t *testing.T, ctx irrecoverable.SignalerContext, node p2p.LibP2PNode, timeout time.Duration)
StartNode start a single node using the provided context, timing out if nodes are not all Ready() before duration expires
func StartNodes ¶
func StartNodes(t *testing.T, ctx irrecoverable.SignalerContext, nodes []p2p.LibP2PNode, timeout time.Duration)
StartNodes start all nodes in the input slice using the provided context, timing out if nodes are not all Ready() before duration expires
func StopNode ¶
func StopNode(t *testing.T, node p2p.LibP2PNode, cancel context.CancelFunc, timeout time.Duration)
StopNode stops a single node using the provided cancel func, timing out if nodes are not all Done() before duration expires
func StopNodes ¶
func StopNodes(t *testing.T, nodes []p2p.LibP2PNode, cancel context.CancelFunc, timeout time.Duration)
StopNodes stops all nodes in the input slice using the provided cancel func, timing out if nodes are not all Done() before duration expires
Types ¶
type NodeFixtureParameterOption ¶
type NodeFixtureParameterOption func(*NodeFixtureParameters)
func WithConnectionGater ¶
func WithConnectionGater(connGater connmgr.ConnectionGater) NodeFixtureParameterOption
func WithConnectionManager ¶ added in v0.30.0
func WithConnectionManager(connManager connmgr.ConnManager) NodeFixtureParameterOption
func WithCreateStreamRetryDelay ¶ added in v0.30.0
func WithCreateStreamRetryDelay(delay time.Duration) NodeFixtureParameterOption
func WithDHTOptions ¶
func WithDHTOptions(opts ...dht.Option) NodeFixtureParameterOption
func WithDefaultResourceManager ¶ added in v0.30.0
func WithDefaultResourceManager() NodeFixtureParameterOption
WithDefaultResourceManager sets the resource manager to nil, which will cause the node to use the default resource manager. Otherwise, it uses the resource manager provided by the test (the infinite resource manager).
func WithDefaultStreamHandler ¶
func WithDefaultStreamHandler(handler network.StreamHandler) NodeFixtureParameterOption
func WithGossipSubRpcInspectorSuite ¶ added in v0.31.0
func WithGossipSubRpcInspectorSuite(inspectorSuite p2p.GossipSubInspectorSuite) NodeFixtureParameterOption
func WithGossipSubTracer ¶ added in v0.30.0
func WithGossipSubTracer(tracer p2p.PubSubTracer) NodeFixtureParameterOption
func WithLogger ¶
func WithLogger(logger zerolog.Logger) NodeFixtureParameterOption
func WithMetricsCollector ¶ added in v0.30.0
func WithMetricsCollector(metrics module.NetworkMetrics) NodeFixtureParameterOption
func WithNetworkingAddress ¶
func WithNetworkingAddress(address string) NodeFixtureParameterOption
func WithNetworkingPrivateKey ¶
func WithNetworkingPrivateKey(key crypto.PrivateKey) NodeFixtureParameterOption
func WithPeerManagerEnabled ¶
func WithPeerManagerEnabled(connectionPruning bool, updateInterval time.Duration, peerProvider p2p.PeersProvider) NodeFixtureParameterOption
func WithPeerScoreParamsOption ¶ added in v0.30.0
func WithPeerScoreParamsOption(cfg *p2p.PeerScoringConfig) NodeFixtureParameterOption
func WithPeerScoreTracerInterval ¶ added in v0.30.0
func WithPeerScoreTracerInterval(interval time.Duration) NodeFixtureParameterOption
func WithPeerScoringEnabled ¶
func WithPeerScoringEnabled(idProvider module.IdentityProvider) NodeFixtureParameterOption
func WithPreferredUnicasts ¶
func WithPreferredUnicasts(unicasts []protocols.ProtocolName) NodeFixtureParameterOption
func WithRole ¶
func WithRole(role flow.Role) NodeFixtureParameterOption
type NodeFixtureParameters ¶
type NodeFixtureParameters struct { HandlerFunc network.StreamHandler Unicasts []protocols.ProtocolName Key crypto.PrivateKey Address string DhtOptions []dht.Option Role flow.Role Logger zerolog.Logger PeerScoringEnabled bool IdProvider module.IdentityProvider PeerScoreConfig *p2p.PeerScoringConfig ConnectionPruning bool // peer manager parameter UpdateInterval time.Duration // peer manager parameter PeerProvider p2p.PeersProvider // peer manager parameter ConnGater connmgr.ConnectionGater ConnManager connmgr.ConnManager GossipSubFactory p2p.GossipSubFactoryFunc GossipSubConfig p2p.GossipSubAdapterConfigFunc Metrics module.LibP2PMetrics ResourceManager network.ResourceManager PubSubTracer p2p.PubSubTracer GossipSubPeerScoreTracerInterval time.Duration // intervals at which the peer score is updated and logged. CreateStreamRetryDelay time.Duration GossipSubRPCInspector p2p.GossipSubInspectorSuite }