availability_test

package
v0.4.8-db Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillBS

func FillBS(t *testing.T, bServ blockservice.BlockService, shares []share.Share) *share.Root

FillBS fills the given BlockService with the given shares.

func NewTestBrokenAvailability

func NewTestBrokenAvailability() share.Availability

NewTestBrokenAvailability returns an instance of Availability that allows for testing error cases during sampling.

If the share.Root field is empty, it will return share.ErrNotAvailable on every call to SharesAvailable. Otherwise, it will only return ErrNotAvailable if the given Root hash matches the stored Root hash.

func NewTestSuccessfulAvailability

func NewTestSuccessfulAvailability() share.Availability

NewTestSuccessfulAvailability returns an Availability that always returns successfully when SharesAvailable is called.

func RandFillBS

func RandFillBS(t *testing.T, n int, bServ blockservice.BlockService) *share.Root

RandFillBS fills the given BlockService with a random block of a given size.

Types

type DagNet

type DagNet struct {
	T *testing.T
	// contains filtered or unexported fields
}

func NewTestDAGNet

func NewTestDAGNet(ctx context.Context, t *testing.T) *DagNet

NewTestDAGNet creates a new testing swarm utility to spawn different nodes and test how they interact and/or exchange data.

func (*DagNet) Connect

func (dn *DagNet) Connect(peerA, peerB peer.ID)

Connect connects two given peer.

func (*DagNet) ConnectAll

func (dn *DagNet) ConnectAll()

ConnectAll connects all the peers on registered on the DagNet.

func (*DagNet) Disconnect

func (dn *DagNet) Disconnect(peerA, peerB peer.ID)

Disconnect disconnects two peers. It does a hard disconnect, meaning that disconnected peers won't be able to reconnect on their own but only with DagNet.Connect or DagNet.ConnectAll.

func (*DagNet) Node

func (dn *DagNet) Node() *Node

Node create a plain network node that can serve and request data.

func (*DagNet) SubNet

func (dn *DagNet) SubNet() *SubNet

type Node

type Node struct {
	*service.ShareService
	blockservice.BlockService
	host.Host
	// contains filtered or unexported fields
}

func (*Node) ClearStorage

func (n *Node) ClearStorage()

ClearStorage cleans up the storage of the node.

type SubNet

type SubNet struct {
	*DagNet
	// contains filtered or unexported fields
}

func (*SubNet) AddNode

func (sn *SubNet) AddNode(nd *Node)

func (*SubNet) ConnectAll

func (sn *SubNet) ConnectAll()

type TestBrokenAvailability

type TestBrokenAvailability struct {
	Root *share.Root
}

func (*TestBrokenAvailability) ProbabilityOfAvailability

func (b *TestBrokenAvailability) ProbabilityOfAvailability() float64

func (*TestBrokenAvailability) SharesAvailable

func (b *TestBrokenAvailability) SharesAvailable(_ context.Context, root *share.Root) error

type TestSuccessfulAvailability

type TestSuccessfulAvailability struct {
}

func (*TestSuccessfulAvailability) ProbabilityOfAvailability

func (tsa *TestSuccessfulAvailability) ProbabilityOfAvailability() float64

func (*TestSuccessfulAvailability) SharesAvailable

func (tsa *TestSuccessfulAvailability) SharesAvailable(context.Context, *share.Root) error

Jump to

Keyboard shortcuts

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