Documentation ¶
Index ¶
- Constants
- func GenerateBlocksOfSize(n int, size int64) []blocks.Block
- func GenerateCid() cid.Cid
- func GenerateCids(n int) []cid.Cid
- func GenerateMultiaddr() multiaddr.Multiaddr
- func GenerateNoDupes(gen func() unixfs.DirEntry) unixfs.DirEntry
- func GeneratePeers(t *testing.T, n int) []peer.ID
- func GenerateRetrievalCandidates(t *testing.T, n int, protocols ...metadata.Protocol) []types.RetrievalCandidate
- func GenerateRetrievalCandidatesForCID(t *testing.T, n int, c cid.Cid, protocols ...metadata.Protocol) []types.RetrievalCandidate
- func GenerateRetrievalIDs(t *testing.T, n int) []types.RetrievalID
- func GenerateRetrievalRequests(t *testing.T, n int) []types.RetrievalRequest
- func GenerateStrictlyNestedShardedDir(t *testing.T, linkSys *linking.LinkSystem, randReader io.Reader, ...) unixfs.DirEntry
- func RandomBytes(n int64) []byte
- func ToBlocks(t *testing.T, lsys linking.LinkSystem, root cid.Cid, selNode datamodel.Node) []blocks.Block
- func VerifyCollectedEvent(t *testing.T, actual types.RetrievalEvent, expected types.RetrievalEvent)
- func VerifyContainsCollectedEvent(t *testing.T, afterStart time.Duration, expectedList []types.RetrievalEvent, ...) types.EventCode
- type AsyncCollectingEventsListener
- type ClientRetrievalRequest
- type CollectingEventsListener
- type DelayedClientReturn
- type DelayedConnectReturn
- type DiscoveredCandidate
- type ExpectedActionsAtTime
- type MockCandidateFinder
- func (me *MockCandidateFinder) FindCandidates(ctx context.Context, cid cid.Cid) ([]types.RetrievalCandidate, error)
- func (me *MockCandidateFinder) FindCandidatesAsync(ctx context.Context, c cid.Cid, cb func(types.RetrievalCandidate)) error
- func (me *MockCandidateFinder) VerifyCandidatesDiscovered(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type MockClient
- func (mc *MockClient) Connect(ctx context.Context, minerPeer peer.AddrInfo) error
- func (mc *MockClient) GetConnectReturns() map[string]DelayedConnectReturn
- func (mc *MockClient) GetReceivedLinkSystems() []ipld.LinkSystem
- func (mc *MockClient) GetRetrievalReturns() map[string]DelayedClientReturn
- func (mc *MockClient) RetrieveFromPeer(ctx context.Context, linkSystem ipld.LinkSystem, peerID peer.ID, ...) (*types.RetrievalStats, error)
- func (mc *MockClient) SetConnectReturns(connectReturns map[string]DelayedConnectReturn)
- func (mc *MockClient) SetRetrievalReturns(retrievalReturns map[string]DelayedClientReturn)
- func (mc *MockClient) VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyReceivedRetrievalFrom(ctx context.Context, t *testing.T, p peer.ID) ClientRetrievalRequest
- func (mc *MockClient) VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mc *MockClient) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type MockRoundTripRemote
- type MockRoundTripper
- func (mrt *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
- func (mrt *MockRoundTripper) VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (mrt *MockRoundTripper) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- type MockSession
- func (ms *MockSession) AddToRetrieval(retrievalId types.RetrievalID, storageProviderIds []peer.ID) error
- func (ms *MockSession) ChooseNextProvider(peers []peer.ID, metadata []metadata.Protocol) int
- func (ms *MockSession) EndRetrieval(retrievalId types.RetrievalID) error
- func (ms *MockSession) FilterIndexerCandidate(candidate types.RetrievalCandidate) (bool, types.RetrievalCandidate)
- func (ms *MockSession) GetStorageProviderTimeout(storageProviderId peer.ID) time.Duration
- func (ms *MockSession) RecordConnectTime(storageProviderId peer.ID, connectTime time.Duration)
- func (ms *MockSession) RecordFailure(retrievalId types.RetrievalID, storageProviderId peer.ID) error
- func (ms *MockSession) RecordFirstByteTime(storageProviderId peer.ID, firstByteTime time.Duration)
- func (ms *MockSession) RecordSuccess(storageProviderId peer.ID, bandwidthBytesPerSecond uint64)
- func (ms *MockSession) RegisterRetrieval(retrievalId types.RetrievalID, cid cid.Cid, selector datamodel.Node) bool
- func (ms *MockSession) SetBlockList(blockList map[peer.ID]bool)
- func (ms *MockSession) SetCandidatePreferenceOrder(candidatePreferenceOrder []types.RetrievalCandidate)
- func (ms *MockSession) SetProviderTimeout(providerTimeout time.Duration)
- func (ms *MockSession) VerifyMetricsAt(ctx context.Context, t *testing.T, afterStart time.Duration, ...)
- func (ms *MockSession) WithActual(session *session.Session)
- type ParentStore
- type RemoteStats
- type RetrievalVerifier
- type RunRetrieval
- type SessionMetric
- type SessionMetricType
- type ThreadsafeStore
- type VerifierClient
Constants ¶
const ( SessionMetric_Success = SessionMetricType("success") SessionMetric_Failure = SessionMetricType("failure") SessionMetric_Connect = SessionMetricType("connect") SessionMetric_FirstByte = SessionMetricType("first-byte") )
Variables ¶
This section is empty.
Functions ¶
func GenerateBlocksOfSize ¶
GenerateBlocksOfSize generates a series of blocks of the given byte size
func GenerateMultiaddr ¶ added in v0.10.0
func GenerateMultiaddr() multiaddr.Multiaddr
func GenerateNoDupes ¶ added in v0.11.1
GenerateNoDupes runs the unixfsnode/testutil generator function repeatedly until it produces a DAG with strictly no duplicate CIDs.
func GeneratePeers ¶
GeneratePeers creates n peer ids.
func GenerateRetrievalCandidates ¶
func GenerateRetrievalCandidates(t *testing.T, n int, protocols ...metadata.Protocol) []types.RetrievalCandidate
GenerateRetrievalCandidates produces n retrieval candidates
func GenerateRetrievalCandidatesForCID ¶ added in v0.8.1
func GenerateRetrievalCandidatesForCID(t *testing.T, n int, c cid.Cid, protocols ...metadata.Protocol) []types.RetrievalCandidate
GenerateRetrievalCandidates produces n retrieval candidates
func GenerateRetrievalIDs ¶
func GenerateRetrievalIDs(t *testing.T, n int) []types.RetrievalID
func GenerateRetrievalRequests ¶ added in v0.6.0
func GenerateRetrievalRequests(t *testing.T, n int) []types.RetrievalRequest
GenerateRetrievalRequests produces retrieval requests
func GenerateStrictlyNestedShardedDir ¶ added in v0.14.0
func GenerateStrictlyNestedShardedDir(t *testing.T, linkSys *linking.LinkSystem, randReader io.Reader, targetSize int) unixfs.DirEntry
GenerateStrictlyNestedShardedDir is a wrapper around unixfsnode/testutil.GenerateDirectory that uses dark magic to repeatedly generate a sharded directory until it produces one that is strictly nested. That is, it produces a sharded directory structure with strictly at least one level of sharding with at least two child shards.
Since it is possible to produce a sharded directory that is contained in a single block, this function provides a way to generate a sharded directory for cases where we need to test multi-level sharding.
func RandomBytes ¶
RandomBytes returns a byte array of the given size with random values.
func ToBlocks ¶ added in v0.11.0
func ToBlocks(t *testing.T, lsys linking.LinkSystem, root cid.Cid, selNode datamodel.Node) []blocks.Block
ToBlocks makes a block array from ordered blocks in a traversal
func VerifyCollectedEvent ¶
func VerifyCollectedEvent(t *testing.T, actual types.RetrievalEvent, expected types.RetrievalEvent)
func VerifyContainsCollectedEvent ¶
func VerifyContainsCollectedEvent(t *testing.T, afterStart time.Duration, expectedList []types.RetrievalEvent, actual types.RetrievalEvent) types.EventCode
Types ¶
type AsyncCollectingEventsListener ¶ added in v0.7.0
type AsyncCollectingEventsListener struct {
// contains filtered or unexported fields
}
func NewAsyncCollectingEventsListener ¶ added in v0.7.0
func NewAsyncCollectingEventsListener(ctx context.Context) *AsyncCollectingEventsListener
func (*AsyncCollectingEventsListener) Collect ¶ added in v0.7.0
func (ev *AsyncCollectingEventsListener) Collect(evt types.RetrievalEvent)
func (*AsyncCollectingEventsListener) VerifyNextEvents ¶ added in v0.7.0
func (ev *AsyncCollectingEventsListener) VerifyNextEvents(t *testing.T, afterStart time.Duration, expectedEvents []types.RetrievalEvent)
type ClientRetrievalRequest ¶ added in v0.7.0
type ClientRetrievalRequest struct { Peer peer.ID Proposal *retrievaltypes.DealProposal Selector ipld.Node }
type CollectingEventsListener ¶
type CollectingEventsListener struct { CollectedEvents []types.RetrievalEvent // contains filtered or unexported fields }
func NewCollectingEventsListener ¶
func NewCollectingEventsListener() *CollectingEventsListener
func (*CollectingEventsListener) Collect ¶
func (el *CollectingEventsListener) Collect(event types.RetrievalEvent)
type DelayedClientReturn ¶ added in v0.7.0
type DelayedClientReturn struct { ResultStats *types.RetrievalStats ResultErr error Delay time.Duration }
type DelayedConnectReturn ¶ added in v0.7.0
type DiscoveredCandidate ¶ added in v0.7.0
type DiscoveredCandidate struct { Cid cid.Cid Candidate types.RetrievalCandidate }
type ExpectedActionsAtTime ¶ added in v0.7.0
type ExpectedActionsAtTime struct { AfterStart time.Duration ReceivedConnections []peer.ID ReceivedRetrievals []peer.ID ServedRetrievals []RemoteStats CompletedRetrievals []peer.ID CandidatesDiscovered []DiscoveredCandidate ExpectedEvents []types.RetrievalEvent ExpectedMetrics []SessionMetric }
func BlockReceivedActions ¶ added in v0.19.0
func BlockReceivedActions(baseTime time.Time, baseAfterStart time.Duration, rid types.RetrievalID, candidate types.RetrievalCandidate, protocol multicodec.Code, blockTime time.Duration, blks []blocks.Block) []ExpectedActionsAtTime
func SortActions ¶ added in v0.19.0
func SortActions(actions []ExpectedActionsAtTime) []ExpectedActionsAtTime
type MockCandidateFinder ¶
type MockCandidateFinder struct {
// contains filtered or unexported fields
}
func NewMockCandidateFinder ¶ added in v0.7.0
func NewMockCandidateFinder(err error, candidates map[cid.Cid][]types.RetrievalCandidate) *MockCandidateFinder
func (*MockCandidateFinder) FindCandidates ¶
func (me *MockCandidateFinder) FindCandidates(ctx context.Context, cid cid.Cid) ([]types.RetrievalCandidate, error)
func (*MockCandidateFinder) FindCandidatesAsync ¶
func (me *MockCandidateFinder) FindCandidatesAsync(ctx context.Context, c cid.Cid, cb func(types.RetrievalCandidate)) error
func (*MockCandidateFinder) VerifyCandidatesDiscovered ¶ added in v0.7.0
func (me *MockCandidateFinder) VerifyCandidatesDiscovered(ctx context.Context, t *testing.T, afterStart time.Duration, expectedCandidatesDiscovered []DiscoveredCandidate)
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
func NewMockClient ¶
func NewMockClient(connectReturns map[string]DelayedConnectReturn, retrievalReturns map[string]DelayedClientReturn, clock clock.Clock) *MockClient
func (*MockClient) GetConnectReturns ¶ added in v0.7.0
func (mc *MockClient) GetConnectReturns() map[string]DelayedConnectReturn
func (*MockClient) GetReceivedLinkSystems ¶
func (mc *MockClient) GetReceivedLinkSystems() []ipld.LinkSystem
func (*MockClient) GetRetrievalReturns ¶
func (mc *MockClient) GetRetrievalReturns() map[string]DelayedClientReturn
func (*MockClient) RetrieveFromPeer ¶
func (mc *MockClient) RetrieveFromPeer( ctx context.Context, linkSystem ipld.LinkSystem, peerID peer.ID, proposal *retrievaltypes.DealProposal, selector ipld.Node, maxBlocks uint64, eventsCallback datatransfer.Subscriber, gracefulShutdownRequested <-chan struct{}, ) (*types.RetrievalStats, error)
func (*MockClient) SetConnectReturns ¶ added in v0.7.0
func (mc *MockClient) SetConnectReturns(connectReturns map[string]DelayedConnectReturn)
func (*MockClient) SetRetrievalReturns ¶
func (mc *MockClient) SetRetrievalReturns(retrievalReturns map[string]DelayedClientReturn)
func (*MockClient) VerifyConnectionsReceived ¶ added in v0.7.0
func (*MockClient) VerifyReceivedRetrievalFrom ¶ added in v0.7.0
func (mc *MockClient) VerifyReceivedRetrievalFrom(ctx context.Context, t *testing.T, p peer.ID) ClientRetrievalRequest
func (*MockClient) VerifyRetrievalsCompleted ¶ added in v0.10.0
func (*MockClient) VerifyRetrievalsReceived ¶ added in v0.7.0
func (*MockClient) VerifyRetrievalsServed ¶ added in v0.10.0
func (mc *MockClient) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats)
type MockRoundTripRemote ¶ added in v0.10.0
type MockRoundTripper ¶ added in v0.10.0
type MockRoundTripper struct {
// contains filtered or unexported fields
}
func NewMockRoundTripper ¶ added in v0.10.0
func NewMockRoundTripper( t *testing.T, ctx context.Context, clock *clock.Mock, remoteBlockDuration time.Duration, expectedPath map[cid.Cid]string, expectedScope map[cid.Cid]trustlessutils.DagScope, remotes map[cid.Cid][]MockRoundTripRemote, sendDuplicates map[cid.Cid]bool, ) *MockRoundTripper
func (*MockRoundTripper) VerifyConnectionsReceived ¶ added in v0.10.0
func (*MockRoundTripper) VerifyRetrievalsCompleted ¶ added in v0.10.0
func (*MockRoundTripper) VerifyRetrievalsReceived ¶ added in v0.10.0
func (*MockRoundTripper) VerifyRetrievalsServed ¶ added in v0.10.0
func (mrt *MockRoundTripper) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats)
type MockSession ¶ added in v0.12.0
type MockSession struct {
// contains filtered or unexported fields
}
func NewMockSession ¶ added in v0.12.0
func NewMockSession(ctx context.Context) *MockSession
func (*MockSession) AddToRetrieval ¶ added in v0.12.0
func (ms *MockSession) AddToRetrieval(retrievalId types.RetrievalID, storageProviderIds []peer.ID) error
func (*MockSession) ChooseNextProvider ¶ added in v0.12.0
func (*MockSession) EndRetrieval ¶ added in v0.12.0
func (ms *MockSession) EndRetrieval(retrievalId types.RetrievalID) error
func (*MockSession) FilterIndexerCandidate ¶ added in v0.12.0
func (ms *MockSession) FilterIndexerCandidate(candidate types.RetrievalCandidate) (bool, types.RetrievalCandidate)
func (*MockSession) GetStorageProviderTimeout ¶ added in v0.12.0
func (ms *MockSession) GetStorageProviderTimeout(storageProviderId peer.ID) time.Duration
func (*MockSession) RecordConnectTime ¶ added in v0.12.0
func (ms *MockSession) RecordConnectTime(storageProviderId peer.ID, connectTime time.Duration)
func (*MockSession) RecordFailure ¶ added in v0.12.0
func (ms *MockSession) RecordFailure(retrievalId types.RetrievalID, storageProviderId peer.ID) error
func (*MockSession) RecordFirstByteTime ¶ added in v0.12.0
func (ms *MockSession) RecordFirstByteTime(storageProviderId peer.ID, firstByteTime time.Duration)
func (*MockSession) RecordSuccess ¶ added in v0.12.0
func (ms *MockSession) RecordSuccess(storageProviderId peer.ID, bandwidthBytesPerSecond uint64)
func (*MockSession) RegisterRetrieval ¶ added in v0.12.0
func (ms *MockSession) RegisterRetrieval(retrievalId types.RetrievalID, cid cid.Cid, selector datamodel.Node) bool
func (*MockSession) SetBlockList ¶ added in v0.12.0
func (ms *MockSession) SetBlockList(blockList map[peer.ID]bool)
func (*MockSession) SetCandidatePreferenceOrder ¶ added in v0.12.0
func (ms *MockSession) SetCandidatePreferenceOrder(candidatePreferenceOrder []types.RetrievalCandidate)
func (*MockSession) SetProviderTimeout ¶ added in v0.12.0
func (ms *MockSession) SetProviderTimeout(providerTimeout time.Duration)
func (*MockSession) VerifyMetricsAt ¶ added in v0.12.0
func (ms *MockSession) VerifyMetricsAt(ctx context.Context, t *testing.T, afterStart time.Duration, expectedMetrics []SessionMetric)
func (*MockSession) WithActual ¶ added in v0.12.0
func (ms *MockSession) WithActual(session *session.Session)
WithActual sets a real session to be used for all methods where no value is currently set. The primary use of this is to test session implementation functionality while collecting call information.
type ParentStore ¶ added in v0.13.0
type ParentStore interface { storage.ReadableStorage storage.StreamingReadableStorage storage.WritableStorage }
type RemoteStats ¶ added in v0.10.0
type RetrievalVerifier ¶ added in v0.7.0
type RetrievalVerifier struct {
ExpectedSequence []ExpectedActionsAtTime
}
func (RetrievalVerifier) RunWithVerification ¶ added in v0.7.0
func (rv RetrievalVerifier) RunWithVerification( ctx context.Context, t *testing.T, clock *clock.Mock, client VerifierClient, mockCandidateFinder *MockCandidateFinder, mockSession *MockSession, cancelFunc context.CancelFunc, cancelAfter time.Duration, runRetrievals []RunRetrieval, ) []types.RetrievalResult
type RunRetrieval ¶ added in v0.7.0
type RunRetrieval func(cb func(types.RetrievalEvent)) (*types.RetrievalStats, error)
type SessionMetric ¶ added in v0.12.0
type SessionMetricType ¶ added in v0.12.0
type SessionMetricType string
type ThreadsafeStore ¶ added in v0.13.0
type ThreadsafeStore struct { ParentStore // contains filtered or unexported fields }
func (*ThreadsafeStore) GetStream ¶ added in v0.13.0
func (tss *ThreadsafeStore) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
type VerifierClient ¶ added in v0.10.0
type VerifierClient interface { VerifyConnectionsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, expectedConnections []peer.ID) VerifyRetrievalsReceived(ctx context.Context, t *testing.T, afterStart time.Duration, expectedRetrievals []peer.ID) VerifyRetrievalsServed(ctx context.Context, t *testing.T, afterStart time.Duration, expectedServed []RemoteStats) VerifyRetrievalsCompleted(ctx context.Context, t *testing.T, afterStart time.Duration, expectedRetrievals []peer.ID) }