Version: v0.0.1 Latest Latest

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0, MIT Imports: 17 Imported by: 0




This section is empty.


This section is empty.


func Close

func Close(instances []Instance) error

Close closes multiple instances at once

func ConnectInstances

func ConnectInstances(instances []Instance)

ConnectInstances connects the given instances to each other


type Instance

type Instance struct {
	Peer       peer.ID
	LinkSystem ld.LinkSystem
	Exchange   graphsync.GraphExchange
	BlockStore blockstore.Blockstore
	Adapter    gsnet.GraphSyncNetwork
	// contains filtered or unexported fields

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

func NewInstance

func NewInstance(ctx context.Context, net tn.Network, p tnet.Identity, gsOptions []gsimpl.Option, tempDir string, diskBasedDatastore bool) (Instance, error)

NewInstance creates a test bitswap 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 (*Instance) Blockstore

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

Blockstore returns the block store for this test instance

func (*Instance) Close

func (i *Instance) Close() error

Close closes the associated datastore

func (*Instance) SetBlockstoreLatency

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

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

type InstanceGenerator

type InstanceGenerator struct {
	// contains filtered or unexported fields

InstanceGenerator generates new test instances of bitswap+dependencies

func NewTestInstanceGenerator

func NewTestInstanceGenerator(ctx context.Context, net tn.Network, gsOptions []gsimpl.Option, tempDirGenerator TempDirGenerator, diskBasedDatastore bool) InstanceGenerator

NewTestInstanceGenerator generates a new InstanceGenerator for the given testnet

func (*InstanceGenerator) Close

func (g *InstanceGenerator) Close() error

Close closes the clobal context, shutting down all test instances

func (*InstanceGenerator) Instances

func (g *InstanceGenerator) Instances(n int) ([]Instance, error)

Instances creates N test instances of bitswap + dependencies and connects them to each other

func (*InstanceGenerator) Next

func (g *InstanceGenerator) Next() (Instance, error)

Next generates a new instance of graphsync + dependencies

type TempDirGenerator

type TempDirGenerator interface {
	TempDir() string

TempDirGenerator is any interface that can generate temporary directories

Source Files

Jump to

Keyboard shortcuts

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