Documentation ¶
Index ¶
- func FillBS(t *testing.T, bServ blockservice.BlockService, shares []share.Share) *share.Root
- func MockNode(t *testing.T, net *TestDagNet) (*TestNode, *FraudulentBlockstore)
- func RandFillBS(t *testing.T, n int, bServ blockservice.BlockService) *share.Root
- type CorruptBlock
- type FraudulentBlockstore
- func (fb FraudulentBlockstore) AllKeysChan(context.Context) (<-chan cid.Cid, error)
- func (fb FraudulentBlockstore) DeleteBlock(context.Context, cid.Cid) error
- func (fb FraudulentBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
- func (fb FraudulentBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)
- func (fb FraudulentBlockstore) Has(context.Context, cid.Cid) (bool, error)
- func (fb FraudulentBlockstore) HashOnRead(bool)
- func (fb FraudulentBlockstore) Put(ctx context.Context, block blocks.Block) error
- func (fb FraudulentBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error
- type SubNet
- type TestDagNet
- func (dn *TestDagNet) Connect(peerA, peerB peer.ID)
- func (dn *TestDagNet) ConnectAll()
- func (dn *TestDagNet) Disconnect(peerA, peerB peer.ID)
- func (dn *TestDagNet) NewTestNode() *TestNode
- func (dn *TestDagNet) NewTestNodeWithBlockstore(dstore ds.Datastore, bstore blockstore.Blockstore) *TestNode
- func (dn *TestDagNet) SubNet() *SubNet
- type TestNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MockNode ¶
func MockNode(t *testing.T, net *TestDagNet) (*TestNode, *FraudulentBlockstore)
MockNode creates a TestNode that uses a FraudulentBlockstore to simulate serving corrupted data.
Types ¶
type CorruptBlock ¶
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 ¶
func NewCorruptBlock(data []byte, fakeCID cid.Cid) *CorruptBlock
func (*CorruptBlock) Cid ¶
func (b *CorruptBlock) Cid() cid.Cid
func (*CorruptBlock) Loggable ¶
func (b *CorruptBlock) Loggable() map[string]interface{}
func (*CorruptBlock) RawData ¶
func (b *CorruptBlock) RawData() []byte
func (*CorruptBlock) String ¶
func (b *CorruptBlock) String() string
type FraudulentBlockstore ¶
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 ¶
func (fb FraudulentBlockstore) AllKeysChan(context.Context) (<-chan cid.Cid, error)
func (FraudulentBlockstore) DeleteBlock ¶
func (fb FraudulentBlockstore) DeleteBlock(context.Context, cid.Cid) error
func (FraudulentBlockstore) GetSize ¶
func (fb FraudulentBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)
func (FraudulentBlockstore) Has ¶
func (fb FraudulentBlockstore) Has(context.Context, cid.Cid) (bool, error)
func (FraudulentBlockstore) HashOnRead ¶
func (fb FraudulentBlockstore) HashOnRead(bool)
type SubNet ¶
type SubNet struct { *TestDagNet // contains filtered or unexported fields }
func (*SubNet) ConnectAll ¶
func (sn *SubNet) ConnectAll()
type TestDagNet ¶
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 ¶
func (dn *TestDagNet) Connect(peerA, peerB peer.ID)
Connect connects two given peers.
func (*TestDagNet) ConnectAll ¶
func (dn *TestDagNet) ConnectAll()
ConnectAll connects all the peers on registered on the TestDagNet.
func (*TestDagNet) Disconnect ¶
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 ¶
func (dn *TestDagNet) NewTestNode() *TestNode
NewTestNode creates a plain network node that can serve and request data.
func (*TestDagNet) NewTestNodeWithBlockstore ¶
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 ¶
func (dn *TestDagNet) SubNet() *SubNet