shared_testutil

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0, MIT Imports: 58 Imported by: 5

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 added in v0.3.0

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

AssertDealState asserts equality of StorageDealStatus but with better error messaging

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 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 FailNewDealStream

func FailNewDealStream(peer.ID) (rmnet.RetrievalDealStream, error)

FailNewDealStream 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, 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 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 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

func MakeTestDealPayment() retrievalmarket.DealPayment

MakeTestDealPayment generates a valid, random DealPayment

func MakeTestDealProposal

func MakeTestDealProposal() retrievalmarket.DealProposal

MakeTestDealProposal generates a valid, random DealProposal

func MakeTestDealResponse

func MakeTestDealResponse() retrievalmarket.DealResponse

MakeTestDealProposal generates a valid, random DealResponse

func MakeTestDealStatusRequest added in v0.3.2

func MakeTestDealStatusRequest() smnet.DealStatusRequest

MakeTestDealStatusRequest generates a request to get a provider's query

func MakeTestDealStatusResponse added in v0.3.2

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 NewTestRetrievalDealStream

func NewTestRetrievalDealStream(params TestDealStreamParams) rmnet.RetrievalDealStream

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

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 TestVoucherEquality

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

TestVoucherEquality verifies that two vouchers are equal to one another

func TrivialDealPaymentReader

func TrivialDealPaymentReader() (rm.DealPayment, error)

TrivialDealPaymentReader succeeds trivially, returning an empty deal payment.

func TrivialDealPaymentWriter

func TrivialDealPaymentWriter(rm.DealPayment) error

TrivialDealPaymentWriter succeeds trivially, returning no error.

func TrivialDealProposalReader

func TrivialDealProposalReader() (rm.DealProposal, error)

TrivialDealProposalReader succeeds trivially, returning an empty proposal.

func TrivialDealProposalWriter

func TrivialDealProposalWriter(rm.DealProposal) error

TrivialDealProposalWriter succeeds trivially, returning no error.

func TrivialDealResponseReader

func TrivialDealResponseReader() (rm.DealResponse, error)

TrivialDealResponseReader succeeds trivially, returning an empty deal response.

func TrivialDealResponseWriter

func TrivialDealResponseWriter(rm.DealResponse) error

TrivialDealResponseWriter succeeds trivially, returning no error.

func TrivialNewDealStream

func TrivialNewDealStream(p peer.ID) (rmnet.RetrievalDealStream, error)

TrivialNewDealStream succeeds trivially, returning an empty deal stream.

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, error)

TrivialStorageDealResponseReader succeeds trivially, returning an empty deal response.

func TrivialStorageDealResponseWriter

func TrivialStorageDealResponseWriter(smnet.SignedResponse) 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 DealStreamBuilder

type DealStreamBuilder func(peer.ID) (rmnet.RetrievalDealStream, error)

DealStreamBuilder if a function that builds retrieval deal streams

type FakeDTValidator added in v0.3.0

type FakeDTValidator struct{}

func (*FakeDTValidator) ValidatePull added in v0.3.0

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

func (*FakeDTValidator) ValidatePush added in v0.3.0

func (v *FakeDTValidator) ValidatePush(sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) 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
	DagService1             ipldformat.DAGService
	DagService2             ipldformat.DAGService
	GraphSync1              graphsync.GraphExchange
	GraphSync2              graphsync.GraphExchange
	Loader1                 ipld.Loader
	Loader2                 ipld.Loader
	Storer1                 ipld.Storer
	Storer2                 ipld.Storer
	Host1                   host.Host
	Host2                   host.Host
	OrigBytes               []byte
}

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

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 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, 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) error

StorageDealResponseWriter is a function to mock writing deal responses.

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 {
	DealStreamBuilder  DealStreamBuilder
	QueryStreamBuilder QueryStreamBuilder
	Receiver           rmnet.RetrievalReceiver
}

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

type TestPeerResolver added in v0.2.1

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

TestPeerResolver provides a fake retrievalmarket PeerResolver

func (TestPeerResolver) GetPeers added in v0.2.1

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

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

func (TestRetrievalDealStream) Close

func (trds TestRetrievalDealStream) Close() error

Close closes the stream (does nothing for mocked stream)

func (*TestRetrievalDealStream) ReadDealPayment

func (trds *TestRetrievalDealStream) ReadDealPayment() (rm.DealPayment, error)

ReadDealPayment calls the mocked deal payment reader function.

func (*TestRetrievalDealStream) ReadDealProposal

func (trds *TestRetrievalDealStream) ReadDealProposal() (rm.DealProposal, error)

ReadDealProposal calls the mocked deal proposal reader function.

func (*TestRetrievalDealStream) ReadDealResponse

func (trds *TestRetrievalDealStream) ReadDealResponse() (rm.DealResponse, error)

ReadDealResponse calls the mocked deal response reader function.

func (TestRetrievalDealStream) Receiver

func (trds TestRetrievalDealStream) Receiver() peer.ID

Receiver returns the other peer

func (*TestRetrievalDealStream) WriteDealPayment

func (trds *TestRetrievalDealStream) WriteDealPayment(dealPayment rm.DealPayment) error

WriteDealPayment calls the mocked deal payment writer function.

func (*TestRetrievalDealStream) WriteDealProposal

func (trds *TestRetrievalDealStream) WriteDealProposal(dealProposal rm.DealProposal) error

WriteDealProposal calls the mocked deal proposal writer function.

func (*TestRetrievalDealStream) WriteDealResponse

func (trds *TestRetrievalDealStream) WriteDealResponse(dealResponse rm.DealResponse) error

WriteDealResponse calls the mocked deal response writer function.

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

func (trmn *TestRetrievalMarketNetwork) NewDealStream(id peer.ID) (rmnet.RetrievalDealStream, error)

NewDealStream returns a deal stream Note this always returns the same stream. This is fine for testing for now.

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

func (trmn *TestRetrievalMarketNetwork) ReceiveDealStream(ds rmnet.RetrievalDealStream)

ReceiveDealStream simulates receiving a deal stream

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 {
	// 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) AssertConnectionTagged added in v0.2.3

func (tsds TestStorageDealStream) AssertConnectionTagged(t *testing.T, identifier string)

AssertConnectionTagged verifies a connection was tagged with the given identifier

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, 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) TagProtectedConnection added in v0.2.3

func (tsds TestStorageDealStream) TagProtectedConnection(identifier string)

TagProtectedConnection preserves this connection as higher priority than others

func (TestStorageDealStream) UntagProtectedConnection added in v0.2.3

func (tsds TestStorageDealStream) UntagProtectedConnection(identifier string)

UntagProtectedConnection removes the given tag on this connection, increasing the likelyhood it will be cleaned up

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