streamtest

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordsNotFound        = errors.New("records not found")
	ErrStreamNotSupported     = errors.New("stream not supported")
	ErrStreamClosed           = errors.New("stream closed")
	ErrStreamFullcloseTimeout = errors.New("fullclose timeout")
)

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithBaseAddr

func WithBaseAddr(a boson.Address) Option

func WithLightNode

func WithLightNode() Option

func WithMiddlewares

func WithMiddlewares(middlewares ...p2p.HandlerMiddleware) Option

func WithPeerProtocols

func WithPeerProtocols(protocolsWithPeers map[string]p2p.ProtocolSpec) Option

func WithPingErr

func WithPingErr(pingErr func(ma.Multiaddr) (time.Duration, error)) Option

func WithProtocols

func WithProtocols(protocols ...p2p.ProtocolSpec) Option

func WithStreamError

func WithStreamError(streamErr func(boson.Address, string, string, string) error) Option

type Record

type Record struct {
	// contains filtered or unexported fields
}

func (*Record) Err

func (r *Record) Err() error

func (*Record) In

func (r *Record) In() []byte

func (*Record) Out

func (r *Record) Out() []byte

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Recorder

func (*Recorder) NewConnChainRelayStream

func (r *Recorder) NewConnChainRelayStream(ctx context.Context, target boson.Address, h p2p.Headers, protocolName, protocolVersion, streamName string) (p2p.Stream, error)

func (*Recorder) NewRelayStream

func (r *Recorder) NewRelayStream(ctx context.Context, address boson.Address, h p2p.Headers, protocol, version, stream string, midCall bool) (p2p.Stream, error)

func (*Recorder) NewStream

func (r *Recorder) NewStream(ctx context.Context, addr boson.Address, h p2p.Headers, protocolName, protocolVersion, streamName string) (p2p.Stream, error)

func (*Recorder) Ping

func (r *Recorder) Ping(ctx context.Context, addr ma.Multiaddr) (rtt time.Duration, err error)

func (*Recorder) Records

func (r *Recorder) Records(addr boson.Address, protocolName, protocolVersio, streamName string) ([]*Record, error)

func (*Recorder) SetProtocols

func (r *Recorder) SetProtocols(protocols ...p2p.ProtocolSpec)

func (*Recorder) WaitRecords

func (r *Recorder) WaitRecords(t *testing.T, addr boson.Address, proto, version, stream string, msgs, timeoutSec int) []*Record

WaitRecords waits for some time for records to come into the recorder. If msgs is 0, the timeoutSec period is waited to verify that _no_ messages arrive during this time period.

type RecorderDisconnecter

type RecorderDisconnecter struct {
	*Recorder
	// contains filtered or unexported fields
}

func NewRecorderDisconnecter

func NewRecorderDisconnecter(r *Recorder) *RecorderDisconnecter

func (*RecorderDisconnecter) Blocklist

func (r *RecorderDisconnecter) Blocklist(overlay boson.Address, d time.Duration, _ string) error

func (*RecorderDisconnecter) Disconnect

func (r *RecorderDisconnecter) Disconnect(overlay boson.Address, _ string) error

func (*RecorderDisconnecter) IsBlocklisted

func (r *RecorderDisconnecter) IsBlocklisted(overlay boson.Address) (bool, time.Duration)

func (*RecorderDisconnecter) IsDisconnected

func (r *RecorderDisconnecter) IsDisconnected(overlay boson.Address) bool

func (*RecorderDisconnecter) NetworkStatus

func (r *RecorderDisconnecter) NetworkStatus() p2p.NetworkStatus

NetworkStatus implements p2p.NetworkStatuser interface. It always returns p2p.NetworkStatusAvailable.

Jump to

Keyboard shortcuts

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