shared_testutil

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0, MIT Imports: 64 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 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 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 MakeTestDealPayment added in v1.2.5

func MakeTestDealPayment() retrievalmarket.DealPayment

MakeTestDealPayment generates a valid, random DealPayment

func MakeTestDealProposal

func MakeTestDealProposal() retrievalmarket.DealProposal

MakeTestDealProposal generates a valid, random DealProposal

func MakeTestDealResponse added in v1.2.5

func MakeTestDealResponse() retrievalmarket.DealResponse

MakeTestDealResponse generates a valid, random DealResponse

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 MakeTestRetrievalProviderDeal added in v1.2.5

func MakeTestRetrievalProviderDeal(status retrievalmarket.DealStatus) *retrievalmarket.ProviderDealState

MakeTestRetrievalProviderDeal returns a random valid retrieval provider deal

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 NewTestChannel

func NewTestChannel(params TestChannelParams) datatransfer.ChannelState

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

func NewTestRetrievalQueryStream

func NewTestRetrievalQueryStream(params TestQueryStreamParams) rmnet.RetrievalQueryStream

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

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 TestVoucherEquality

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

TestVoucherEquality verifies that two vouchers are equal to one another

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 FakeDTType

type FakeDTType struct{}

FakeDTType is a fake voucher type

func (FakeDTType) Type

Type returns an identifier

type FakeDTValidator

type FakeDTValidator struct{}

func (*FakeDTValidator) ValidatePull

func (v *FakeDTValidator) ValidatePull(receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.VoucherResult, error)

func (*FakeDTValidator) ValidatePush

func (v *FakeDTValidator) ValidatePush(sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.VoucherResult, error)

type Libp2pTestData

type Libp2pTestData struct {
	Ctx                     context.Context
	Ds1                     datastore.Batching
	Ds2                     datastore.Batching
	DTStoredCounter1        *storedcounter.StoredCounter
	DTStoredCounter2        *storedcounter.StoredCounter
	RetrievalStoredCounter1 *storedcounter.StoredCounter
	RetrievalStoredCounter2 *storedcounter.StoredCounter
	Bs1                     bstore.Blockstore
	Bs2                     bstore.Blockstore
	MultiStore1             *multistore.MultiStore
	MultiStore2             *multistore.MultiStore
	DagService1             ipldformat.DAGService
	DagService2             ipldformat.DAGService
	DTNet1                  dtnet.DataTransferNetwork
	DTNet2                  dtnet.DataTransferNetwork
	DTStore1                datastore.Batching
	DTStore2                datastore.Batching
	DTTmpDir1               string
	DTTmpDir2               string
	Loader1                 ipld.Loader
	Loader2                 ipld.Loader
	Storer1                 ipld.Storer
	Storer2                 ipld.Storer
	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, fixturesPath string, useSecondNode bool) ipld.Link

LoadUnixFSFile injects the fixture `filename` 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, fixturesPath string, useSecondNode bool) (ipld.Link, multistore.StoreID)

LoadUnixFSFileToStore injects the fixture `filename` from the fixtures directory, creating a new multistore in the process. If useSecondNode is true, fixture is injected to the second node. Otherwise the first node gets it

func (*Libp2pTestData) VerifyFileTransferred

func (ltd *Libp2pTestData) VerifyFileTransferred(t *testing.T, link ipld.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 ipld.Link, storeID multistore.StoreID, useSecondNode bool, readLen uint64)

VerifyFileTransferredIntoStore checks that the fixture file was sent from one node to the other, into the store specified by storeID

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 RegisteredRevalidator

type RegisteredRevalidator struct {
	VoucherType datatransfer.Voucher
	Revalidator datatransfer.Revalidator
}

RegisteredRevalidator records a voucher type that was registered for revalidations

type RegisteredTransportConfigurer

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

RegisteredTransportConfigurer records transport configurer registered for a voucher type

type RegisteredVoucherType

type RegisteredVoucherType struct {
	VoucherType datatransfer.Voucher
	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) ChannelID

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

ChannelID returns the channel id for this channel

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.Voucher

LastVoucher returns the last voucher sent on the channel

func (*TestChannel) LastVoucherResult

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

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) 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) 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) Recipient

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

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

func (*TestChannel) Selector

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

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

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) 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.Voucher

Voucher returns the voucher for this data transfer

func (*TestChannel) VoucherResults

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

VoucherResults are results of vouchers sent on the channel

func (*TestChannel) Vouchers

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

Vouchers returns all vouchers sent on this channel

type TestChannelParams

type TestChannelParams struct {
	TransferID     datatransfer.TransferID
	BaseCID        cid.Cid
	Selector       ipld.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.Voucher
	VoucherResults []datatransfer.VoucherResult
	ReceivedCids   []cid.Cid
}

TestChannelParams are params for a new test data transfer channel

type TestDataTransfer

type TestDataTransfer struct {
	RegisteredRevalidators         []RegisteredRevalidator
	RegisteredVoucherTypes         []RegisteredVoucherType
	RegisteredVoucherResultTypes   []datatransfer.VoucherResult
	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.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, error)

OpenPullDataChannel does nothing

func (*TestDataTransfer) OpenPushDataChannel

func (tdt *TestDataTransfer) OpenPushDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (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) RegisterRevalidator

func (tdt *TestDataTransfer) RegisterRevalidator(voucherType datatransfer.Voucher, revalidator datatransfer.Revalidator) error

RegisterRevalidator records the registred revalidator type

func (*TestDataTransfer) RegisterTransportConfigurer

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

RegisterTransportConfigurer records the registered transport configurer

func (*TestDataTransfer) RegisterVoucherResultType

func (tdt *TestDataTransfer) RegisterVoucherResultType(resultType datatransfer.VoucherResult) error

RegisterVoucherResultType records the registered result type

func (*TestDataTransfer) RegisterVoucherType

func (tdt *TestDataTransfer) RegisterVoucherType(voucherType datatransfer.Voucher, 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

func (tdt *TestDataTransfer) SendVoucher(ctx context.Context, chid datatransfer.ChannelID, voucher datatransfer.Voucher) error

SendVoucher 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

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[ipld.Link][]byte
	LeafAlpha         ipld.Node
	LeafAlphaLnk      ipld.Link
	LeafAlphaBlock    blocks.Block
	LeafBeta          ipld.Node
	LeafBetaLnk       ipld.Link
	LeafBetaBlock     blocks.Block
	MiddleMapNode     ipld.Node
	MiddleMapNodeLnk  ipld.Link
	MiddleMapBlock    blocks.Block
	MiddleListNode    ipld.Node
	MiddleListNodeLnk ipld.Link
	MiddleListBlock   blocks.Block
	RootNode          ipld.Node
	RootNodeLnk       ipld.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(c cid.Cid) (blocks.Block, error)

Get makes a test tree behave like a block read store

func (TestIPLDTree) Loader

func (tt TestIPLDTree) Loader(lnk ipld.Link, lnkCtx ipld.LinkContext) (io.Reader, error)

Loader is an IPLD comptabile loader for the "storage" part of the tree

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, 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) 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 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 (*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) 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 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.

Jump to

Keyboard shortcuts

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