test

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustCreateNodesWithBootstrap

func MustCreateNodesWithBootstrap(ctx context.Context, t *testing.T, additionalNodes uint) ([]*node.Node, context.CancelFunc)

MustCreateNodesWithBootstrap creates an in-process test setup capable of testing communication between nodes. Every setup will have one bootstrap node (the first node that is called) that is setup to have power to mine. All of the proofs for the set-up are fake (but additional nodes will still need to create miners and add storage to gain power). All nodes will be started and connected to each other. The returned cancel function ensures all nodes are stopped when the test is over.

Types

type Client

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

Client is an in-process client to a command API.

func RunNodeAPI

func RunNodeAPI(ctx context.Context, node *node.Node, tb testing.TB) (client *Client, stop func())

RunNodeAPI creates a new API server and `Run()`s it.

func (*Client) Address

func (c *Client) Address() string

Address returns the address string to which the client sends command RPCs.

func (*Client) Run

func (c *Client) Run(ctx context.Context, command ...string) *th.CmdOutput

Run runs a CLI command and returns its output.

func (*Client) RunFail

func (c *Client) RunFail(ctx context.Context, err string, command ...string) *th.CmdOutput

RunFail runs a command and asserts that it fails with a specified message on stderr.

func (*Client) RunJSON

func (c *Client) RunJSON(ctx context.Context, command ...string) map[string]interface{}

RunJSON runs a command, asserts success, and parses the response as JSON.

func (*Client) RunMarshaledJSON

func (c *Client) RunMarshaledJSON(ctx context.Context, result interface{}, command ...string)

RunMarshaledJSON runs a command, asserts success, and marshals the JSON response.

func (*Client) RunSuccess

func (c *Client) RunSuccess(ctx context.Context, command ...string) *th.CmdOutput

RunSuccess runs a command and asserts that it succeeds (status of zero and logs no errors).

func (*Client) RunSuccessFirstLine

func (c *Client) RunSuccessFirstLine(ctx context.Context, args ...string) string

RunSuccessFirstLine executes the given command, asserts success and returns the first line of stdout.

func (*Client) RunSuccessLines

func (c *Client) RunSuccessLines(ctx context.Context, args ...string) []string

RunSuccessLines executes the given command, asserts success and returns an array of lines of the stdout.

type NodeAPI

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

NodeAPI wraps an in-process Node to provide a command API server and client for testing.

func NewNodeAPI

func NewNodeAPI(node *node.Node, tb testing.TB) *NodeAPI

NewNodeAPI creates a wrangler for a node.

func (*NodeAPI) Node

func (a *NodeAPI) Node() *node.Node

Node returns the node backing the API.

func (*NodeAPI) Run

func (a *NodeAPI) Run(ctx context.Context) (client *Client, stop func())

Run start s a command API server for the node. Returns a client proxy and a function to terminate the NodeAPI server.

type NodeBuilder

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

NodeBuilder creates and configures Filecoin nodes for in-process testing. This is intended to replace use of GenNode and the various other node construction entry points that end up there. Note that (August 2019) there are two things called "config": the configuration read in from file to the config.Config structure, and node.Config which is really just some dependency injection. This builder avoids exposing the latter directly.

func NewNodeBuilder

func NewNodeBuilder(tb testing.TB) *NodeBuilder

NewNodeBuilder creates a new node builder.

func (*NodeBuilder) Build

func (b *NodeBuilder) Build(ctx context.Context) *node.Node

Build creates a node as specified by this builder. This many be invoked multiple times to create many nodes.

func (*NodeBuilder) BuildAndStart

func (b *NodeBuilder) BuildAndStart(ctx context.Context) *node.Node

BuildAndStart build a node and starts it.

func (*NodeBuilder) BuildAndStartAPI

func (b *NodeBuilder) BuildAndStartAPI(ctx context.Context) (*node.Node, *Client, func())

BuildAndStartAPI is a convenience function composing BuildAndStart with RunNodeAPI

func (*NodeBuilder) BuildMany

func (b *NodeBuilder) BuildMany(ctx context.Context, numNodes int) []*node.Node

BuildMany builds numNodes nodes with the builder's configuration.

func (*NodeBuilder) WithBuilderOpt

func (b *NodeBuilder) WithBuilderOpt(opts ...node.BuilderOpt) *NodeBuilder

WithBuilderOpt adds one or more node building options to node creation.

func (*NodeBuilder) WithConfig

func (b *NodeBuilder) WithConfig(cm node.ConfigOpt) *NodeBuilder

WithConfig adds a configuration mutation function to be invoked after repo initialisation.

func (*NodeBuilder) WithGenesisInit

func (b *NodeBuilder) WithGenesisInit(gif genesis.InitFunc) *NodeBuilder

WithGenesisInit sets the built nodes' genesis function.

func (*NodeBuilder) WithInitOpt

func (b *NodeBuilder) WithInitOpt(opts ...node.InitOpt) *NodeBuilder

WithInitOpt adds one or more options to repo initialisation.

Jump to

Keyboard shortcuts

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