Help us shape the future of Go! Take the 2026 Go Developer Survey

p2ptest

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 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

func NewSenderTestAdapter added in v1.16.16

func NewSenderTestAdapter(sender *SenderTest) p2p.ExtendedAppSender

Types

type SenderTest added in v1.16.16

type SenderTest struct {
	T                             *testing.T
	SendAppRequestF               func(context.Context, 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, []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
	CantSendAppRequest            bool
	CantSendAppResponse           bool
	CantSendAppError              bool
	CantSendAppGossip             bool
	CantSendCrossChainAppRequest  bool
	CantSendCrossChainAppResponse bool
	CantSendCrossChainAppError    bool
}

SenderTest is a test implementation of AppSender

type SenderTestAdapter added in v1.16.16

type SenderTestAdapter struct {
	*SenderTest
}

SenderTestAdapter adapts SenderTest to p2p.ExtendedAppSender

func (*SenderTestAdapter) SendAppError added in v1.16.16

func (s *SenderTestAdapter) SendAppError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error

func (*SenderTestAdapter) SendAppGossip added in v1.16.16

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

func (*SenderTestAdapter) SendAppGossipSpecific added in v1.16.16

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

func (*SenderTestAdapter) SendAppRequest added in v1.16.16

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

func (*SenderTestAdapter) SendAppResponse added in v1.16.16

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

func (*SenderTestAdapter) SendCrossChainAppError added in v1.16.16

func (s *SenderTestAdapter) SendCrossChainAppError(ctx context.Context, chainID ids.ID, requestID uint32, errorCode int32, errorMessage string) error

func (*SenderTestAdapter) SendCrossChainAppRequest added in v1.16.16

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

func (*SenderTestAdapter) SendCrossChainAppResponse added in v1.16.16

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

Jump to

Keyboard shortcuts

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