p2ptest

package
v1.22.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(
	t *testing.T,
	ctx context.Context,
	clientNodeID ids.NodeID,
	clientHandler p2p.Handler,
	serverNodeID ids.NodeID,
	serverHandler p2p.Handler,
) *p2p.Client

NewClient generates a client-server pair and returns the client used to communicate with a server with the specified handler

func NewClientWithPeers

func NewClientWithPeers(
	t *testing.T,
	ctx context.Context,
	clientNodeID ids.NodeID,
	clientHandler p2p.Handler,
	peers map[ids.NodeID]p2p.Handler,
) *p2p.Client

NewClientWithPeers generates a client to communicate to a set of peers

func NewSelfClient

func NewSelfClient(t *testing.T, ctx context.Context, nodeID ids.NodeID, handler p2p.Handler) *p2p.Client

Types

type WarpSender added in v1.16.56

type WarpSender struct {
	T *testing.T

	// Function hooks - set these to customize behavior
	SendAppRequestF            func(context.Context, set.Set[ids.NodeID], uint32, []byte) error
	SendAppResponseF           func(context.Context, ids.NodeID, uint32, []byte) error
	SendAppErrorF              func(context.Context, ids.NodeID, uint32, int32, string) error
	SendAppGossipF             func(context.Context, set.Set[ids.NodeID], []byte) error
	SendCrossChainAppRequestF  func(context.Context, ids.ID, uint32, []byte) error
	SendCrossChainAppResponseF func(context.Context, ids.ID, uint32, []byte) error
	SendCrossChainAppErrorF    func(context.Context, ids.ID, uint32, int32, string) error

	// Fail flags - set to true to fail on unexpected calls
	CantSendAppRequest            bool
	CantSendAppResponse           bool
	CantSendAppError              bool
	CantSendAppGossip             bool
	CantSendCrossChainAppRequest  bool
	CantSendCrossChainAppResponse bool
	CantSendCrossChainAppError    bool
}

WarpSender is a test implementation of p2p.WarpSender. Set function fields to customize behavior, or leave nil for default no-op. Set Cant* fields to true to fail on unexpected calls.

func (*WarpSender) SendAppError added in v1.22.2

func (s *WarpSender) SendAppError(ctx context.Context, nodeID ids.NodeID, requestID uint32, code int32, message string) error

func (*WarpSender) SendAppGossip added in v1.22.2

func (s *WarpSender) SendAppGossip(ctx context.Context, nodeIDs set.Set[ids.NodeID], msg []byte) error

func (*WarpSender) SendAppGossipSpecific added in v1.22.2

func (s *WarpSender) SendAppGossipSpecific(ctx context.Context, nodeIDs set.Set[ids.NodeID], msg []byte) error

func (*WarpSender) SendAppRequest added in v1.22.2

func (s *WarpSender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, msg []byte) error

func (*WarpSender) SendAppResponse added in v1.22.2

func (s *WarpSender) SendAppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error

func (*WarpSender) SendCrossChainAppError added in v1.22.2

func (s *WarpSender) SendCrossChainAppError(ctx context.Context, chainID ids.ID, requestID uint32, code int32, message string) error

func (*WarpSender) SendCrossChainAppRequest added in v1.22.2

func (s *WarpSender) SendCrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, msg []byte) error

func (*WarpSender) SendCrossChainAppResponse added in v1.22.2

func (s *WarpSender) SendCrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, msg []byte) error

Jump to

Keyboard shortcuts

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