Documentation
¶
Index ¶
- func CreateNode(t *testing.T, nodeID flow.Identifier, networkKey crypto.PrivateKey, ...) *p2pnode.Node
- func LetNodesDiscoverEachOther(t *testing.T, ctx context.Context, nodes []*p2pnode.Node, ...)
- func MustEncodeEvent(t *testing.T, v interface{}) []byte
- func NetworkingKeyFixtures(t *testing.T) crypto.PrivateKey
- func NodeFixture(t *testing.T, sporkID flow.Identifier, dhtPrefix string, ...) (*p2pnode.Node, flow.Identity)
- func NodesFixture(t *testing.T, sporkID flow.Identifier, dhtPrefix string, count int, ...) ([]*p2pnode.Node, flow.IdentityList)
- func PeerIdFixture(t *testing.T) peer.ID
- func PeerIdsFixture(t *testing.T, n int) []peer.ID
- func SilentNodeFixture(t *testing.T) (net.Listener, flow.Identity)
- func StartNode(t *testing.T, ctx irrecoverable.SignalerContext, node *p2pnode.Node, ...)
- func StartNodes(t *testing.T, ctx irrecoverable.SignalerContext, nodes []*p2pnode.Node, ...)
- func StopNode(t *testing.T, node *p2pnode.Node, cancel context.CancelFunc, ...)
- func StopNodes(t *testing.T, nodes []*p2pnode.Node, cancel context.CancelFunc, ...)
- func SubMustNeverReceiveAnyMessage(t *testing.T, ctx context.Context, sub *pubsub.Subscription)
- func SubMustReceiveMessage(t *testing.T, ctx context.Context, expectedMessage []byte, ...)
- func SubsMustNeverReceiveAnyMessage(t *testing.T, ctx context.Context, subs []*pubsub.Subscription)
- func SubsMustReceiveMessage(t *testing.T, ctx context.Context, expectedMessage []byte, ...)
- func WithSubscriptionFilter(filter pubsub.SubscriptionFilter) nodeOpt
- type NodeFixtureParameterOption
- func WithDHTOptions(opts ...dht.Option) NodeFixtureParameterOption
- func WithDefaultStreamHandler(handler network.StreamHandler) NodeFixtureParameterOption
- func WithLogger(logger zerolog.Logger) NodeFixtureParameterOption
- func WithNetworkingAddress(address string) NodeFixtureParameterOption
- func WithNetworkingPrivateKey(key crypto.PrivateKey) NodeFixtureParameterOption
- func WithPeerFilter(filter p2p.PeerFilter) NodeFixtureParameterOption
- func WithPeerScoringEnabled(idProvider module.IdentityProvider) NodeFixtureParameterOption
- func WithPreferredUnicasts(unicasts []unicast.ProtocolName) NodeFixtureParameterOption
- func WithRole(role flow.Role) NodeFixtureParameterOption
- type NodeFixtureParameters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNode ¶
func CreateNode(t *testing.T, nodeID flow.Identifier, networkKey crypto.PrivateKey, sporkID flow.Identifier, logger zerolog.Logger, opts ...nodeOpt) *p2pnode.Node
func LetNodesDiscoverEachOther ¶
func LetNodesDiscoverEachOther(t *testing.T, ctx context.Context, nodes []*p2pnode.Node, ids flow.IdentityList)
LetNodesDiscoverEachOther connects all nodes to each other on the pubsub mesh.
func MustEncodeEvent ¶
MustEncodeEvent encodes and returns the given event and fails the test if it faces any issue while encoding.
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, opts ...NodeFixtureParameterOption, ) (*p2pnode.Node, 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, opts ...NodeFixtureParameterOption) ([]*p2pnode.Node, 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 ¶
PeerIdFixture creates a random and unique peer ID (libp2p node ID).
func PeerIdsFixture ¶
PeerIdsFixture creates random and unique peer IDs (libp2p node IDs).
func SilentNodeFixture ¶
SilentNodeFixture returns a TCP listener and a node which never replies
func StartNode ¶
func StartNode(t *testing.T, ctx irrecoverable.SignalerContext, node *p2pnode.Node, 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 []*p2pnode.Node, 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 ¶
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 []*p2pnode.Node, 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
func SubMustNeverReceiveAnyMessage ¶
SubMustNeverReceiveAnyMessage checks that the subscription never receives any message within the given timeout by the context.
func SubMustReceiveMessage ¶
func SubMustReceiveMessage(t *testing.T, ctx context.Context, expectedMessage []byte, sub *pubsub.Subscription)
SubMustReceiveMessage checks that the subscription have received the given message within the given timeout by the context.
func SubsMustNeverReceiveAnyMessage ¶
SubsMustNeverReceiveAnyMessage checks that all subscriptions never receive any message within the given timeout by the context.
func SubsMustReceiveMessage ¶
func SubsMustReceiveMessage(t *testing.T, ctx context.Context, expectedMessage []byte, subs []*pubsub.Subscription)
SubsMustReceiveMessage checks that all subscriptions receive the given message within the given timeout by the context.
func WithSubscriptionFilter ¶
func WithSubscriptionFilter(filter pubsub.SubscriptionFilter) nodeOpt
Types ¶
type NodeFixtureParameterOption ¶
type NodeFixtureParameterOption func(*NodeFixtureParameters)
func WithDHTOptions ¶
func WithDHTOptions(opts ...dht.Option) NodeFixtureParameterOption
func WithDefaultStreamHandler ¶
func WithDefaultStreamHandler(handler network.StreamHandler) NodeFixtureParameterOption
func WithLogger ¶
func WithLogger(logger zerolog.Logger) NodeFixtureParameterOption
func WithNetworkingAddress ¶
func WithNetworkingAddress(address string) NodeFixtureParameterOption
func WithNetworkingPrivateKey ¶
func WithNetworkingPrivateKey(key crypto.PrivateKey) NodeFixtureParameterOption
func WithPeerFilter ¶
func WithPeerFilter(filter p2p.PeerFilter) NodeFixtureParameterOption
func WithPeerScoringEnabled ¶
func WithPeerScoringEnabled(idProvider module.IdentityProvider) NodeFixtureParameterOption
func WithPreferredUnicasts ¶
func WithPreferredUnicasts(unicasts []unicast.ProtocolName) NodeFixtureParameterOption
func WithRole ¶
func WithRole(role flow.Role) NodeFixtureParameterOption
type NodeFixtureParameters ¶
type NodeFixtureParameters struct { HandlerFunc network.StreamHandler Unicasts []unicast.ProtocolName Key crypto.PrivateKey Address string DhtOptions []dht.Option PeerFilter p2p.PeerFilter Role flow.Role Logger zerolog.Logger PeerScoringEnabled bool IdProvider module.IdentityProvider }