availability_test

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 22 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 MockNode added in v0.5.0

func MockNode(t *testing.T, net *TestDagNet) (*TestNode, *FraudulentBlockstore)

MockNode creates a TestNode that uses a FraudulentBlockstore to simulate serving corrupted data.

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 CorruptBlock added in v0.5.0

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

CorruptBlock is a block where the cid doesn't match the data. It fulfills the blocks.Block interface.

func NewCorruptBlock added in v0.5.0

func NewCorruptBlock(data []byte, fakeCID cid.Cid) *CorruptBlock

func (*CorruptBlock) Cid added in v0.5.0

func (b *CorruptBlock) Cid() cid.Cid

func (*CorruptBlock) Loggable added in v0.5.0

func (b *CorruptBlock) Loggable() map[string]interface{}

func (*CorruptBlock) RawData added in v0.5.0

func (b *CorruptBlock) RawData() []byte

func (*CorruptBlock) String added in v0.5.0

func (b *CorruptBlock) String() string

type FraudulentBlockstore added in v0.5.0

type FraudulentBlockstore struct {
	ds.Datastore
	Attacking bool
}

FraudulentBlockstore is a mock blockstore.Blockstore that saves both corrupted and original data for every block it receives. If FraudulentBlockstore.Attacking is true, it will serve the corrupted data on requests.

func (FraudulentBlockstore) AllKeysChan added in v0.5.0

func (fb FraudulentBlockstore) AllKeysChan(context.Context) (<-chan cid.Cid, error)

func (FraudulentBlockstore) DeleteBlock added in v0.5.0

func (fb FraudulentBlockstore) DeleteBlock(context.Context, cid.Cid) error

func (FraudulentBlockstore) Get added in v0.5.0

func (fb FraudulentBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)

func (FraudulentBlockstore) GetSize added in v0.5.0

func (fb FraudulentBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)

func (FraudulentBlockstore) Has added in v0.5.0

func (fb FraudulentBlockstore) Has(context.Context, cid.Cid) (bool, error)

func (FraudulentBlockstore) HashOnRead added in v0.5.0

func (fb FraudulentBlockstore) HashOnRead(bool)

func (FraudulentBlockstore) Put added in v0.5.0

func (FraudulentBlockstore) PutMany added in v0.5.0

func (fb FraudulentBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error

type SubNet

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

func (*SubNet) AddNode

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

func (*SubNet) ConnectAll

func (sn *SubNet) ConnectAll()

type TestDagNet added in v0.5.0

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

func NewTestDAGNet

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

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

func (*TestDagNet) Connect added in v0.5.0

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

Connect connects two given peers.

func (*TestDagNet) ConnectAll added in v0.5.0

func (dn *TestDagNet) ConnectAll()

ConnectAll connects all the peers on registered on the TestDagNet.

func (*TestDagNet) Disconnect added in v0.5.0

func (dn *TestDagNet) 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 TestDagNet.ConnectAll.

func (*TestDagNet) NewTestNode added in v0.5.0

func (dn *TestDagNet) NewTestNode() *TestNode

NewTestNode creates a plain network node that can serve and request data.

func (*TestDagNet) NewTestNodeWithBlockstore added in v0.5.0

func (dn *TestDagNet) NewTestNodeWithBlockstore(dstore ds.Datastore, bstore blockstore.Blockstore) *TestNode

NewTestNodeWithBlockstore creates a new plain TestNode with the given blockstore that can serve and request data.

func (*TestDagNet) SubNet added in v0.5.0

func (dn *TestDagNet) SubNet() *SubNet

type TestNode added in v0.5.0

type TestNode struct {
	share.Getter
	share.Availability
	blockservice.BlockService
	host.Host
	// contains filtered or unexported fields
}

func (*TestNode) ClearStorage added in v0.5.0

func (n *TestNode) ClearStorage()

ClearStorage cleans up the storage of the node.

Jump to

Keyboard shortcuts

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