testutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBlocksOfSize

func GenerateBlocksOfSize(n int, size int64) []blocks.Block

GenerateBlocksOfSize generates a series of blocks of the given byte size

func GenerateCid

func GenerateCid() cid.Cid

GenerateCid produces a content identifier.

func GenerateCids

func GenerateCids(n int) []cid.Cid

GenerateCids produces n content identifiers.

func GeneratePeers

func GeneratePeers(n int) []peer.ID

GeneratePeers creates n peer ids.

func GenerateRetrievalCandidates

func GenerateRetrievalCandidates(n int) []types.RetrievalCandidate

GenerateRetrievalCandidates produces n retrieval candidates

func GenerateRetrievalIDs

func GenerateRetrievalIDs(t *testing.T, n int) []types.RetrievalID

func RandomBytes

func RandomBytes(n int64) []byte

RandomBytes returns a byte array of the given size with random values.

func VerifyCollectedEvent

func VerifyCollectedEvent(t *testing.T, actual types.RetrievalEvent, expected types.RetrievalEvent)

func VerifyCollectedEventTimings

func VerifyCollectedEventTimings(t *testing.T, events []types.RetrievalEvent)

func VerifyContainsCollectedEvent

func VerifyContainsCollectedEvent(t *testing.T, actualList []types.RetrievalEvent, expected types.RetrievalEvent)

Types

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 DelayedQueryReturn

type DelayedQueryReturn struct {
	QueryResponse *retrievalmarket.QueryResponse
	Err           error
	Delay         time.Duration
}

type DelayedRetrievalReturn

type DelayedRetrievalReturn struct {
	ResultStats *types.RetrievalStats
	ResultErr   error
	Delay       time.Duration
}

type MockCandidateFinder

type MockCandidateFinder struct {
	Error      error
	Candidates map[cid.Cid][]types.RetrievalCandidate
}

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) (<-chan types.FindCandidatesResult, error)

type MockClient

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

func NewMockClient

func NewMockClient(queryReturns map[string]DelayedQueryReturn, retrievalReturns map[string]DelayedRetrievalReturn) *MockClient

func (*MockClient) GetQueryReturns

func (mc *MockClient) GetQueryReturns() map[string]DelayedQueryReturn

func (*MockClient) GetReceivedLinkSystems

func (mc *MockClient) GetReceivedLinkSystems() []ipld.LinkSystem

func (*MockClient) GetReceivedQueries

func (mc *MockClient) GetReceivedQueries() []peer.ID

func (*MockClient) GetReceivedRetrievals

func (mc *MockClient) GetReceivedRetrievals() []peer.ID

func (*MockClient) GetRetrievalReturns

func (mc *MockClient) GetRetrievalReturns() map[string]DelayedRetrievalReturn

func (*MockClient) RetrievalQueryToPeer

func (mc *MockClient) RetrievalQueryToPeer(
	ctx context.Context,
	minerPeer peer.AddrInfo,
	pcid cid.Cid,
	onConnected func(),
) (*retrievalmarket.QueryResponse, error)

func (*MockClient) RetrieveFromPeer

func (mc *MockClient) RetrieveFromPeer(
	ctx context.Context,
	linkSystem ipld.LinkSystem,
	peerID peer.ID,
	minerWallet address.Address,
	proposal *retrievalmarket.DealProposal,
	eventsCallback datatransfer.Subscriber,
	gracefulShutdownRequested <-chan struct{},
) (*types.RetrievalStats, error)

func (*MockClient) SetQueryReturns

func (mc *MockClient) SetQueryReturns(queryReturns map[string]DelayedQueryReturn)

func (*MockClient) SetRetrievalReturns

func (mc *MockClient) SetRetrievalReturns(retrievalReturns map[string]DelayedRetrievalReturn)

Jump to

Keyboard shortcuts

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