Documentation
¶
Index ¶
- func ContainsBlock(blks []blocks.Block, block blocks.Block) bool
- func ContainsPeer(peers []peer.ID, p peer.ID) bool
- func GenerateBlocksOfSize(n int, size int64) []blocks.Block
- func GenerateCids(n int) []cid.Cid
- func GeneratePeers(n int) []peer.ID
- func IndexOf(blks []blocks.Block, c cid.Cid) int
- func RandomBytes(n int64) []byte
- type FakeGraphSync
- func (fgs *FakeGraphSync) AssertNoRequestReceived(t *testing.T)
- func (fgs *FakeGraphSync) AssertRequestReceived(ctx context.Context, t *testing.T) ReceivedGraphSyncRequest
- func (fgs *FakeGraphSync) RegisterCompletedResponseListener(listener graphsync.OnResponseCompletedListener) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) RegisterIncomingRequestHook(hook graphsync.OnIncomingRequestHook) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) RegisterIncomingResponseHook(_ graphsync.OnIncomingResponseHook) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) RegisterOutgoingBlockHook(hook graphsync.OnOutgoingBlockHook) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) RegisterOutgoingRequestHook(hook graphsync.OnOutgoingRequestHook) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) RegisterPersistenceOption(name string, loader ipld.Loader, storer ipld.Storer) error
- func (fgs *FakeGraphSync) RegisterRequestUpdatedHook(hook graphsync.OnRequestUpdatedHook) graphsync.UnregisterHookFunc
- func (fgs *FakeGraphSync) Request(ctx context.Context, p peer.ID, root ipld.Link, selector ipld.Node, ...) (<-chan graphsync.ResponseProgress, <-chan error)
- func (fgs *FakeGraphSync) UnpauseResponse(_ peer.ID, _ graphsync.RequestID) error
- type GraphsyncTestingData
- func (gsData *GraphsyncTestingData) LoadUnixFSFile(t *testing.T, useSecondNode bool) ipld.Link
- func (gsData *GraphsyncTestingData) SetupGraphsyncHost1() graphsync.GraphExchange
- func (gsData *GraphsyncTestingData) SetupGraphsyncHost2() graphsync.GraphExchange
- func (gsData *GraphsyncTestingData) VerifyFileTransferred(t *testing.T, link ipld.Link, useSecondNode bool)
- type ReceivedGraphSyncRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsBlock ¶
ContainsBlock returns true if a block is found n a list of blocks
func ContainsPeer ¶
ContainsPeer returns true if a peer is found n a list of peers.
func GenerateBlocksOfSize ¶
GenerateBlocksOfSize generates a series of blocks of the given byte size
func RandomBytes ¶
RandomBytes returns a byte array of the given size with random values.
Types ¶
type FakeGraphSync ¶
type FakeGraphSync struct {
// contains filtered or unexported fields
}
FakeGraphSync implements a GraphExchange but does nothing
func NewFakeGraphSync ¶
func NewFakeGraphSync() *FakeGraphSync
NewFakeGraphSync returns a new fake graphsync implementation
func (*FakeGraphSync) AssertNoRequestReceived ¶
func (fgs *FakeGraphSync) AssertNoRequestReceived(t *testing.T)
AssertNoRequestReceived asserts that no requests should ahve been received by this graphsync implementation
func (*FakeGraphSync) AssertRequestReceived ¶
func (fgs *FakeGraphSync) AssertRequestReceived(ctx context.Context, t *testing.T) ReceivedGraphSyncRequest
AssertRequestReceived asserts a request should be received before the context closes (and returns said request)
func (*FakeGraphSync) RegisterCompletedResponseListener ¶
func (fgs *FakeGraphSync) RegisterCompletedResponseListener(listener graphsync.OnResponseCompletedListener) graphsync.UnregisterHookFunc
RegisterCompletedResponseListener adds a listener on the responder for completed responses
func (*FakeGraphSync) RegisterIncomingRequestHook ¶
func (fgs *FakeGraphSync) RegisterIncomingRequestHook(hook graphsync.OnIncomingRequestHook) graphsync.UnregisterHookFunc
RegisterIncomingRequestHook adds a hook that runs when a request is received
func (*FakeGraphSync) RegisterIncomingResponseHook ¶
func (fgs *FakeGraphSync) RegisterIncomingResponseHook(_ graphsync.OnIncomingResponseHook) graphsync.UnregisterHookFunc
RegisterIncomingResponseHook adds a hook that runs when a response is received
func (*FakeGraphSync) RegisterOutgoingBlockHook ¶
func (fgs *FakeGraphSync) RegisterOutgoingBlockHook(hook graphsync.OnOutgoingBlockHook) graphsync.UnregisterHookFunc
RegisterOutgoingBlockHook adds a hook that runs every time a block is sent from a responder
func (*FakeGraphSync) RegisterOutgoingRequestHook ¶
func (fgs *FakeGraphSync) RegisterOutgoingRequestHook(hook graphsync.OnOutgoingRequestHook) graphsync.UnregisterHookFunc
RegisterOutgoingRequestHook adds a hook that runs immediately prior to sending a new request
func (*FakeGraphSync) RegisterPersistenceOption ¶
func (fgs *FakeGraphSync) RegisterPersistenceOption(name string, loader ipld.Loader, storer ipld.Storer) error
RegisterPersistenceOption registers an alternate loader/storer combo that can be substituted for the default
func (*FakeGraphSync) RegisterRequestUpdatedHook ¶
func (fgs *FakeGraphSync) RegisterRequestUpdatedHook(hook graphsync.OnRequestUpdatedHook) graphsync.UnregisterHookFunc
RegisterRequestUpdatedHook adds a hook that runs every time an update to a request is received
func (*FakeGraphSync) Request ¶
func (fgs *FakeGraphSync) Request(ctx context.Context, p peer.ID, root ipld.Link, selector ipld.Node, extensions ...graphsync.ExtensionData) (<-chan graphsync.ResponseProgress, <-chan error)
Request initiates a new GraphSync request to the given peer using the given selector spec.
func (*FakeGraphSync) UnpauseResponse ¶
func (fgs *FakeGraphSync) UnpauseResponse(_ peer.ID, _ graphsync.RequestID) error
UnpauseResponse unpauses a response that was paused in a block hook based on peer ID and request ID
type GraphsyncTestingData ¶
type GraphsyncTestingData struct {
Ctx context.Context
StoredCounter1 *storedcounter.StoredCounter
StoredCounter2 *storedcounter.StoredCounter
Bs1 bstore.Blockstore
Bs2 bstore.Blockstore
DagService1 ipldformat.DAGService
DagService2 ipldformat.DAGService
Loader1 ipld.Loader
Loader2 ipld.Loader
Storer1 ipld.Storer
Storer2 ipld.Storer
Host1 host.Host
Host2 host.Host
GsNet1 gsnet.GraphSyncNetwork
GsNet2 gsnet.GraphSyncNetwork
AllSelector ipld.Node
OrigBytes []byte
}
GraphsyncTestingData is a test harness for testing data transfer on top of graphsync
func NewGraphsyncTestingData ¶
func NewGraphsyncTestingData(ctx context.Context, t *testing.T) *GraphsyncTestingData
NewGraphsyncTestingData returns a new GraphsyncTestingData instance
func (*GraphsyncTestingData) LoadUnixFSFile ¶
func (gsData *GraphsyncTestingData) LoadUnixFSFile(t *testing.T, useSecondNode bool) ipld.Link
LoadUnixFSFile loads a fixtures file we can test dag transfer with
func (*GraphsyncTestingData) SetupGraphsyncHost1 ¶
func (gsData *GraphsyncTestingData) SetupGraphsyncHost1() graphsync.GraphExchange
SetupGraphsyncHost1 sets up a new, real graphsync instance on top of the first host
func (*GraphsyncTestingData) SetupGraphsyncHost2 ¶
func (gsData *GraphsyncTestingData) SetupGraphsyncHost2() graphsync.GraphExchange
SetupGraphsyncHost2 sets up a new, real graphsync instance on top of the second host
func (*GraphsyncTestingData) VerifyFileTransferred ¶
func (gsData *GraphsyncTestingData) VerifyFileTransferred(t *testing.T, link ipld.Link, useSecondNode bool)
VerifyFileTransferred verifies all of the file was transfer to the given node
type ReceivedGraphSyncRequest ¶
type ReceivedGraphSyncRequest struct {
P peer.ID
Root ipld.Link
Selector ipld.Node
Extensions []graphsync.ExtensionData
}
ReceivedGraphSyncRequest contains data about a received graphsync request