Documentation
¶
Index ¶
- func AssertChannelEmpty(t TestingT, channel interface{}, errorMessage string)
- func AssertContainsBlock(t TestingT, blks []blocks.Block, block blocks.Block)
- func AssertContainsPeer(t TestingT, peers []peer.ID, p peer.ID)
- func AssertDoesReceive(ctx context.Context, t TestingT, channel interface{}, errorMessage string)
- func AssertDoesReceiveFirst(t TestingT, channel interface{}, errorMessage string, ...)
- func AssertReceive(ctx context.Context, t TestingT, channel interface{}, out interface{}, ...)
- func AssertReceiveFirst(t TestingT, channel interface{}, out interface{}, errorMessage string, ...)
- func AssertSends(ctx context.Context, t TestingT, channel interface{}, in interface{}, ...)
- func CollectErrors(ctx context.Context, t *testing.T, errChan <-chan error) []error
- func CollectResponses(ctx context.Context, t TestingT, ...) []graphsync.ResponseProgress
- func ContainsBlock(blks []blocks.Block, block blocks.Block) bool
- func ContainsPeer(peers []peer.ID, p peer.ID) bool
- func GenerateBlocksOfSize(n int, size int64) []blocks.Block
- func GenerateCids(n int) []cid.Cid
- func GeneratePeers(n int) []peer.ID
- func IndexOf(blks []blocks.Block, c cid.Cid) int
- func NewFakeBlockData() graphsync.BlockData
- func NewInvalidSelectorSpec() ld.Node
- func NewTestLink() ld.Link
- func NewTestStore(blocksWritten map[ld.Link][]byte) ld.LinkSystem
- func NewUnparsableSelectorSpec() ld.Node
- func RandomBytes(n int64) []byte
- func ReadNResponses(ctx context.Context, t TestingT, ...) []graphsync.ResponseProgress
- func RefuteContainsBlock(t TestingT, blks []blocks.Block, block blocks.Block)
- func RefuteContainsPeer(t TestingT, peers []peer.ID, p peer.ID)
- func VerifyEmptyErrors(ctx context.Context, t TestingT, errChan <-chan error)
- func VerifyEmptyResponse(ctx context.Context, t TestingT, ...)
- func VerifyHasErrors(ctx context.Context, t TestingT, errChan <-chan error)
- func VerifySingleTerminalError(ctx context.Context, t TestingT, errChan <-chan error)
- type DispatchedEvent
- type MockPublisher
- func (mp *MockPublisher) AddNotifees(notifees []notifications.Notifee)
- func (mp *MockPublisher) PublishEvents(events []notifications.Event)
- func (mp *MockPublisher) PublishEventsOnTopicData(data []notifications.TopicData, events []notifications.Event)
- func (mp *MockPublisher) PublishMatchingEvents(shouldPublish func(notifications.TopicData) bool, events []notifications.Event)
- type NotifeeVerifier
- type TestBlockChain
- func (tbc *TestBlockChain) AllBlocks() []blocks.Block
- func (tbc *TestBlockChain) Blocks(from int, to int) []blocks.Block
- func (tbc *TestBlockChain) Chooser(ld.Link, ld.LinkContext) (ld.NodePrototype, error)
- func (tbc *TestBlockChain) LinkTipIndex(fromTip int) ld.Link
- func (tbc *TestBlockChain) NodeTipIndex(fromTip int) ld.Node
- func (tbc *TestBlockChain) RemainderBlocks(from int) []blocks.Block
- func (tbc *TestBlockChain) Selector() ld.Node
- func (tbc *TestBlockChain) VerifyRemainder(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int)
- func (tbc *TestBlockChain) VerifyRemainderSync(responses []graphsync.ResponseProgress, from int)
- func (tbc *TestBlockChain) VerifyRemainderWithTypes(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int)
- func (tbc *TestBlockChain) VerifyResponseRange(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int, ...)
- func (tbc *TestBlockChain) VerifyResponseRangeSync(responses []graphsync.ResponseProgress, from int, to int)
- func (tbc *TestBlockChain) VerifyWholeChain(ctx context.Context, responseChan <-chan graphsync.ResponseProgress)
- func (tbc *TestBlockChain) VerifyWholeChainSync(responses []graphsync.ResponseProgress)
- func (tbc *TestBlockChain) VerifyWholeChainWithTypes(ctx context.Context, responseChan <-chan graphsync.ResponseProgress)
- type TestLDTree
- type TestSubscriber
- func (ts *TestSubscriber) ExpectCloses(ctx context.Context, t *testing.T, topics []notifications.Topic)
- func (ts *TestSubscriber) ExpectClosesAnyOrder(ctx context.Context, t *testing.T, topics []notifications.Topic)
- func (ts *TestSubscriber) ExpectEvents(ctx context.Context, t *testing.T, events []DispatchedEvent)
- func (ts *TestSubscriber) NoEventsReceived(t *testing.T)
- func (ts *TestSubscriber) OnClose(topic notifications.Topic)
- func (ts *TestSubscriber) OnNext(topic notifications.Topic, ev notifications.Event)
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertChannelEmpty ¶
AssertChannelEmpty verifies that a channel has no value currently
func AssertContainsBlock ¶
AssertContainsBlock will fail a test if the block is not in the given block list
func AssertContainsPeer ¶
AssertContainsPeer will fail a test if the peer is not in the given peer list
func AssertDoesReceive ¶
AssertDoesReceive verifies that a channel returns some value before the given context closes
func AssertDoesReceiveFirst ¶
func AssertDoesReceiveFirst(t TestingT, channel interface{}, errorMessage string, incorrectChannels ...interface{})
AssertDoesReceiveFirst asserts that the given channel receives a value before any of the other channels specified
func AssertReceive ¶
func AssertReceive(ctx context.Context, t TestingT, channel interface{}, out interface{}, errorMessage string)
AssertReceive verifies that a channel returns a value before the given context closes, and writes into into out, which should be a pointer to the value type
func AssertReceiveFirst ¶
func AssertReceiveFirst(t TestingT, channel interface{}, out interface{}, errorMessage string, incorrectChannels ...interface{})
AssertReceiveFirst verifies that a channel returns a value on the specified channel before the other channels, and writes the value into out, which should be a pointer to the value type
func AssertSends ¶
func AssertSends(ctx context.Context, t TestingT, channel interface{}, in interface{}, errorMessage string)
AssertSends attempts to send the given input value to the given channel before the given context closes
func CollectErrors ¶
CollectErrors is just a utility to convert an error channel into an array.
func CollectResponses ¶
func CollectResponses(ctx context.Context, t TestingT, responseChan <-chan graphsync.ResponseProgress) []graphsync.ResponseProgress
CollectResponses is just a utility to convert a graphsync response progress channel into an array.
func ContainsBlock ¶
ContainsBlock returns true if a block is found n a list of blocks
func ContainsPeer ¶
ContainsPeer returns true if a peer is found n a list of peers.
func GenerateBlocksOfSize ¶
GenerateBlocksOfSize generates a series of blocks of the given byte size
func NewFakeBlockData ¶
func NewFakeBlockData() graphsync.BlockData
NewFakeBlockData returns a fake block that matches the block data interface
func NewInvalidSelectorSpec ¶
NewInvalidSelectorSpec returns a spec that will fail when you attempt to validate it on the responder side
func NewTestStore ¶
func NewTestStore(blocksWritten map[ld.Link][]byte) ld.LinkSystem
NewTestStore provides a loader and storer for the given in memory link -> byte data map
func NewUnparsableSelectorSpec ¶
NewUnparsableSelectorSpec returns a spec that will fail when you attempt to validate it or decompose to a node + selector.
func RandomBytes ¶
RandomBytes returns a byte array of the given size with random values.
func ReadNResponses ¶
func ReadNResponses(ctx context.Context, t TestingT, responseChan <-chan graphsync.ResponseProgress, count int) []graphsync.ResponseProgress
ReadNResponses does a partial read from a ResponseProgress channel -- up to n values
func RefuteContainsBlock ¶
RefuteContainsBlock will fail a test if the block is in the given block list
func RefuteContainsPeer ¶
RefuteContainsPeer will fail a test if the peer is in the given peer list
func VerifyEmptyErrors ¶
VerifyEmptyErrors verifies that no errors were sent over a channel before it was closed
func VerifyEmptyResponse ¶
func VerifyEmptyResponse(ctx context.Context, t TestingT, responseChan <-chan graphsync.ResponseProgress)
VerifyEmptyResponse verifies that no response progress happened before the channel was closed.
func VerifyHasErrors ¶
VerifyHasErrors verifies that at least one error was sent over a channel
Types ¶
type DispatchedEvent ¶
type DispatchedEvent struct { Topic notifications.Topic Event notifications.Event }
type MockPublisher ¶
type MockPublisher struct {
// contains filtered or unexported fields
}
func NewMockPublisher ¶
func NewMockPublisher() *MockPublisher
func (*MockPublisher) AddNotifees ¶
func (mp *MockPublisher) AddNotifees(notifees []notifications.Notifee)
func (*MockPublisher) PublishEvents ¶
func (mp *MockPublisher) PublishEvents(events []notifications.Event)
func (*MockPublisher) PublishEventsOnTopicData ¶
func (mp *MockPublisher) PublishEventsOnTopicData(data []notifications.TopicData, events []notifications.Event)
func (*MockPublisher) PublishMatchingEvents ¶
func (mp *MockPublisher) PublishMatchingEvents(shouldPublish func(notifications.TopicData) bool, events []notifications.Event)
type NotifeeVerifier ¶
type NotifeeVerifier struct {
// contains filtered or unexported fields
}
func NewTestNotifee ¶
func NewTestNotifee(data notifications.TopicData, bufferSize int) (notifications.Notifee, *NotifeeVerifier)
func (*NotifeeVerifier) ExpectClose ¶
func (nv *NotifeeVerifier) ExpectClose(ctx context.Context, t *testing.T)
func (*NotifeeVerifier) ExpectEvents ¶
func (nv *NotifeeVerifier) ExpectEvents(ctx context.Context, t *testing.T, events []notifications.Event)
type TestBlockChain ¶
type TestBlockChain struct { GenisisNode ld.Node GenisisLink ld.Link MiddleNodes []ld.Node MiddleLinks []ld.Link TipNode ld.Node TipLink ld.Link // contains filtered or unexported fields }
TestBlockChain is a simulated data structure similar to a blockchain which graphsync is uniquely suited for
func SetupBlockChain ¶
func SetupBlockChain( ctx context.Context, t TestingT, lsys ld.LinkSystem, size uint64, blockChainLength int) *TestBlockChain
SetupBlockChain creates a new test block chain with the given height
func (*TestBlockChain) AllBlocks ¶
func (tbc *TestBlockChain) AllBlocks() []blocks.Block
AllBlocks returns all blocks for a blockchain
func (*TestBlockChain) Blocks ¶
func (tbc *TestBlockChain) Blocks(from int, to int) []blocks.Block
Blocks Returns the given raw blocks for the block chain for the given range, indexed from the tip
func (*TestBlockChain) Chooser ¶
func (tbc *TestBlockChain) Chooser(ld.Link, ld.LinkContext) (ld.NodePrototype, error)
Chooser is a NodeBuilderChooser function that always returns the block chain
func (*TestBlockChain) LinkTipIndex ¶
func (tbc *TestBlockChain) LinkTipIndex(fromTip int) ld.Link
LinkTipIndex returns a link to the block at the given index from the tip
func (*TestBlockChain) NodeTipIndex ¶
func (tbc *TestBlockChain) NodeTipIndex(fromTip int) ld.Node
NodeTipIndex returns the node to the block at the given index from the tip
func (*TestBlockChain) RemainderBlocks ¶
func (tbc *TestBlockChain) RemainderBlocks(from int) []blocks.Block
RemainderBlocks returns the remaining blocks for a blockchain, indexed from tip
func (*TestBlockChain) Selector ¶
func (tbc *TestBlockChain) Selector() ld.Node
Selector returns the selector to recursive traverse the block chain parent links
func (*TestBlockChain) VerifyRemainder ¶
func (tbc *TestBlockChain) VerifyRemainder(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int)
VerifyRemainder verifies the given response channel returns the remainder of the chain starting at the nth block from the tip
func (*TestBlockChain) VerifyRemainderSync ¶
func (tbc *TestBlockChain) VerifyRemainderSync(responses []graphsync.ResponseProgress, from int)
VerifyRemainderSync verifies the given set of read responses are the remainder of the chain starting at the nth block from the tip
func (*TestBlockChain) VerifyRemainderWithTypes ¶
func (tbc *TestBlockChain) VerifyRemainderWithTypes(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int)
VerifyRemainderWithTypes verifies the given response channel returns the remainder of the chain starting at the nth block from the tip and that the types in the response are the expected types for a block chain
func (*TestBlockChain) VerifyResponseRange ¶
func (tbc *TestBlockChain) VerifyResponseRange(ctx context.Context, responseChan <-chan graphsync.ResponseProgress, from int, to int)
VerifyResponseRange verifies the given response channel returns the given range of respnses, indexed from the tip (with possibly more data left in the channel)
func (*TestBlockChain) VerifyResponseRangeSync ¶
func (tbc *TestBlockChain) VerifyResponseRangeSync(responses []graphsync.ResponseProgress, from int, to int)
VerifyResponseRangeSync verifies given set of read responses match responses for the given range of the blockchain, indexed from the tip (with possibly more data left in the channel)
func (*TestBlockChain) VerifyWholeChain ¶
func (tbc *TestBlockChain) VerifyWholeChain(ctx context.Context, responseChan <-chan graphsync.ResponseProgress)
VerifyWholeChain verifies the given response channel returns the expected responses for the whole chain
func (*TestBlockChain) VerifyWholeChainSync ¶
func (tbc *TestBlockChain) VerifyWholeChainSync(responses []graphsync.ResponseProgress)
VerifyWholeChainSync verifies the given set of read responses are the expected responses for the whole chain
func (*TestBlockChain) VerifyWholeChainWithTypes ¶
func (tbc *TestBlockChain) VerifyWholeChainWithTypes(ctx context.Context, responseChan <-chan graphsync.ResponseProgress)
VerifyWholeChainWithTypes verifies the given response channel returns the expected responses for the whole chain and that the types in the response are the expected types for a block chain
type TestLDTree ¶
type TestLDTree struct { Storage map[ld.Link][]byte LeafAlpha ld.Node LeafAlphaLnk ld.Link LeafAlphaBlock blocks.Block LeafBeta ld.Node LeafBetaLnk ld.Link LeafBetaBlock blocks.Block MiddleMapNode ld.Node MiddleMapNodeLnk ld.Link MiddleMapBlock blocks.Block MiddleListNode ld.Node MiddleListNodeLnk ld.Link MiddleListBlock blocks.Block RootNode ld.Node RootNodeLnk ld.Link RootBlock blocks.Block }
TestLDTree is a set of LD Data that forms a tree spread across some blocks with a serialized in memory representation
func NewTestLDTree ¶
func NewTestLDTree() TestLDTree
NewTestLDTree returns a fake tree of nodes, spread across 5 blocks
type TestSubscriber ¶
type TestSubscriber struct {
// contains filtered or unexported fields
}
func NewTestSubscriber ¶
func NewTestSubscriber(bufferSize int) *TestSubscriber
func (*TestSubscriber) ExpectCloses ¶
func (ts *TestSubscriber) ExpectCloses(ctx context.Context, t *testing.T, topics []notifications.Topic)
func (*TestSubscriber) ExpectClosesAnyOrder ¶
func (ts *TestSubscriber) ExpectClosesAnyOrder(ctx context.Context, t *testing.T, topics []notifications.Topic)
func (*TestSubscriber) ExpectEvents ¶
func (ts *TestSubscriber) ExpectEvents(ctx context.Context, t *testing.T, events []DispatchedEvent)
func (*TestSubscriber) NoEventsReceived ¶
func (ts *TestSubscriber) NoEventsReceived(t *testing.T)
func (*TestSubscriber) OnClose ¶
func (ts *TestSubscriber) OnClose(topic notifications.Topic)
func (*TestSubscriber) OnNext ¶
func (ts *TestSubscriber) OnNext(topic notifications.Topic, ev notifications.Event)