testpeer

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectPeers

func ConnectPeers(instances []TestPeer)

ConnectPeers connects the given peers to each other

func StartAndWaitForReady added in v0.5.0

func StartAndWaitForReady(ctx context.Context, manager datatransfer.Manager) error

Types

type TestPeer

type TestPeer struct {
	ID                 peer.ID
	BitswapServer      *server.Server
	BitswapNetwork     bsnet.BitSwapNetwork
	DatatransferServer datatransfer.Manager

	Host host.Host

	LinkSystem linking.LinkSystem
	Cids       map[cid.Cid]struct{}
	// contains filtered or unexported fields
}

TestPeer is a test instance of bitswap + dependencies for integration testing

func NewTestBitswapPeer added in v0.5.0

func NewTestBitswapPeer(ctx context.Context, mn mocknet.Mocknet, p tnet.Identity, netOptions []bsnet.NetOpt, bsOptions []server.Option) (TestPeer, error)

NewTestPeer creates a test peer instance.

NB: It's easy make mistakes by providing the same peer ID to two different instances. To safeguard, use the InstanceGenerator to generate instances. It's just a much better idea.

func NewTestGraphsyncPeer added in v0.5.0

func NewTestGraphsyncPeer(ctx context.Context, mn mocknet.Mocknet, p tnet.Identity) (TestPeer, error)

func (TestPeer) AddrInfo added in v0.5.0

func (i TestPeer) AddrInfo() *peer.AddrInfo

func (*TestPeer) Blockstore

func (i *TestPeer) Blockstore() blockstore.Blockstore

Blockstore returns the block store for this test instance

func (*TestPeer) SetBlockstoreLatency

func (i *TestPeer) SetBlockstoreLatency(t time.Duration) time.Duration

SetBlockstoreLatency customizes the artificial delay on receiving blocks from a blockstore test instance.

type TestPeerGenerator

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

TestPeerGenerator generates new test peers bitswap+dependencies TODO: add graphsync/markets stack, make protocols choosable

func NewTestPeerGenerator

func NewTestPeerGenerator(ctx context.Context, t *testing.T, mn mocknet.Mocknet, netOptions []bsnet.NetOpt, bsOptions []server.Option) TestPeerGenerator

NewTestPeerGenerator generates a new TestPeerGenerator for the given mocknet

func (*TestPeerGenerator) BitswapPeers added in v0.5.0

func (g *TestPeerGenerator) BitswapPeers(n int) []TestPeer

Peers creates N test peers with bitswap + dependencies

func (*TestPeerGenerator) Close

func (g *TestPeerGenerator) Close() error

Close closes the clobal context, shutting down all test peers

func (*TestPeerGenerator) GraphsyncPeers added in v0.5.0

func (g *TestPeerGenerator) GraphsyncPeers(n int) []TestPeer

Peers creates N test peers with bitswap + dependencies

func (*TestPeerGenerator) NextBitswap added in v0.5.0

func (g *TestPeerGenerator) NextBitswap() TestPeer

Next generates a new test peer with bitswap + dependencies

func (*TestPeerGenerator) NextGraphsync added in v0.5.0

func (g *TestPeerGenerator) NextGraphsync() TestPeer

Next generates a new test peer with graphsync + dependencies

Jump to

Keyboard shortcuts

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