qri: github.com/qri-io/qri/p2p/test Index | Files

package p2ptest

import "github.com/qri-io/qri/p2p/test"

Package p2ptest defines utilities for qri peer-2-peer testing

Index

Package Files

p2ptest.go

func ConnectNodes Uses

func ConnectNodes(ctx context.Context, nodes []TestablePeerNode) error

ConnectNodes creates a basic connection between the nodes. This connection mirrors the connection that would normally occur between two p2p nodes. The Host.Connect function adds the addresses into the peerstore and dials the remote peer. Take a look at https://github.com/libp2p/go-libp2p-host/blob/623ffaa4ef2b8dad77933159d0848a393a91c41e/host.go#L36 for more info Connect should always: - add a connections to the peer - add the addrs of the peer to the peerstore - add a tag for each peer in the connmanager

func ConnectQriNodes Uses

func ConnectQriNodes(ctx context.Context, nodes []TestablePeerNode) error

ConnectQriNodes takes a slice of unconnected nodes and returns a slice of connected nodes that have upgraded qri connections: They support the qri protocol and have exchanged profile

type NodeMakerFunc Uses

type NodeMakerFunc func(repo.Repo, *config.P2P) (TestablePeerNode, error)

NodeMakerFunc is a function that constructs a Node from a Repo and options.

type TestNodeFactory Uses

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

TestNodeFactory can be used to safetly construct nodes for tests

func NewTestNodeFactory Uses

func NewTestNodeFactory(maker NodeMakerFunc) *TestNodeFactory

NewTestNodeFactory returns a new TestNodeFactory

func (*TestNodeFactory) New Uses

func (f *TestNodeFactory) New(r repo.Repo) (TestablePeerNode, error)

New creates a new Node for testing

func (*TestNodeFactory) NewWithConf Uses

func (f *TestNodeFactory) NewWithConf(r repo.Repo, p2pconf *config.P2P) (TestablePeerNode, error)

NewWithConf creates a new Node for testing using a configuration

func (*TestNodeFactory) NextInfo Uses

func (f *TestNodeFactory) NextInfo() *cfgtest.PeerInfo

NextInfo gets the PeerInfo for the next test Node to be constructed

type TestablePeerNode Uses

type TestablePeerNode interface {
    // add Host here?
    Host() host.Host
    SimplePeerInfo() pstore.PeerInfo
    UpgradeToQriConnection(pstore.PeerInfo) error
    GoOnline() error
}

TestablePeerNode is used by tests only. Implemented by QriNode

func NewAvailableTestNode Uses

func NewAvailableTestNode(r repo.Repo, f *TestNodeFactory) (TestablePeerNode, error)

NewAvailableTestNode constructs a test node that is hooked up and ready to Connect

func NewTestDirNetwork Uses

func NewTestDirNetwork(ctx context.Context, f *TestNodeFactory) ([]TestablePeerNode, error)

NewTestDirNetwork constructs nodes from the testdata directory, for p2p testing Peers are pulled from the "testdata" directory, and come pre-populated with datasets no peers are connected.

func NewTestNetwork Uses

func NewTestNetwork(ctx context.Context, f *TestNodeFactory, num int) ([]TestablePeerNode, error)

NewTestNetwork constructs nodes to test p2p functionality. each of these peers has no datasets and no peers are connected

Package p2ptest imports 13 packages (graph) and is imported by 1 packages. Updated 2019-06-12. Refresh now. Tools for package owners.