shared_testutil

package
v0.0.0-...-f311442 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0, MIT Imports: 76 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestErrNotFound = errors.New("file not found")
View Source
var TestErrTempFile = errors.New("temp file creation failed")

Functions

func AssertDealState

func AssertDealState(t *testing.T, expected storagemarket.StorageDealStatus, actual storagemarket.StorageDealStatus)

AssertDealState asserts equality of StorageDealStatus but with better error messaging

func AssertRetrievalDealState

func AssertRetrievalDealState(t *testing.T, expected, actual retrievalmarket.DealStatus)

func ContainsBlock

func ContainsBlock(blks []blocks.Block, block blocks.Block) bool

ContainsBlock returns true if a block is found n a list of blocks

func ContainsPeer

func ContainsPeer(peers []peer.ID, p peer.ID) bool

ContainsPeer returns true if a peer is found n a list of peers.

func CreateDenseCARv2

func CreateDenseCARv2(t *testing.T, src string) (root cid.Cid, path string)

CreateDenseCARv2 generates a "dense" UnixFS CARv2 from the supplied ordinary file. A dense UnixFS CARv2 is one storing leaf data. Contrast to CreateRefCARv2.

func CreateRefCARv2

func CreateRefCARv2(t *testing.T, src string) (cid.Cid, string)

CreateRefCARv2 generates a "ref" CARv2 from the supplied ordinary file. A "ref" CARv2 is one that stores leaf data as positional references to the original file.

func DatastoreAtVersion

func DatastoreAtVersion(t *testing.T, ds datastore.Batching, version versioning.VersionKey) datastore.Batching

func FailDealPaymentReader

func FailDealPaymentReader() (rm.DealPayment, error)

FailDealPaymentReader always fails

func FailDealPaymentWriter

func FailDealPaymentWriter(rm.DealPayment) error

FailDealPaymentWriter always fails

func FailDealProposalReader

func FailDealProposalReader() (rm.DealProposal, error)

FailDealProposalReader always fails

func FailDealProposalWriter

func FailDealProposalWriter(rm.DealProposal) error

FailDealProposalWriter always fails

func FailDealResponseReader

func FailDealResponseReader() (rm.DealResponse, error)

FailDealResponseReader always fails

func FailDealResponseWriter

func FailDealResponseWriter(rm.DealResponse) error

FailDealResponseWriter always fails

func FailNewQueryStream

func FailNewQueryStream(peer.ID) (rmnet.RetrievalQueryStream, error)

FailNewQueryStream always fails

func FailQueryReader

func FailQueryReader() (rm.Query, error)

FailQueryReader always fails

func FailQueryWriter

func FailQueryWriter(rm.Query) error

FailQueryWriter always fails

func FailResponseReader

func FailResponseReader() (rm.QueryResponse, error)

FailResponseReader always fails

func FailResponseWriter

func FailResponseWriter(rm.QueryResponse) error

FailResponseWriter always fails

func FailStorageProposalReader

func FailStorageProposalReader() (smnet.Proposal, error)

FailStorageProposalReader always fails

func FailStorageProposalWriter

func FailStorageProposalWriter(smnet.Proposal) error

FailStorageProposalWriter always fails

func FailStorageResponseReader

func FailStorageResponseReader() (smnet.SignedResponse, []byte, error)

FailStorageResponseReader always fails

func FailStorageResponseWriter

func FailStorageResponseWriter(smnet.SignedResponse) error

FailStorageResponseWriter always fails

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(t *testing.T, o interface{}) cid.Cid

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 IndexOf

func IndexOf(blks []blocks.Block, c cid.Cid) int

IndexOf returns the index of a given cid in an array of blocks

func MakeIdentityCidWith

func MakeIdentityCidWith(cids []cid.Cid, codec multicodec.Code, padding ...[]byte) (cid.Cid, error)

MakeIdentityCidWith will create either a dag-pb or dag-cbor identity CID containing the provided list of CIDs and optional byte blocks. The dag-cbor identity CID will be a simple list with all items appended. This can also be used recursively to increase the ridiculousness.

func MakeTestChannelID

func MakeTestChannelID() datatransfer.ChannelID

MakeTestChannelID makes a new empty data transfer channel ID

func MakeTestClientDeal

func MakeTestClientDeal(state storagemarket.StorageDealStatus, clientDealProposal *market.ClientDealProposal, manualXfer bool) (*storagemarket.ClientDeal, error)

MakeTestClientDeal returns a storage market client deal

func MakeTestClientDealProposal

func MakeTestClientDealProposal() *market.ClientDealProposal

MakeTestClientDealProposal generates a valid storage deal proposal

func MakeTestDataRef

func MakeTestDataRef(manualXfer bool) *storagemarket.DataRef

MakeTestDataRef returns a storage market data ref

func MakeTestDealProposal

func MakeTestDealProposal() *retrievalmarket.DealProposal

MakeTestDealProposal generates a valid, random DealProposal

func MakeTestDealStatusRequest

func MakeTestDealStatusRequest() smnet.DealStatusRequest

MakeTestDealStatusRequest generates a request to get a provider's query

func MakeTestDealStatusResponse

func MakeTestDealStatusResponse() smnet.DealStatusResponse

MakeTestDealStatusResponse generates a response to an query request

func MakeTestMerge

func MakeTestMerge() paych.Merge

MakeTestMerge generates a random Merge that has all non-zero fields

func MakeTestMinerDeal

func MakeTestMinerDeal(state storagemarket.StorageDealStatus, clientDealProposal *market.ClientDealProposal, dataRef *storagemarket.DataRef) (*storagemarket.MinerDeal, error)

MakeTestMinerDeal returns a storage market provider deal

func MakeTestModVerifyParams

func MakeTestModVerifyParams() *paych.ModVerifyParams

MakeTestModVerifyParams generates a random ModVerifyParams that has all non-zero fields

func MakeTestQueryResponse

func MakeTestQueryResponse() retrievalmarket.QueryResponse

MakeTestQueryResponse generates a valid, random QueryResponse with no non-zero fields

func MakeTestSignature

func MakeTestSignature() *crypto.Signature

MakeTestSignature generates a valid yet random Signature with all non-zero fields

func MakeTestSignedStorageAsk

func MakeTestSignedStorageAsk() *storagemarket.SignedStorageAsk

MakeTestSignedStorageAsk generates a signed storage ask

func MakeTestSignedVoucher

func MakeTestSignedVoucher() *paych.SignedVoucher

MakeTestSignedVoucher generates a random SignedVoucher that has all non-zero fields

func MakeTestStorageAsk

func MakeTestStorageAsk() *storagemarket.StorageAsk

MakeTestStorageAsk generates a storage ask

func MakeTestStorageAskRequest

func MakeTestStorageAskRequest() smnet.AskRequest

MakeTestStorageAskRequest generates a request to get a provider's ask

func MakeTestStorageAskResponse

func MakeTestStorageAskResponse() smnet.AskResponse

MakeTestStorageAskResponse generates a response to an ask request

func MakeTestStorageNetworkProposal

func MakeTestStorageNetworkProposal() smnet.Proposal

MakeTestStorageNetworkProposal generates a proposal that can be sent over the network to a provider

func MakeTestStorageNetworkResponse

func MakeTestStorageNetworkResponse() smnet.Response

MakeTestStorageNetworkResponse generates a response to a proposal sent over the network

func MakeTestStorageNetworkSignedResponse

func MakeTestStorageNetworkSignedResponse() smnet.SignedResponse

MakeTestStorageNetworkSignedResponse generates a response to a proposal sent over the network that is signed

func MakeTestTokenAmount

func MakeTestTokenAmount() abi.TokenAmount

MakeTestTokenAmount generates a valid yet random TokenAmount with a non-zero value.

func MakeTestUnsignedDealProposal

func MakeTestUnsignedDealProposal() market.DealProposal

MakeTestUnsignedDealProposal generates a deal proposal with no signature

func NewIDAddr

func NewIDAddr(t testing.TB, id uint64) address.Address

func NewTestChannel

func NewTestChannel(params TestChannelParams) datatransfer.ChannelState

NewTestChannel makes a test channel with default params plus non-zero values for TestChannelParams

func QueryReadWriter

func QueryReadWriter() (QueryReader, QueryWriter)

QueryReadWriter will read only if something is written, otherwise it errors

func QueryResponseReadWriter

func QueryResponseReadWriter() (QueryResponseReader, QueryResponseWriter)

QueryResponseReadWriter will read only if something is written, otherwise it errors

func RandomBytes

func RandomBytes(n int64) []byte

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

func RequireGenerateRetrievalPeers

func RequireGenerateRetrievalPeers(t *testing.T, numPeers int) []retrievalmarket.RetrievalPeer

func StartAndWaitForReady

func StartAndWaitForReady(ctx context.Context, t *testing.T, startAndWaitable StartAndWaitable)

StartAndWaitForReady is a utility function to start a module and verify it reaches the ready state

func StartAndWaitForReadyDT

func StartAndWaitForReadyDT(ctx context.Context, t *testing.T, startAndWaitable datatransfer.Manager)

StartAndWaitForReadyDT is a utility function to start a go-data-transfer and verify it reaches the ready state

func TestVoucherEquality

func TestVoucherEquality(t *testing.T, a, b *paych.SignedVoucher)

TestVoucherEquality verifies that two vouchers are equal to one another

func ThisDir

func ThisDir(t *testing.T) string

func TrivialNewQueryStream

func TrivialNewQueryStream(p peer.ID) (rmnet.RetrievalQueryStream, error)

TrivialNewQueryStream succeeds trivially, returning an empty query stream.

func TrivialQueryReader

func TrivialQueryReader() (rm.Query, error)

TrivialQueryReader succeeds trivially, returning an empty query.

func TrivialQueryResponseReader

func TrivialQueryResponseReader() (rm.QueryResponse, error)

TrivialQueryResponseReader succeeds trivially, returning an empty query response.

func TrivialQueryResponseWriter

func TrivialQueryResponseWriter(rm.QueryResponse) error

TrivialQueryResponseWriter succeeds trivially, returning no error.

func TrivialQueryWriter

func TrivialQueryWriter(rm.Query) error

TrivialQueryWriter succeeds trivially, returning no error.

func TrivialStorageDealProposalReader

func TrivialStorageDealProposalReader() (smnet.Proposal, error)

TrivialStorageDealProposalReader succeeds trivially, returning an empty proposal.

func TrivialStorageDealProposalWriter

func TrivialStorageDealProposalWriter(smnet.Proposal) error

TrivialStorageDealProposalWriter succeeds trivially, returning no error.

func TrivialStorageDealResponseReader

func TrivialStorageDealResponseReader() (smnet.SignedResponse, []byte, error)

TrivialStorageDealResponseReader succeeds trivially, returning an empty deal response.

func TrivialStorageDealResponseWriter

func TrivialStorageDealResponseWriter(smnet.SignedResponse, smnet.ResigningFunc) error

TrivialStorageDealResponseWriter succeeds trivially, returning no error.

Types

type DealPaymentReader

type DealPaymentReader func() (rm.DealPayment, error)

DealPaymentReader is a function to mock reading deal payments.

func StubbedDealPaymentReader

func StubbedDealPaymentReader(payment rm.DealPayment) DealPaymentReader

StubbedDealPaymentReader returns the given deal payment when called

type DealPaymentWriter

type DealPaymentWriter func(rm.DealPayment) error

DealPaymentWriter is a function to mock writing deal payments.

type DealProposalReader

type DealProposalReader func() (rm.DealProposal, error)

DealProposalReader is a function to mock reading deal proposals.

func StubbedDealProposalReader

func StubbedDealProposalReader(proposal rm.DealProposal) DealProposalReader

StubbedDealProposalReader returns the given proposal when called

type DealProposalWriter

type DealProposalWriter func(rm.DealProposal) error

DealProposalWriter is a function to mock writing deal proposals.

type DealResponseReader

type DealResponseReader func() (rm.DealResponse, error)

DealResponseReader is a function to mock reading deal responses.

func StubbedDealResponseReader

func StubbedDealResponseReader(response rm.DealResponse) DealResponseReader

StubbedDealResponseReader returns the given deal response when called

type DealResponseWriter

type DealResponseWriter func(rm.DealResponse) error

DealResponseWriter is a function to mock writing deal responses.

func ExpectDealResponseWriter

func ExpectDealResponseWriter(t *testing.T, expectedDealResponse rm.DealResponse, msgAndArgs ...interface{}) DealResponseWriter

ExpectDealResponseWriter will fail if the written query and expected query don't match

type FakeDTValidator

type FakeDTValidator struct{}

func (*FakeDTValidator) ValidatePull

func (v *FakeDTValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error)

func (*FakeDTValidator) ValidatePush

func (v *FakeDTValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error)

func (*FakeDTValidator) ValidateRestart

type Libp2pTestData

type Libp2pTestData struct {
	Ctx         context.Context
	Ds1         datastore.Batching
	Ds2         datastore.Batching
	Bs1         bstore.Blockstore
	Bs2         bstore.Blockstore
	DagService1 ipldformat.DAGService
	DagService2 ipldformat.DAGService
	DTNet1      dtnet.DataTransferNetwork
	DTNet2      dtnet.DataTransferNetwork
	DTStore1    datastore.Batching
	DTStore2    datastore.Batching
	DTTmpDir1   string
	DTTmpDir2   string
	LinkSystem1 ipld.LinkSystem
	LinkSystem2 ipld.LinkSystem
	Host1       host.Host
	Host2       host.Host
	OrigBytes   []byte

	MockNet mocknet.Mocknet
}

func NewLibp2pTestData

func NewLibp2pTestData(ctx context.Context, t *testing.T) *Libp2pTestData

func (*Libp2pTestData) LoadUnixFSFile

func (ltd *Libp2pTestData) LoadUnixFSFile(t *testing.T, src string, useSecondNode bool) (datamodel.Link, string)

LoadUnixFSFile injects the fixture `src` into the given blockstore from the fixtures directory. If useSecondNode is true, fixture is injected to the second node; otherwise the first node gets it

func (*Libp2pTestData) LoadUnixFSFileToStore

func (ltd *Libp2pTestData) LoadUnixFSFileToStore(t *testing.T, src string) (datamodel.Link, string)

LoadUnixFSFileToStore creates a CAR file from the fixture at `src`

func (*Libp2pTestData) VerifyFileTransferred

func (ltd *Libp2pTestData) VerifyFileTransferred(t *testing.T, link datamodel.Link, useSecondNode bool, readLen uint64)

VerifyFileTransferred checks that the fixture file was sent from one node to the other.

func (*Libp2pTestData) VerifyFileTransferredIntoStore

func (ltd *Libp2pTestData) VerifyFileTransferredIntoStore(t *testing.T, link datamodel.Link, bs bstore.Blockstore, readLen uint64)

VerifyFileTransferredIntoStore checks that the fixture file was sent from one node to the other, and stored in the given CAR file

type MockDagStoreWrapper

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

MockDagStoreWrapper is used to mock out the DAG store wrapper operations for the tests. It simulates getting deal info from a piece store and unsealing the data for the deal from a retrieval provider node.

func (*MockDagStoreWrapper) AddBlockToPieceIndex

func (m *MockDagStoreWrapper) AddBlockToPieceIndex(blockCID cid.Cid, pieceCid cid.Cid)

Used by the tests to add an entry to the index of block CID -> []piece CID

func (*MockDagStoreWrapper) ClearRegistrations

func (m *MockDagStoreWrapper) ClearRegistrations()

func (*MockDagStoreWrapper) Close

func (m *MockDagStoreWrapper) Close() error

func (*MockDagStoreWrapper) DestroyShard

func (m *MockDagStoreWrapper) DestroyShard(ctx context.Context, pieceCid cid.Cid, resch chan dagstore.ShardResult) error

func (*MockDagStoreWrapper) GetIterableIndexForPiece

func (m *MockDagStoreWrapper) GetIterableIndexForPiece(c cid.Cid) (carindex.IterableIndex, error)

func (*MockDagStoreWrapper) GetPiecesContainingBlock

func (m *MockDagStoreWrapper) GetPiecesContainingBlock(blockCID cid.Cid) ([]cid.Cid, error)

func (*MockDagStoreWrapper) GetRegistration

func (m *MockDagStoreWrapper) GetRegistration(pieceCid cid.Cid) (registration, bool)

func (*MockDagStoreWrapper) LenRegistrations

func (m *MockDagStoreWrapper) LenRegistrations() int

func (*MockDagStoreWrapper) LoadShard

func (m *MockDagStoreWrapper) LoadShard(ctx context.Context, pieceCid cid.Cid) (stores.ClosableBlockstore, error)

func (*MockDagStoreWrapper) MigrateDeals

func (m *MockDagStoreWrapper) MigrateDeals(ctx context.Context, deals []storagemarket.MinerDeal) (bool, error)

func (*MockDagStoreWrapper) RegisterShard

func (m *MockDagStoreWrapper) RegisterShard(ctx context.Context, pieceCid cid.Cid, carPath string, eagerInit bool, resch chan dagstore.ShardResult) error

type MockIndexProvider

type MockIndexProvider struct {
	provider.Interface
	// contains filtered or unexported fields
}

func NewMockIndexProvider

func NewMockIndexProvider() *MockIndexProvider

func (*MockIndexProvider) GetNotifs

func (m *MockIndexProvider) GetNotifs() map[string]metadata.Metadata

func (*MockIndexProvider) NotifyPut

func (m *MockIndexProvider) NotifyPut(ctx context.Context, addr *peer.AddrInfo, contextID []byte, metadata metadata.Metadata) (cid.Cid, error)

func (*MockIndexProvider) NotifyRemove

func (m *MockIndexProvider) NotifyRemove(ctx context.Context, p peer.ID, contextID []byte) (cid.Cid, error)

func (*MockIndexProvider) RegisterMultihashLister

func (m *MockIndexProvider) RegisterMultihashLister(cb provider.MultihashLister)

type QueryReader

type QueryReader func() (rm.Query, error)

QueryReader is a function to mock reading queries.

func StubbedQueryReader

func StubbedQueryReader(query rm.Query) QueryReader

StubbedQueryReader returns the given query when called

type QueryResponseReader

type QueryResponseReader func() (rm.QueryResponse, error)

QueryResponseReader is a function to mock reading query responses.

func StubbedQueryResponseReader

func StubbedQueryResponseReader(queryResponse rm.QueryResponse) QueryResponseReader

StubbedQueryResponseReader returns the given query response when called

type QueryResponseWriter

type QueryResponseWriter func(rm.QueryResponse) error

QueryResponseWriter is a function to mock writing query responses.

func ExpectQueryResponseWriter

func ExpectQueryResponseWriter(t *testing.T, expectedQueryResponse rm.QueryResponse, msgAndArgs ...interface{}) QueryResponseWriter

ExpectQueryResponseWriter will fail if the written query response and expected query response don't match

type QueryStreamBuilder

type QueryStreamBuilder func(peer.ID) (rmnet.RetrievalQueryStream, error)

QueryStreamBuilder is a function that builds retrieval query streams.

func ExpectPeerOnQueryStreamBuilder

func ExpectPeerOnQueryStreamBuilder(t *testing.T, expectedPeer peer.ID, qb QueryStreamBuilder, msgAndArgs ...interface{}) QueryStreamBuilder

ExpectPeerOnQueryStreamBuilder fails if the peer used does not match the expected peer

type QueryWriter

type QueryWriter func(rm.Query) error

QueryWriter is a function to mock writing queries.

func ExpectQueryWriter

func ExpectQueryWriter(t *testing.T, expectedQuery rm.Query, msgAndArgs ...interface{}) QueryWriter

ExpectQueryWriter will fail if the written query and expected query don't match

type RegisteredTransportConfigurer

type RegisteredTransportConfigurer struct {
	VoucherType datatransfer.TypeIdentifier
	Configurer  datatransfer.TransportConfigurer
}

RegisteredTransportConfigurer records transport configurer registered for a voucher type

type RegisteredVoucherType

type RegisteredVoucherType struct {
	VoucherType datatransfer.TypeIdentifier
	Validator   datatransfer.RequestValidator
}

RegisteredVoucherType records a voucher typed that was registered

type StartAndWaitable

type StartAndWaitable interface {
	Start(ctx context.Context) error
	OnReady(shared.ReadyFunc)
}

StartAndWaitable is any interface that can be started up and will be asynchronously ready later

type StorageDealProposalReader

type StorageDealProposalReader func() (smnet.Proposal, error)

StorageDealProposalReader is a function to mock reading deal proposals.

func StubbedStorageProposalReader

func StubbedStorageProposalReader(proposal smnet.Proposal) StorageDealProposalReader

StubbedStorageProposalReader returns the given proposal when called

type StorageDealProposalWriter

type StorageDealProposalWriter func(smnet.Proposal) error

StorageDealProposalWriter is a function to mock writing deal proposals.

type StorageDealResponseReader

type StorageDealResponseReader func() (smnet.SignedResponse, []byte, error)

StorageDealResponseReader is a function to mock reading deal responses.

func StubbedStorageResponseReader

func StubbedStorageResponseReader(response smnet.SignedResponse) StorageDealResponseReader

StubbedStorageResponseReader returns the given deal response when called

type StorageDealResponseWriter

type StorageDealResponseWriter func(smnet.SignedResponse, smnet.ResigningFunc) error

StorageDealResponseWriter is a function to mock writing deal responses.

type TestChannel

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

TestChannel implements a datatransfer channel with set values

func (*TestChannel) BaseCID

func (tc *TestChannel) BaseCID() cid.Cid

BaseCID returns the CID that is at the root of this data transfer

func (*TestChannel) BothPaused

func (tc *TestChannel) BothPaused() bool

func (*TestChannel) ChannelID

func (tc *TestChannel) ChannelID() datatransfer.ChannelID

ChannelID returns the channel id for this channel

func (*TestChannel) DataLimit

func (tc *TestChannel) DataLimit() uint64

func (*TestChannel) InitiatorPaused

func (tc *TestChannel) InitiatorPaused() bool

func (*TestChannel) IsPull

func (tc *TestChannel) IsPull() bool

IsPull returns whether this is a pull request based on who initiated it

func (*TestChannel) LastVoucher

func (tc *TestChannel) LastVoucher() datatransfer.TypedVoucher

LastVoucher returns the last voucher sent on the channel

func (*TestChannel) LastVoucherResult

func (tc *TestChannel) LastVoucherResult() datatransfer.TypedVoucher

LastVoucherResult returns the last voucher result sent on the channel

func (*TestChannel) Message

func (tc *TestChannel) Message() string

Message offers additional information about the current status

func (*TestChannel) MissingCids

func (tc *TestChannel) MissingCids() []cid.Cid

TODO actual implementation of those

func (*TestChannel) OtherParty

func (tc *TestChannel) OtherParty(thisParty peer.ID) peer.ID

OtherParty returns the opposite party in the channel to the passed in party

func (*TestChannel) OtherPeer

func (tc *TestChannel) OtherPeer() peer.ID

OtherPeer returns the channel counter party peer

func (*TestChannel) Queued

func (tc *TestChannel) Queued() uint64

Received returns the number of bytes received

func (*TestChannel) QueuedCidsTotal

func (tc *TestChannel) QueuedCidsTotal() int64

func (*TestChannel) Received

func (tc *TestChannel) Received() uint64

Received returns the number of bytes received

func (*TestChannel) ReceivedCids

func (tc *TestChannel) ReceivedCids() []cid.Cid

ReceivedCids returns the cids received so far

func (*TestChannel) ReceivedCidsLen

func (tc *TestChannel) ReceivedCidsLen() int

func (*TestChannel) ReceivedCidsTotal

func (tc *TestChannel) ReceivedCidsTotal() int64

func (*TestChannel) Recipient

func (tc *TestChannel) Recipient() peer.ID

Recipient returns the peer id for the node that is receiving data

func (*TestChannel) RequiresFinalization

func (tc *TestChannel) RequiresFinalization() bool

func (*TestChannel) ResponderPaused

func (tc *TestChannel) ResponderPaused() bool

func (*TestChannel) Selector

func (tc *TestChannel) Selector() datamodel.Node

Selector returns the IPLD selector for this data transfer (represented as an IPLD node)

func (*TestChannel) SelfPaused

func (tc *TestChannel) SelfPaused() bool

func (*TestChannel) SelfPeer

func (tc *TestChannel) SelfPeer() peer.ID

SelfPeer returns the peer this channel belongs to

func (*TestChannel) Sender

func (tc *TestChannel) Sender() peer.ID

Sender returns the peer id for the node that is sending data

func (*TestChannel) Sent

func (tc *TestChannel) Sent() uint64

Sent returns the number of bytes sent

func (*TestChannel) SentCidsTotal

func (tc *TestChannel) SentCidsTotal() int64

func (*TestChannel) Stages

func (tc *TestChannel) Stages() *datatransfer.ChannelStages

func (*TestChannel) Status

func (tc *TestChannel) Status() datatransfer.Status

Status is the current status of this channel

func (*TestChannel) TotalSize

func (tc *TestChannel) TotalSize() uint64

TotalSize returns the total size for the data being transferred

func (*TestChannel) TransferID

func (tc *TestChannel) TransferID() datatransfer.TransferID

TransferID returns the transfer id for this channel

func (*TestChannel) Voucher

func (tc *TestChannel) Voucher() datatransfer.TypedVoucher

Voucher returns the voucher for this data transfer

func (*TestChannel) VoucherResults

func (tc *TestChannel) VoucherResults() []datatransfer.TypedVoucher

VoucherResults are results of vouchers sent on the channel

func (*TestChannel) Vouchers

func (tc *TestChannel) Vouchers() []datatransfer.TypedVoucher

Vouchers returns all vouchers sent on this channel

type TestChannelParams

type TestChannelParams struct {
	TransferID     datatransfer.TransferID
	BaseCID        cid.Cid
	Selector       datamodel.Node
	SelfPeer       peer.ID
	Sender         peer.ID
	Recipient      peer.ID
	TotalSize      uint64
	IsPull         bool
	Message        string
	Sent           uint64
	Received       uint64
	Queued         uint64
	Status         datatransfer.Status
	Vouchers       []datatransfer.TypedVoucher
	VoucherResults []datatransfer.TypedVoucher
	ReceivedCids   []cid.Cid
}

TestChannelParams are params for a new test data transfer channel

type TestDataTransfer

type TestDataTransfer struct {
	RegisteredVoucherTypes         []RegisteredVoucherType
	RegisteredTransportConfigurers []RegisteredTransportConfigurer
	Subscribers                    []datatransfer.Subscriber
}

TestDataTransfer is a mock implementation of the data transfer libary Most of its functions have no effect

func NewTestDataTransfer

func NewTestDataTransfer() *TestDataTransfer

NewTestDataTransfer returns a new test interface implementation of datatransfer.Manager

func (*TestDataTransfer) ChannelState

func (*TestDataTransfer) CloseDataTransferChannel

func (tdt *TestDataTransfer) CloseDataTransferChannel(ctx context.Context, chid datatransfer.ChannelID) error

CloseDataTransferChannel does nothing

func (*TestDataTransfer) InProgressChannels

InProgressChannels returns empty

func (*TestDataTransfer) OnReady

func (tdt *TestDataTransfer) OnReady(f datatransfer.ReadyFunc)

func (*TestDataTransfer) OpenPullDataChannel

func (tdt *TestDataTransfer) OpenPullDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node, options ...datatransfer.TransferOption) (datatransfer.ChannelID, error)

OpenPullDataChannel does nothing

func (*TestDataTransfer) OpenPushDataChannel

func (tdt *TestDataTransfer) OpenPushDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node, options ...datatransfer.TransferOption) (datatransfer.ChannelID, error)

OpenPushDataChannel does nothing

func (*TestDataTransfer) PauseDataTransferChannel

func (tdt *TestDataTransfer) PauseDataTransferChannel(ctx context.Context, chid datatransfer.ChannelID) error

PauseDataTransferChannel does nothing

func (*TestDataTransfer) RegisterTransportConfigurer

func (tdt *TestDataTransfer) RegisterTransportConfigurer(voucherType datatransfer.TypeIdentifier, configurer datatransfer.TransportConfigurer) error

RegisterTransportConfigurer records the registered transport configurer

func (*TestDataTransfer) RegisterVoucherType

func (tdt *TestDataTransfer) RegisterVoucherType(voucherType datatransfer.TypeIdentifier, validator datatransfer.RequestValidator) error

RegisterVoucherType records the registred voucher type

func (*TestDataTransfer) RestartDataTransferChannel

func (tdt *TestDataTransfer) RestartDataTransferChannel(ctx context.Context, chId datatransfer.ChannelID) error

func (*TestDataTransfer) ResumeDataTransferChannel

func (tdt *TestDataTransfer) ResumeDataTransferChannel(ctx context.Context, chid datatransfer.ChannelID) error

ResumeDataTransferChannel does nothing

func (*TestDataTransfer) SendVoucher

SendVoucher does nothing

func (*TestDataTransfer) SendVoucherResult

func (tdt *TestDataTransfer) SendVoucherResult(ctx context.Context, chid datatransfer.ChannelID, voucherResult datatransfer.TypedVoucher) error

SendVoucherResult does nothing

func (*TestDataTransfer) Start

func (tdt *TestDataTransfer) Start(ctx context.Context) error

Start does nothing

func (*TestDataTransfer) Stop

Stop does nothing

func (*TestDataTransfer) SubscribeToEvents

func (tdt *TestDataTransfer) SubscribeToEvents(subscriber datatransfer.Subscriber) datatransfer.Unsubscribe

SubscribeToEvents records subscribers

func (*TestDataTransfer) TransferChannelStatus

func (tdt *TestDataTransfer) TransferChannelStatus(ctx context.Context, x datatransfer.ChannelID) datatransfer.Status

TransferChannelStatus returns ChannelNotFoundError

func (*TestDataTransfer) UpdateValidationStatus

func (tdt *TestDataTransfer) UpdateValidationStatus(ctx context.Context, chid datatransfer.ChannelID, result datatransfer.ValidationResult) error

UpdateValidationStatus does nothing

type TestDealFunds

type TestDealFunds struct {
	ReserveCalls []abi.TokenAmount
	ReleaseCalls []abi.TokenAmount
	// contains filtered or unexported fields
}

func NewTestDealFunds

func NewTestDealFunds() *TestDealFunds

func (*TestDealFunds) Get

func (f *TestDealFunds) Get() abi.TokenAmount

func (*TestDealFunds) Release

func (f *TestDealFunds) Release(amount abi.TokenAmount) (abi.TokenAmount, error)

func (*TestDealFunds) Reserve

func (f *TestDealFunds) Reserve(amount abi.TokenAmount) (abi.TokenAmount, error)

type TestDealStreamParams

type TestDealStreamParams struct {
	PeerID         peer.ID
	ProposalReader DealProposalReader
	ProposalWriter DealProposalWriter
	ResponseReader DealResponseReader
	ResponseWriter DealResponseWriter
	PaymentReader  DealPaymentReader
	PaymentWriter  DealPaymentWriter
}

TestDealStreamParams are parameters used to setup a TestRetrievalDealStream. All parameters except the peer ID are optional.

type TestFile

type TestFile struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

TestFile is a mocked version of filestore.File with preset returns and a byte buffer for read/writes

func NewTestFile

func NewTestFile(params TestFileParams) *TestFile

NewTestFile generates a mocked filestore.File that has programmed returns

func (*TestFile) Close

func (f *TestFile) Close() error

Close does nothing

func (*TestFile) OsPath

func (f *TestFile) OsPath() filestore.OsPath

OsPath is not implemented

func (*TestFile) Path

func (f *TestFile) Path() filestore.Path

Path returns the preset path

func (*TestFile) Seek

func (f *TestFile) Seek(offset int64, whence int) (int64, error)

Seek is not implemented

func (*TestFile) Size

func (f *TestFile) Size() int64

Size returns the preset size

type TestFileParams

type TestFileParams struct {
	Buffer *bytes.Buffer
	Size   int64
	Path   filestore.Path
}

TestFileParams are parameters for a test file

type TestFileStore

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

TestFileStore is a mocked file store that can provide programmed returns and test expectations

func NewTestFileStore

func NewTestFileStore(params TestFileStoreParams) *TestFileStore

NewTestFileStore returns a new test file store from the given parameters

func (*TestFileStore) Create

func (fs *TestFileStore) Create(p filestore.Path) (filestore.File, error)

Create is not implement

func (*TestFileStore) CreateTemp

func (fs *TestFileStore) CreateTemp() (filestore.File, error)

CreateTemp will create a temporary file from the provided set of temporary files

func (*TestFileStore) Delete

func (fs *TestFileStore) Delete(p filestore.Path) error

Delete will delete a file if it is in the file store

func (*TestFileStore) Open

Open will open a file if it's in the file store

func (*TestFileStore) Store

Store is not implemented

func (*TestFileStore) VerifyExpectations

func (fs *TestFileStore) VerifyExpectations(t *testing.T)

VerifyExpectations will verify that the correct files were opened and deleted

type TestFileStoreParams

type TestFileStoreParams struct {
	Files              []filestore.File
	AvailableTempFiles []filestore.File
	ExpectedDeletions  []filestore.Path
	ExpectedOpens      []filestore.Path
}

TestFileStoreParams are parameters for a test file store

type TestIPLDTree

type TestIPLDTree struct {
	Storage           map[datamodel.Link][]byte
	LeafAlpha         datamodel.Node
	LeafAlphaLnk      datamodel.Link
	LeafAlphaBlock    blocks.Block
	LeafBeta          datamodel.Node
	LeafBetaLnk       datamodel.Link
	LeafBetaBlock     blocks.Block
	MiddleMapNode     datamodel.Node
	MiddleMapNodeLnk  datamodel.Link
	MiddleMapBlock    blocks.Block
	MiddleListNode    datamodel.Node
	MiddleListNodeLnk datamodel.Link
	MiddleListBlock   blocks.Block
	RootNode          datamodel.Node
	RootNodeLnk       datamodel.Link
	RootBlock         blocks.Block
}

TestIPLDTree is a set of IPLD Data that forms a tree spread across some blocks with a serialized in memory representation

func NewTestIPLDTree

func NewTestIPLDTree() TestIPLDTree

NewTestIPLDTree returns a fake tree of nodes, spread across 5 blocks

func (TestIPLDTree) DumpToCar

func (tt TestIPLDTree) DumpToCar(out io.Writer, userOnNewCarBlocks ...car.OnNewCarBlockFunc) error

DumpToCar puts the tree into a car file, with user configured functions

func (TestIPLDTree) Get

func (tt TestIPLDTree) Get(ctx context.Context, c cid.Cid) (blocks.Block, error)

Get makes a test tree behave like a block read store

type TestNetworkParams

type TestNetworkParams struct {
	QueryStreamBuilder QueryStreamBuilder
	Receiver           rmnet.RetrievalReceiver
}

TestNetworkParams are parameters for setting up a test network. All parameters other than the receiver are optional

type TestPeerResolver

type TestPeerResolver struct {
	Peers         []rm.RetrievalPeer
	ResolverError error
}

TestPeerResolver provides a fake retrievalmarket PeerResolver

func (TestPeerResolver) GetPeers

func (tpr TestPeerResolver) GetPeers(cid.Cid) ([]rm.RetrievalPeer, error)

type TestPeerTagger

type TestPeerTagger struct {
	TagCalls   []peer.ID
	UntagCalls []peer.ID
}

func NewTestPeerTagger

func NewTestPeerTagger() *TestPeerTagger

func (*TestPeerTagger) TagPeer

func (pt *TestPeerTagger) TagPeer(id peer.ID, _ string)

func (*TestPeerTagger) UntagPeer

func (pt *TestPeerTagger) UntagPeer(id peer.ID, _ string)

type TestPieceStore

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

TestPieceStore is piecestore who's query results are mocked

func NewTestPieceStore

func NewTestPieceStore() *TestPieceStore

NewTestPieceStore creates a TestPieceStore

func NewTestPieceStoreWithParams

func NewTestPieceStoreWithParams(params TestPieceStoreParams) *TestPieceStore

NewTestPieceStoreWithParams creates a TestPieceStore with the given parameters

func (*TestPieceStore) AddDealForPiece

func (tps *TestPieceStore) AddDealForPiece(pieceCID cid.Cid, _ cid.Cid, dealInfo piecestore.DealInfo) error

AddDealForPiece returns a preprogrammed error

func (*TestPieceStore) AddPieceBlockLocations

func (tps *TestPieceStore) AddPieceBlockLocations(pieceCID cid.Cid, blockLocations map[cid.Cid]piecestore.BlockLocation) error

AddPieceBlockLocations returns a preprogrammed error

func (*TestPieceStore) ExpectCID

func (tps *TestPieceStore) ExpectCID(c cid.Cid, cidInfo piecestore.CIDInfo)

ExpectCID records a CID being expected to be queried and return the given CID info

func (*TestPieceStore) ExpectMissingCID

func (tps *TestPieceStore) ExpectMissingCID(c cid.Cid)

ExpectMissingCID records a CID being expected to be queried and should fail

func (*TestPieceStore) ExpectMissingPiece

func (tps *TestPieceStore) ExpectMissingPiece(pieceCid cid.Cid)

ExpectMissingPiece records a piece being expected to be queried and should fail

func (*TestPieceStore) ExpectPiece

func (tps *TestPieceStore) ExpectPiece(pieceCid cid.Cid, pieceInfo piecestore.PieceInfo)

ExpectPiece records a piece being expected to be queried and return the given piece info

func (*TestPieceStore) GetCIDInfo

func (tps *TestPieceStore) GetCIDInfo(c cid.Cid) (piecestore.CIDInfo, error)

GetCIDInfo returns cid info if it's been stubbed

func (*TestPieceStore) GetPieceInfo

func (tps *TestPieceStore) GetPieceInfo(pieceCID cid.Cid) (piecestore.PieceInfo, error)

GetPieceInfo returns a piece info if it's been stubbed

func (*TestPieceStore) ListCidInfoKeys

func (tps *TestPieceStore) ListCidInfoKeys() ([]cid.Cid, error)

func (*TestPieceStore) ListPieceInfoKeys

func (tps *TestPieceStore) ListPieceInfoKeys() ([]cid.Cid, error)

func (*TestPieceStore) OnReady

func (tps *TestPieceStore) OnReady(ready shared.ReadyFunc)

func (*TestPieceStore) ReturnErrorFromGetPieceInfo

func (tps *TestPieceStore) ReturnErrorFromGetPieceInfo(err error)

func (*TestPieceStore) Start

func (tps *TestPieceStore) Start(ctx context.Context) error

func (*TestPieceStore) StubCID

func (tps *TestPieceStore) StubCID(c cid.Cid, cidInfo piecestore.CIDInfo)

StubCID creates a return value for the given CID without expecting it to be called

func (*TestPieceStore) StubPiece

func (tps *TestPieceStore) StubPiece(pieceCid cid.Cid, pieceInfo piecestore.PieceInfo)

StubPiece creates a return value for the given piece cid without expecting it to be called

func (*TestPieceStore) VerifyExpectations

func (tps *TestPieceStore) VerifyExpectations(t *testing.T)

VerifyExpectations verifies that the piecestore was queried in the expected ways

type TestPieceStoreParams

type TestPieceStoreParams struct {
	AddDealForPieceError        error
	AddPieceBlockLocationsError error
	GetPieceInfoError           error
}

TestPieceStoreParams sets parameters for a piece store

type TestQueryStreamParams

type TestQueryStreamParams struct {
	PeerID     peer.ID
	Reader     QueryReader
	RespReader QueryResponseReader
	RespWriter QueryResponseWriter
	Writer     QueryWriter
}

TestQueryStreamParams are parameters used to setup a TestRetrievalQueryStream. All parameters except the peer ID are optional.

type TestRetrievalBlockstoreAccessor

type TestRetrievalBlockstoreAccessor struct {
	Blockstore bstore.Blockstore
}

func NewTestRetrievalBlockstoreAccessor

func NewTestRetrievalBlockstoreAccessor() *TestRetrievalBlockstoreAccessor

func (*TestRetrievalBlockstoreAccessor) Done

func (*TestRetrievalBlockstoreAccessor) Get

type TestRetrievalDealStream

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

TestRetrievalDealStream is a retrieval deal stream with predefined stubbed behavior.

type TestRetrievalMarketNetwork

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

TestRetrievalMarketNetwork is a test network that has stubbed behavior for testing the retrieval market implementation

func NewTestRetrievalMarketNetwork

func NewTestRetrievalMarketNetwork(params TestNetworkParams) *TestRetrievalMarketNetwork

NewTestRetrievalMarketNetwork returns a new TestRetrievalMarketNetwork with the behavior specified by the paramaters, or default behaviors if not specified.

func (*TestRetrievalMarketNetwork) AddAddrs

func (trmn *TestRetrievalMarketNetwork) AddAddrs(peer.ID, []ma.Multiaddr)

AddAddrs does nothing in test

func (*TestRetrievalMarketNetwork) ID

func (trmn *TestRetrievalMarketNetwork) ID() peer.ID

ID returns the peer id of this host (empty peer ID in test)

func (*TestRetrievalMarketNetwork) NewQueryStream

func (trmn *TestRetrievalMarketNetwork) NewQueryStream(id peer.ID) (rmnet.RetrievalQueryStream, error)

NewDealStatusStream returns a query stream. Note this always returns the same stream. This is fine for testing for now.

func (*TestRetrievalMarketNetwork) ReceiveQueryStream

func (trmn *TestRetrievalMarketNetwork) ReceiveQueryStream(qs rmnet.RetrievalQueryStream)

ReceiveQueryStream simulates receiving a query stream

func (*TestRetrievalMarketNetwork) SetDelegate

SetDelegate sets the market receiver

func (*TestRetrievalMarketNetwork) StopHandlingRequests

func (trmn *TestRetrievalMarketNetwork) StopHandlingRequests() error

StopHandlingRequests sets receiver to nil

type TestRetrievalQueryStream

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

TestRetrievalQueryStream is a retrieval query stream with predefined stubbed behavior.

func NewTestRetrievalQueryStream

func NewTestRetrievalQueryStream(params TestQueryStreamParams) *TestRetrievalQueryStream

NewTestRetrievalQueryStream returns a new TestRetrievalQueryStream with the behavior specified by the paramaters, or default behaviors if not specified.

func (*TestRetrievalQueryStream) Close

func (trqs *TestRetrievalQueryStream) Close() error

Close closes the stream (does nothing for test).

func (*TestRetrievalQueryStream) ReadQuery

func (trqs *TestRetrievalQueryStream) ReadQuery() (rm.Query, error)

ReadDealStatusRequest calls the mocked query reader.

func (*TestRetrievalQueryStream) ReadQueryResponse

func (trqs *TestRetrievalQueryStream) ReadQueryResponse() (rm.QueryResponse, error)

ReadDealStatusResponse calls the mocked query response reader.

func (*TestRetrievalQueryStream) RemotePeer

func (trqs *TestRetrievalQueryStream) RemotePeer() peer.ID

func (*TestRetrievalQueryStream) SetRemotePeer

func (trqs *TestRetrievalQueryStream) SetRemotePeer(rp peer.ID)

func (*TestRetrievalQueryStream) WriteQuery

func (trqs *TestRetrievalQueryStream) WriteQuery(newQuery rm.Query) error

WriteDealStatusRequest calls the mocked query writer.

func (*TestRetrievalQueryStream) WriteQueryResponse

func (trqs *TestRetrievalQueryStream) WriteQueryResponse(newResp rm.QueryResponse) error

WriteDealStatusResponse calls the mocked query response writer.

type TestStorageBlockstoreAccessor

type TestStorageBlockstoreAccessor struct {
	Blockstore bstore.Blockstore
}

func NewTestStorageBlockstoreAccessor

func NewTestStorageBlockstoreAccessor() *TestStorageBlockstoreAccessor

func (*TestStorageBlockstoreAccessor) Done

func (*TestStorageBlockstoreAccessor) Get

type TestStorageDealStream

type TestStorageDealStream struct {
	CloseCount int
	CloseError error
	// contains filtered or unexported fields
}

TestStorageDealStream is a retrieval deal stream with predefined stubbed behavior.

func NewTestStorageDealStream

func NewTestStorageDealStream(params TestStorageDealStreamParams) *TestStorageDealStream

NewTestStorageDealStream returns a new TestStorageDealStream with the behavior specified by the paramaters, or default behaviors if not specified.

func (*TestStorageDealStream) Close

func (tsds *TestStorageDealStream) Close() error

Close closes the stream (does nothing for mocked stream)

func (*TestStorageDealStream) ReadDealProposal

func (tsds *TestStorageDealStream) ReadDealProposal() (smnet.Proposal, error)

ReadDealProposal calls the mocked deal proposal reader function.

func (*TestStorageDealStream) ReadDealResponse

func (tsds *TestStorageDealStream) ReadDealResponse() (smnet.SignedResponse, []byte, error)

ReadDealResponse calls the mocked deal response reader function.

func (TestStorageDealStream) RemotePeer

func (tsds TestStorageDealStream) RemotePeer() peer.ID

RemotePeer returns the other peer

func (*TestStorageDealStream) WriteDealProposal

func (tsds *TestStorageDealStream) WriteDealProposal(dealProposal smnet.Proposal) error

WriteDealProposal calls the mocked deal proposal writer function.

func (*TestStorageDealStream) WriteDealResponse

func (tsds *TestStorageDealStream) WriteDealResponse(dealResponse smnet.SignedResponse, resigningFunc smnet.ResigningFunc) error

WriteDealResponse calls the mocked deal response writer function.

type TestStorageDealStreamParams

type TestStorageDealStreamParams struct {
	PeerID         peer.ID
	ProposalReader StorageDealProposalReader
	ProposalWriter StorageDealProposalWriter
	ResponseReader StorageDealResponseReader
	ResponseWriter StorageDealResponseWriter
}

TestStorageDealStreamParams are parameters used to setup a TestStorageDealStream. All parameters except the peer ID are optional.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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