testutil

package
v1.7.3 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: 54 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSelector

func AllSelector() ipld.Node

AllSelector just returns a new instance of a "whole dag selector"

func AssertEqualFakeDTVoucher

func AssertEqualFakeDTVoucher(t *testing.T, expectedRequest datatransfer.Request, request datatransfer.Request)

AssertEqualFakeDTVoucher asserts that two requests have the same fake data transfer voucher

func AssertEqualFakeDTVoucherResult

func AssertEqualFakeDTVoucherResult(t *testing.T, expectedResponse datatransfer.Response, response datatransfer.Response)

AssertEqualFakeDTVoucherResult asserts that two responses have the same fake data transfer voucher result

func AssertEqualSelector

func AssertEqualSelector(t *testing.T, expectedRequest datatransfer.Request, request datatransfer.Request)

AssertEqualSelector asserts two requests have the same valid selector

func AssertFakeDTVoucher

func AssertFakeDTVoucher(t *testing.T, request datatransfer.Request, expected *FakeDTType)

AssertFakeDTVoucher asserts that a data transfer requests contains the expected fake data transfer voucher type

func AssertFakeDTVoucherResult

func AssertFakeDTVoucherResult(t *testing.T, response datatransfer.Response, expected *FakeDTType)

AssertFakeDTVoucherResult asserts that a data transfer response contains the expected fake data transfer voucher result type

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

func LoadUnixFSFile(ctx context.Context, t *testing.T, dagService ipldformat.DAGService, fileName string) (ipld.Link, []byte)

LoadUnixFSFile loads a fixtures file into the given DAG Service, returning an ipld.Link for the file and the original file bytes

func NewDTRequest

func NewDTRequest(t *testing.T, transferID datatransfer.TransferID) datatransfer.Request

NewDTRequest makes a new DT Request message

func NewDTResponse

func NewDTResponse(t *testing.T, transferID datatransfer.TransferID) datatransfer.Response

NewDTResponse makes a new DT Request message

func NewFakeBlockData

func NewFakeBlockData() graphsync.BlockData

NewFakeBlockData returns a fake block that matches the block data interface

func NewFakeRequest

func NewFakeRequest(id graphsync.RequestID, extensions map[graphsync.ExtensionName][]byte) graphsync.RequestData

NewFakeRequest returns a fake request that matches the request data interface

func NewFakeResponse

func NewFakeResponse(id graphsync.RequestID, extensions map[graphsync.ExtensionName][]byte, status graphsync.ResponseStatusCode) graphsync.ResponseData

NewFakeResponse returns a fake response that matches the response data interface

func RandomBytes

func RandomBytes(n int64) []byte

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

func StartAndWaitForReady

func StartAndWaitForReady(ctx context.Context, t *testing.T, manager datatransfer.Manager)

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

func VerifyHasFile

func VerifyHasFile(ctx context.Context, t *testing.T, dagService ipldformat.DAGService, link ipld.Link, fileBytes []byte)

VerifyHasFile verifies the presence of the given file with the given ipld.Link and file contents (fileBytes) exists in the given blockstore identified by dagService

Types

type CancelResponse

type CancelResponse struct {
	P         peer.ID
	RequestID graphsync.RequestID
}

type CustomizedTransfer

type CustomizedTransfer struct {
	ChannelID datatransfer.ChannelID
	Voucher   datatransfer.Voucher
}

CustomizedTransfer is just a way to record calls made to transport configurer

type FakeDTType

type FakeDTType struct {
	Data string
}

FakeDTType simple fake type for using with registries

func NewFakeDTType

func NewFakeDTType() *FakeDTType

NewFakeDTType returns a fake dt type with random data

func (*FakeDTType) MarshalCBOR

func (t *FakeDTType) MarshalCBOR(w io.Writer) error

func (FakeDTType) Type

Type satisfies registry.Entry

func (*FakeDTType) UnmarshalCBOR

func (t *FakeDTType) UnmarshalCBOR(r io.Reader) error

type FakeGraphSync

type FakeGraphSync struct {
	OutgoingRequestHook        graphsync.OnOutgoingRequestHook
	IncomingBlockHook          graphsync.OnIncomingBlockHook
	OutgoingBlockHook          graphsync.OnOutgoingBlockHook
	IncomingRequestHook        graphsync.OnIncomingRequestHook
	CompletedResponseListener  graphsync.OnResponseCompletedListener
	RequestUpdatedHook         graphsync.OnRequestUpdatedHook
	IncomingResponseHook       graphsync.OnIncomingResponseHook
	RequestorCancelledListener graphsync.OnRequestorCancelledListener
	BlockSentListener          graphsync.OnBlockSentListener
	NetworkErrorListener       graphsync.OnNetworkErrorListener
	// contains filtered or unexported fields
}

FakeGraphSync implements a GraphExchange but does nothing

func NewFakeGraphSync

func NewFakeGraphSync() *FakeGraphSync

NewFakeGraphSync returns a new fake graphsync implementation

func (*FakeGraphSync) AssertCancelResponseReceived

func (fgs *FakeGraphSync) AssertCancelResponseReceived(ctx context.Context, t *testing.T) CancelResponse

AssertCancelResponseReceived asserts a response was cancelled before the context closes (and returns said response)

func (*FakeGraphSync) AssertDoesNotHavePersistenceOption

func (fgs *FakeGraphSync) AssertDoesNotHavePersistenceOption(t *testing.T, name string)

AssertDoesNotHavePersistenceOption verifies that a persistence option is not registered

func (*FakeGraphSync) AssertHasPersistenceOption

func (fgs *FakeGraphSync) AssertHasPersistenceOption(t *testing.T, name string) PersistenceOption

AssertHasPersistenceOption verifies that a persistence option was registered

func (*FakeGraphSync) AssertNoCancelResponseReceived

func (fgs *FakeGraphSync) AssertNoCancelResponseReceived(t *testing.T)

AssertNoCancelResponseReceived asserts that no responses were cancelled by thiss graphsync implementation

func (*FakeGraphSync) AssertNoPauseRequestReceived

func (fgs *FakeGraphSync) AssertNoPauseRequestReceived(t *testing.T)

AssertNoPauseRequestReceived asserts that no pause requests should ahve been received by this graphsync implementation

func (*FakeGraphSync) AssertNoPauseResponseReceived

func (fgs *FakeGraphSync) AssertNoPauseResponseReceived(t *testing.T)

AssertNoPauseResponseReceived asserts that no pause requests should ahve been received by this graphsync implementation

func (*FakeGraphSync) AssertNoRequestReceived

func (fgs *FakeGraphSync) AssertNoRequestReceived(t *testing.T)

AssertNoRequestReceived asserts that no requests should ahve been received by this graphsync implementation

func (*FakeGraphSync) AssertNoResumeRequestReceived

func (fgs *FakeGraphSync) AssertNoResumeRequestReceived(t *testing.T)

AssertNoResumeRequestReceived asserts that no resume requests should ahve been received by this graphsync implementation

func (*FakeGraphSync) AssertNoResumeResponseReceived

func (fgs *FakeGraphSync) AssertNoResumeResponseReceived(t *testing.T)

AssertNoResumeResponseReceived asserts that no resume requests should ahve been received by this graphsync implementation

func (*FakeGraphSync) AssertPauseRequestReceived

func (fgs *FakeGraphSync) AssertPauseRequestReceived(ctx context.Context, t *testing.T) PauseRequest

AssertPauseRequestReceived asserts a pause request should be received before the context closes (and returns said request)

func (*FakeGraphSync) AssertPauseResponseReceived

func (fgs *FakeGraphSync) AssertPauseResponseReceived(ctx context.Context, t *testing.T) PauseResponse

AssertPauseResponseReceived asserts a pause request should be received before the context closes (and returns said request)

func (*FakeGraphSync) AssertRequestReceived

func (fgs *FakeGraphSync) AssertRequestReceived(ctx context.Context, t *testing.T) ReceivedGraphSyncRequest

AssertRequestReceived asserts a request should be received before the context closes (and returns said request)

func (*FakeGraphSync) AssertResumeRequestReceived

func (fgs *FakeGraphSync) AssertResumeRequestReceived(ctx context.Context, t *testing.T) ResumeRequest

AssertResumeRequestReceived asserts a resume request should be received before the context closes (and returns said request)

func (*FakeGraphSync) AssertResumeResponseReceived

func (fgs *FakeGraphSync) AssertResumeResponseReceived(ctx context.Context, t *testing.T) ResumeResponse

AssertResumeResponseReceived asserts a resume request should be received before the context closes (and returns said request)

func (*FakeGraphSync) CancelResponse

func (fgs *FakeGraphSync) CancelResponse(p peer.ID, requestID graphsync.RequestID) error

CancelResponse cancels a response in progress

func (*FakeGraphSync) LeaveRequestsOpen

func (fgs *FakeGraphSync) LeaveRequestsOpen()

func (*FakeGraphSync) PauseRequest

func (fgs *FakeGraphSync) PauseRequest(requestID graphsync.RequestID) error

PauseRequest unpauses a response that was paused in a block hook based on peer ID and request ID

func (*FakeGraphSync) PauseResponse

func (fgs *FakeGraphSync) PauseResponse(p peer.ID, requestID graphsync.RequestID) error

PauseResponse pauses a response based on peer ID and request ID

func (*FakeGraphSync) RegisterBlockSentListener

func (fgs *FakeGraphSync) RegisterBlockSentListener(listener graphsync.OnBlockSentListener) graphsync.UnregisterHookFunc

RegisterBlockSentListener adds a listener on the responder as blocks go out

func (*FakeGraphSync) RegisterCompletedResponseListener

func (fgs *FakeGraphSync) RegisterCompletedResponseListener(listener graphsync.OnResponseCompletedListener) graphsync.UnregisterHookFunc

RegisterCompletedResponseListener adds a listener on the responder for completed responses

func (*FakeGraphSync) RegisterIncomingBlockHook

func (fgs *FakeGraphSync) RegisterIncomingBlockHook(hook graphsync.OnIncomingBlockHook) graphsync.UnregisterHookFunc

RegisterIncomingBlockHook adds a hook that runs every time a block is received by the requestor

func (*FakeGraphSync) RegisterIncomingRequestHook

func (fgs *FakeGraphSync) RegisterIncomingRequestHook(hook graphsync.OnIncomingRequestHook) graphsync.UnregisterHookFunc

RegisterIncomingRequestHook adds a hook that runs when a request is received

func (*FakeGraphSync) RegisterIncomingResponseHook

func (fgs *FakeGraphSync) RegisterIncomingResponseHook(hook graphsync.OnIncomingResponseHook) graphsync.UnregisterHookFunc

RegisterIncomingResponseHook adds a hook that runs when a response is received

func (*FakeGraphSync) RegisterNetworkErrorListener

func (fgs *FakeGraphSync) RegisterNetworkErrorListener(listener graphsync.OnNetworkErrorListener) graphsync.UnregisterHookFunc

RegisterNetworkErrorListener adds a listener on the responder as blocks go out

func (*FakeGraphSync) RegisterOutgoingBlockHook

func (fgs *FakeGraphSync) RegisterOutgoingBlockHook(hook graphsync.OnOutgoingBlockHook) graphsync.UnregisterHookFunc

RegisterOutgoingBlockHook adds a hook that runs every time a block is sent from a responder

func (*FakeGraphSync) RegisterOutgoingRequestHook

func (fgs *FakeGraphSync) RegisterOutgoingRequestHook(hook graphsync.OnOutgoingRequestHook) graphsync.UnregisterHookFunc

RegisterOutgoingRequestHook adds a hook that runs immediately prior to sending a new request

func (*FakeGraphSync) RegisterPersistenceOption

func (fgs *FakeGraphSync) RegisterPersistenceOption(name string, loader ipld.Loader, storer ipld.Storer) error

RegisterPersistenceOption registers an alternate loader/storer combo that can be substituted for the default

func (*FakeGraphSync) RegisterRequestUpdatedHook

func (fgs *FakeGraphSync) RegisterRequestUpdatedHook(hook graphsync.OnRequestUpdatedHook) graphsync.UnregisterHookFunc

RegisterRequestUpdatedHook adds a hook that runs every time an update to a request is received

func (*FakeGraphSync) RegisterRequestorCancelledListener

func (fgs *FakeGraphSync) RegisterRequestorCancelledListener(listener graphsync.OnRequestorCancelledListener) graphsync.UnregisterHookFunc

RegisterRequestorCancelledListener adds a listener on the responder for requests cancelled by the requestor

func (*FakeGraphSync) Request

func (fgs *FakeGraphSync) Request(ctx context.Context, p peer.ID, root ipld.Link, selector ipld.Node, extensions ...graphsync.ExtensionData) (<-chan graphsync.ResponseProgress, <-chan error)

Request initiates a new GraphSync request to the given peer using the given selector spec.

func (*FakeGraphSync) UnpauseRequest

func (fgs *FakeGraphSync) UnpauseRequest(requestID graphsync.RequestID, extensions ...graphsync.ExtensionData) error

UnpauseRequest unpauses a request that was paused in a block hook based on request ID

func (*FakeGraphSync) UnpauseResponse

func (fgs *FakeGraphSync) UnpauseResponse(p peer.ID, requestID graphsync.RequestID, extensions ...graphsync.ExtensionData) error

UnpauseResponse unpauses a response that was paused in a block hook based on peer ID and request ID

func (*FakeGraphSync) UnregisterPersistenceOption

func (fgs *FakeGraphSync) UnregisterPersistenceOption(name string) error

UnregisterPersistenceOption unregisters an existing loader/storer combo

type FakeIncomingBlockHookActions

type FakeIncomingBlockHookActions struct {
	TerminationError error
	SentExtensions   []graphsync.ExtensionData
	Paused           bool
}

func (*FakeIncomingBlockHookActions) PauseRequest

func (fa *FakeIncomingBlockHookActions) PauseRequest()

func (*FakeIncomingBlockHookActions) TerminateWithError

func (fa *FakeIncomingBlockHookActions) TerminateWithError(err error)

func (*FakeIncomingBlockHookActions) UpdateRequestWithExtensions

func (fa *FakeIncomingBlockHookActions) UpdateRequestWithExtensions(extensions ...graphsync.ExtensionData)

type FakeIncomingRequestHookActions

type FakeIncomingRequestHookActions struct {
	PersistenceOption string
	TerminationError  error
	Validated         bool
	SentExtensions    []graphsync.ExtensionData
	Paused            bool
}

func (*FakeIncomingRequestHookActions) PauseResponse

func (fa *FakeIncomingRequestHookActions) PauseResponse()

func (*FakeIncomingRequestHookActions) SendExtensionData

func (fa *FakeIncomingRequestHookActions) SendExtensionData(ext graphsync.ExtensionData)

func (*FakeIncomingRequestHookActions) TerminateWithError

func (fa *FakeIncomingRequestHookActions) TerminateWithError(err error)

func (*FakeIncomingRequestHookActions) UseLinkTargetNodePrototypeChooser

func (fa *FakeIncomingRequestHookActions) UseLinkTargetNodePrototypeChooser(_ traversal.LinkTargetNodePrototypeChooser)

func (*FakeIncomingRequestHookActions) UsePersistenceOption

func (fa *FakeIncomingRequestHookActions) UsePersistenceOption(name string)

func (*FakeIncomingRequestHookActions) ValidateRequest

func (fa *FakeIncomingRequestHookActions) ValidateRequest()

type FakeIncomingResponseHookActions

type FakeIncomingResponseHookActions struct {
	TerminationError error
	SentExtensions   []graphsync.ExtensionData
}

func (*FakeIncomingResponseHookActions) TerminateWithError

func (fa *FakeIncomingResponseHookActions) TerminateWithError(err error)

func (*FakeIncomingResponseHookActions) UpdateRequestWithExtensions

func (fa *FakeIncomingResponseHookActions) UpdateRequestWithExtensions(extensions ...graphsync.ExtensionData)

type FakeNetwork

type FakeNetwork struct {
	PeerID       peer.ID
	SentMessages []FakeSentMessage
	Delegate     network.Receiver
}

FakeNetwork is a network that satisfies the DataTransferNetwork interface but does not actually do anything

func NewFakeNetwork

func NewFakeNetwork(id peer.ID) *FakeNetwork

NewFakeNetwork returns a new fake data transfer network instance

func (*FakeNetwork) ConnectTo

func (fn *FakeNetwork) ConnectTo(_ context.Context, _ peer.ID) error

ConnectTo establishes a connection to the given peer

func (*FakeNetwork) ID

func (fn *FakeNetwork) ID() peer.ID

ID returns a stubbed id for host of this network

func (*FakeNetwork) Protect

func (fn *FakeNetwork) Protect(id peer.ID, tag string)

Protect does nothing on the fake network

func (*FakeNetwork) SendMessage

func (fn *FakeNetwork) SendMessage(ctx context.Context, p peer.ID, m datatransfer.Message) error

SendMessage sends a GraphSync message to a peer.

func (*FakeNetwork) SetDelegate

func (fn *FakeNetwork) SetDelegate(receiver network.Receiver)

SetDelegate registers the Reciver to handle messages received from the network.

func (*FakeNetwork) Unprotect

func (fn *FakeNetwork) Unprotect(id peer.ID, tag string) bool

Unprotect does nothing on the fake network

type FakeOutgoingBlockHookActions

type FakeOutgoingBlockHookActions struct {
	TerminationError error
	SentExtensions   []graphsync.ExtensionData
	Paused           bool
}

func (*FakeOutgoingBlockHookActions) PauseResponse

func (fa *FakeOutgoingBlockHookActions) PauseResponse()

func (*FakeOutgoingBlockHookActions) SendExtensionData

func (fa *FakeOutgoingBlockHookActions) SendExtensionData(extension graphsync.ExtensionData)

func (*FakeOutgoingBlockHookActions) TerminateWithError

func (fa *FakeOutgoingBlockHookActions) TerminateWithError(err error)

type FakeOutgoingRequestHookActions

type FakeOutgoingRequestHookActions struct {
	PersistenceOption string
}

func (*FakeOutgoingRequestHookActions) UseLinkTargetNodePrototypeChooser

func (fa *FakeOutgoingRequestHookActions) UseLinkTargetNodePrototypeChooser(_ traversal.LinkTargetNodePrototypeChooser)

func (*FakeOutgoingRequestHookActions) UsePersistenceOption

func (fa *FakeOutgoingRequestHookActions) UsePersistenceOption(name string)

type FakeRequestUpdatedActions

type FakeRequestUpdatedActions struct {
	TerminationError error
	SentExtensions   []graphsync.ExtensionData
	Unpaused         bool
}

func (*FakeRequestUpdatedActions) SendExtensionData

func (fa *FakeRequestUpdatedActions) SendExtensionData(extension graphsync.ExtensionData)

func (*FakeRequestUpdatedActions) TerminateWithError

func (fa *FakeRequestUpdatedActions) TerminateWithError(err error)

func (*FakeRequestUpdatedActions) UnpauseResponse

func (fa *FakeRequestUpdatedActions) UnpauseResponse()

type FakeSentMessage

type FakeSentMessage struct {
	PeerID  peer.ID
	Message datatransfer.Message
}

FakeSentMessage is a recording of a message sent on the FakeNetwork

type FakeTransport

type FakeTransport struct {
	OpenedChannels      []OpenedChannel
	OpenChannelErr      error
	ClosedChannels      []datatransfer.ChannelID
	CloseChannelErr     error
	PausedChannels      []datatransfer.ChannelID
	PauseChannelErr     error
	ResumedChannels     []ResumedChannel
	ResumeChannelErr    error
	CleanedUpChannels   []datatransfer.ChannelID
	CustomizedTransfers []CustomizedTransfer
	EventHandler        datatransfer.EventsHandler
	SetEventHandlerErr  error
}

FakeTransport is a fake transport with mocked results

func NewFakeTransport

func NewFakeTransport() *FakeTransport

NewFakeTransport returns a new instance of FakeTransport

func (*FakeTransport) CleanupChannel

func (ft *FakeTransport) CleanupChannel(chid datatransfer.ChannelID)

CleanupChannel cleans up the given channel

func (*FakeTransport) CloseChannel

func (ft *FakeTransport) CloseChannel(ctx context.Context, chid datatransfer.ChannelID) error

CloseChannel closes the given channel

func (*FakeTransport) OpenChannel

func (ft *FakeTransport) OpenChannel(ctx context.Context, dataSender peer.ID, channelID datatransfer.ChannelID, root ipld.Link, stor ipld.Node, doNotSend []cid.Cid,
	msg datatransfer.Message) error

OpenChannel initiates an outgoing request for the other peer to send data to us on this channel Note: from a data transfer symantic standpoint, it doesn't matter if the request is push or pull -- OpenChannel is called by the party that is intending to receive data

func (*FakeTransport) PauseChannel

func (ft *FakeTransport) PauseChannel(ctx context.Context, chid datatransfer.ChannelID) error

PauseChannel paused the given channel ID

func (*FakeTransport) RecordCustomizedTransfer

func (ft *FakeTransport) RecordCustomizedTransfer(chid datatransfer.ChannelID, voucher datatransfer.Voucher)

func (*FakeTransport) ResumeChannel

func (ft *FakeTransport) ResumeChannel(ctx context.Context, msg datatransfer.Message, chid datatransfer.ChannelID) error

ResumeChannel resumes the given channel

func (*FakeTransport) SetEventHandler

func (ft *FakeTransport) SetEventHandler(events datatransfer.EventsHandler) error

SetEventHandler sets the handler for events on channels

func (*FakeTransport) Shutdown

func (ft *FakeTransport) Shutdown(ctx context.Context) error

type GraphsyncTestingData

type GraphsyncTestingData struct {
	Ctx            context.Context
	Mn             mocknet.Mocknet
	StoredCounter1 *storedcounter.StoredCounter
	StoredCounter2 *storedcounter.StoredCounter
	DtDs1          datastore.Batching
	DtDs2          datastore.Batching
	Bs1            bstore.Blockstore
	Bs2            bstore.Blockstore
	DagService1    ipldformat.DAGService
	DagService2    ipldformat.DAGService
	Loader1        ipld.Loader
	Loader2        ipld.Loader
	Storer1        ipld.Storer
	Storer2        ipld.Storer
	Host1          host.Host
	Host2          host.Host
	GsNet1         gsnet.GraphSyncNetwork
	GsNet2         gsnet.GraphSyncNetwork
	DtNet1         network.DataTransferNetwork
	DtNet2         network.DataTransferNetwork
	AllSelector    ipld.Node
	OrigBytes      []byte
	TempDir1       string
	TempDir2       string
	// contains filtered or unexported fields
}

GraphsyncTestingData is a test harness for testing data transfer on top of graphsync

func NewGraphsyncTestingData

func NewGraphsyncTestingData(ctx context.Context, t *testing.T, host1Protocols []protocol.ID, host2Protocols []protocol.ID) *GraphsyncTestingData

NewGraphsyncTestingData returns a new GraphsyncTestingData instance

func (*GraphsyncTestingData) LoadUnixFSFile

func (gsData *GraphsyncTestingData) LoadUnixFSFile(t *testing.T, useSecondNode bool) ipld.Link

LoadUnixFSFile loads a fixtures file we can test dag transfer with

func (*GraphsyncTestingData) SetupGSTransportHost1

func (gsData *GraphsyncTestingData) SetupGSTransportHost1() datatransfer.Transport

SetupGSTransportHost1 sets up a new grapshync transport over real graphsync on the first host

func (*GraphsyncTestingData) SetupGSTransportHost2

func (gsData *GraphsyncTestingData) SetupGSTransportHost2() datatransfer.Transport

SetupGSTransportHost2 sets up a new grapshync transport over real graphsync on the second host

func (*GraphsyncTestingData) SetupGraphsyncHost1

func (gsData *GraphsyncTestingData) SetupGraphsyncHost1() graphsync.GraphExchange

SetupGraphsyncHost1 sets up a new, real graphsync instance on top of the first host

func (*GraphsyncTestingData) SetupGraphsyncHost2

func (gsData *GraphsyncTestingData) SetupGraphsyncHost2() graphsync.GraphExchange

SetupGraphsyncHost2 sets up a new, real graphsync instance on top of the second host

func (*GraphsyncTestingData) VerifyFileTransferred

func (gsData *GraphsyncTestingData) VerifyFileTransferred(t *testing.T, link ipld.Link, useSecondNode bool)

VerifyFileTransferred verifies all of the file was transfer to the given node

type OpenedChannel

type OpenedChannel struct {
	DataSender    peer.ID
	ChannelID     datatransfer.ChannelID
	Root          ipld.Link
	Selector      ipld.Node
	DoNotSendCids []cid.Cid
	Message       datatransfer.Message
}

OpenedChannel records a call to open a channel

type PauseRequest

type PauseRequest struct {
	RequestID graphsync.RequestID
}

type PauseResponse

type PauseResponse struct {
	P         peer.ID
	RequestID graphsync.RequestID
}

type PersistenceOption

type PersistenceOption struct {
	ipld.Loader
	ipld.Storer
}

type ReceivedGraphSyncRequest

type ReceivedGraphSyncRequest struct {
	Ctx             context.Context
	P               peer.ID
	Root            ipld.Link
	Selector        ipld.Node
	Extensions      []graphsync.ExtensionData
	ResponseChan    chan graphsync.ResponseProgress
	ResponseErrChan chan error
}

ReceivedGraphSyncRequest contains data about a received graphsync request

func (ReceivedGraphSyncRequest) DTMessage

func (gsRequest ReceivedGraphSyncRequest) DTMessage(t *testing.T) datatransfer.Message

DTMessage returns the data transfer message among the graphsync extensions sent with this request

type ReceivedValidation

type ReceivedValidation struct {
	IsPull   bool
	Other    peer.ID
	Voucher  datatransfer.Voucher
	BaseCid  cid.Cid
	Selector ipld.Node
}

ReceivedValidation records a call to either ValidatePush or ValidatePull

type ResumeRequest

type ResumeRequest struct {
	RequestID  graphsync.RequestID
	Extensions []graphsync.ExtensionData
}

func (ResumeRequest) DTMessage

func (resumeRequest ResumeRequest) DTMessage(t *testing.T) datatransfer.Message

DTMessage returns the data transfer message among the graphsync extensions sent with this request

type ResumeResponse

type ResumeResponse struct {
	P          peer.ID
	RequestID  graphsync.RequestID
	Extensions []graphsync.ExtensionData
}

func (ResumeResponse) DTMessage

func (resumeResponse ResumeResponse) DTMessage(t *testing.T) datatransfer.Message

DTMessage returns the data transfer message among the graphsync extensions sent with this request

type ResumedChannel

type ResumedChannel struct {
	ChannelID datatransfer.ChannelID
	Message   datatransfer.Message
}

ResumedChannel records a call to resume a channel

type StubbedRevalidator

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

StubbedRevalidator is a revalidator that returns predictable results

func NewStubbedRevalidator

func NewStubbedRevalidator() *StubbedRevalidator

NewStubbedRevalidator returns a new instance of a stubbed revalidator

func (*StubbedRevalidator) ExpectErrorComplete

func (srv *StubbedRevalidator) ExpectErrorComplete()

ExpectErrorComplete expects OnComplete to error

func (*StubbedRevalidator) ExpectErrorPullCheck

func (srv *StubbedRevalidator) ExpectErrorPullCheck()

ExpectErrorPullCheck expects OnPullDataSent to error

func (*StubbedRevalidator) ExpectErrorPushCheck

func (srv *StubbedRevalidator) ExpectErrorPushCheck()

ExpectErrorPushCheck expects OnPushDataReceived to error

func (*StubbedRevalidator) ExpectErrorRevalidation

func (srv *StubbedRevalidator) ExpectErrorRevalidation()

ExpectErrorRevalidation expects Revalidate to error

func (*StubbedRevalidator) ExpectPauseComplete

func (srv *StubbedRevalidator) ExpectPauseComplete()

ExpectPauseComplete expects OnComplete to pause

func (*StubbedRevalidator) ExpectPausePullCheck

func (srv *StubbedRevalidator) ExpectPausePullCheck()

ExpectPausePullCheck expects OnPullDataSent to pause

func (*StubbedRevalidator) ExpectPausePushCheck

func (srv *StubbedRevalidator) ExpectPausePushCheck()

ExpectPausePushCheck expects OnPushDataReceived to pause

func (*StubbedRevalidator) ExpectPauseRevalidation

func (srv *StubbedRevalidator) ExpectPauseRevalidation()

ExpectPauseRevalidation expects Revalidate to pause

func (*StubbedRevalidator) ExpectSuccessComplete

func (srv *StubbedRevalidator) ExpectSuccessComplete()

ExpectSuccessComplete expects OnComplete to succeed

func (*StubbedRevalidator) ExpectSuccessPullCheck

func (srv *StubbedRevalidator) ExpectSuccessPullCheck()

ExpectSuccessPullCheck expects OnPullDataSent to succeed

func (*StubbedRevalidator) ExpectSuccessPushCheck

func (srv *StubbedRevalidator) ExpectSuccessPushCheck()

ExpectSuccessPushCheck expects OnPushDataReceived to succeed

func (*StubbedRevalidator) ExpectSuccessRevalidation

func (srv *StubbedRevalidator) ExpectSuccessRevalidation()

ExpectSuccessRevalidation expects Revalidate to succeed

func (*StubbedRevalidator) OnComplete

OnComplete returns a stubbed result for checking when the requests completes

func (*StubbedRevalidator) OnPullDataSent

func (srv *StubbedRevalidator) OnPullDataSent(chid datatransfer.ChannelID, additionalBytesSent uint64) (bool, datatransfer.VoucherResult, error)

OnPullDataSent returns a stubbed result for checking when pull data is sent

func (*StubbedRevalidator) OnPushDataReceived

func (srv *StubbedRevalidator) OnPushDataReceived(chid datatransfer.ChannelID, additionalBytesReceived uint64) (bool, datatransfer.VoucherResult, error)

OnPushDataReceived returns a stubbed result for checking when push data is received

func (*StubbedRevalidator) Revalidate

Revalidate returns a stubbed result for revalidating a request

func (*StubbedRevalidator) StubCheckResult

func (srv *StubbedRevalidator) StubCheckResult(voucherResult datatransfer.VoucherResult)

StubCheckResult returns the given voucher result when a call is made to OnPullDataSent, OnPushDataReceived, or OnComplete

func (*StubbedRevalidator) StubErrorComplete

func (srv *StubbedRevalidator) StubErrorComplete()

StubErrorComplete sets OnComplete to error

func (*StubbedRevalidator) StubErrorPullCheck

func (srv *StubbedRevalidator) StubErrorPullCheck()

StubErrorPullCheck sets OnPullDataSent to error

func (*StubbedRevalidator) StubErrorPushCheck

func (srv *StubbedRevalidator) StubErrorPushCheck()

StubErrorPushCheck sets OnPushDataReceived to error

func (*StubbedRevalidator) StubErrorRevalidation

func (srv *StubbedRevalidator) StubErrorRevalidation()

StubErrorRevalidation sets Revalidate to error

func (*StubbedRevalidator) StubPauseComplete

func (srv *StubbedRevalidator) StubPauseComplete()

StubPauseComplete sets OnComplete to pause

func (*StubbedRevalidator) StubPausePullCheck

func (srv *StubbedRevalidator) StubPausePullCheck()

StubPausePullCheck sets OnPullDataSent to pause

func (*StubbedRevalidator) StubPausePushCheck

func (srv *StubbedRevalidator) StubPausePushCheck()

StubPausePushCheck sets OnPushDataReceived to pause

func (*StubbedRevalidator) StubPauseRevalidation

func (srv *StubbedRevalidator) StubPauseRevalidation()

StubPauseRevalidation sets Revalidate to pause

func (*StubbedRevalidator) StubRevalidationResult

func (srv *StubbedRevalidator) StubRevalidationResult(voucherResult datatransfer.VoucherResult)

StubRevalidationResult returns the given voucher result when a call is made to Revalidate

func (*StubbedRevalidator) StubSuccessComplete

func (srv *StubbedRevalidator) StubSuccessComplete()

StubSuccessComplete sets OnComplete to succeed

func (*StubbedRevalidator) StubSuccessPullCheck

func (srv *StubbedRevalidator) StubSuccessPullCheck()

StubSuccessPullCheck sets OnPullDataSent to succeed

func (*StubbedRevalidator) StubSuccessPushCheck

func (srv *StubbedRevalidator) StubSuccessPushCheck()

StubSuccessPushCheck sets OnPushDataReceived to succeed

func (*StubbedRevalidator) StubSuccessRevalidation

func (srv *StubbedRevalidator) StubSuccessRevalidation()

StubSuccessRevalidation sets Revalidate to succeed

func (*StubbedRevalidator) VerifyExpectations

func (srv *StubbedRevalidator) VerifyExpectations(t *testing.T)

VerifyExpectations verifies the specified calls were made

type StubbedValidator

type StubbedValidator struct {
	ValidationsReceived []ReceivedValidation
	// contains filtered or unexported fields
}

StubbedValidator is a validator that returns predictable results

func NewStubbedValidator

func NewStubbedValidator() *StubbedValidator

NewStubbedValidator returns a new instance of a stubbed validator

func (*StubbedValidator) ExpectErrorPull

func (sv *StubbedValidator) ExpectErrorPull()

ExpectErrorPull expects ValidatePull to error

func (*StubbedValidator) ExpectErrorPush

func (sv *StubbedValidator) ExpectErrorPush()

ExpectErrorPush expects ValidatePush to error

func (*StubbedValidator) ExpectPausePull

func (sv *StubbedValidator) ExpectPausePull()

ExpectPausePull expects ValidatePull to pause

func (*StubbedValidator) ExpectPausePush

func (sv *StubbedValidator) ExpectPausePush()

ExpectPausePush expects ValidatePush to pause

func (*StubbedValidator) ExpectSuccessPull

func (sv *StubbedValidator) ExpectSuccessPull()

ExpectSuccessPull expects ValidatePull to error

func (*StubbedValidator) ExpectSuccessPush

func (sv *StubbedValidator) ExpectSuccessPush()

ExpectSuccessPush expects ValidatePush to error

func (*StubbedValidator) StubErrorPull

func (sv *StubbedValidator) StubErrorPull()

StubErrorPull sets ValidatePull to error

func (*StubbedValidator) StubErrorPush

func (sv *StubbedValidator) StubErrorPush()

StubErrorPush sets ValidatePush to error

func (*StubbedValidator) StubPausePull

func (sv *StubbedValidator) StubPausePull()

StubPausePull sets ValidatePull to pause

func (*StubbedValidator) StubPausePush

func (sv *StubbedValidator) StubPausePush()

StubPausePush sets ValidatePush to pause

func (*StubbedValidator) StubResult

func (sv *StubbedValidator) StubResult(voucherResult datatransfer.VoucherResult)

StubResult returns thes given voucher result when a validate call is made

func (*StubbedValidator) StubSuccessPull

func (sv *StubbedValidator) StubSuccessPull()

StubSuccessPull sets ValidatePull to succeed

func (*StubbedValidator) StubSuccessPush

func (sv *StubbedValidator) StubSuccessPush()

StubSuccessPush sets ValidatePush to succeed

func (*StubbedValidator) ValidatePull

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

ValidatePull returns a stubbed result for a pull validation

func (*StubbedValidator) ValidatePush

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

ValidatePush returns a stubbed result for a push validation

func (*StubbedValidator) VerifyExpectations

func (sv *StubbedValidator) VerifyExpectations(t *testing.T)

VerifyExpectations verifies the specified calls were made

Jump to

Keyboard shortcuts

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