test

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0, MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PeerKeys = []crypto.PrivKey{
	mustGenKey(101),
	mustGenKey(102),
}

PeerKeys are a list of keys for peers that can be used in testing.

Functions

func ConnectNodes

func ConnectNodes(t *testing.T, a, b *node.Node)

ConnectNodes connects two nodes together

func CreateBootstrapMiner

func CreateBootstrapMiner(ctx context.Context, t *testing.T, seed *ChainSeed, chainClock clock.ChainEpochClock, genCfg *gengen.GenesisCfg) *node.Node

func DefaultAddressConfigOpt

func DefaultAddressConfigOpt(addr address.Address) node.ConfigOpt

DefaultAddressConfigOpt is a node config option setting the default address

func FakeProofVerifierBuilderOpts

func FakeProofVerifierBuilderOpts() []node.BuilderOpt

FakeProofVerifierBuilderOpts returns default configuration for testing

func MakeTestGenCfg

func MakeTestGenCfg(t *testing.T, numSectors int) *gengen.GenesisCfg

MakeTestGenCfg returns a genesis configuration used for tests. This config has one miner with numSectors sectors and two accounts, the first is the miner's owner/worker and the accounts both have 10000 FIL

func StartNodes

func StartNodes(t *testing.T, nds []*node.Node)

StartNodes starts some nodes, failing on any error.

func StopNodes

func StopNodes(nds []*node.Node)

StopNodes initiates shutdown of some nodes.

Types

type ChainSeed

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

ChainSeed is a generalized struct for configuring node

func CreateBootstrapSetup

func CreateBootstrapSetup(t *testing.T) (*ChainSeed, *gengen.GenesisCfg, clock.ChainEpochClock)

func FixtureChainSeed

func FixtureChainSeed(t *testing.T) *ChainSeed

FixtureChainSeed returns the genesis function that

func MakeChainSeed

func MakeChainSeed(t *testing.T, cfg *gengen.GenesisCfg) *ChainSeed

MakeChainSeed creates a chain seed struct (see above) from a given genesis config

func (*ChainSeed) Addr

func (cs *ChainSeed) Addr(t *testing.T, key int) address.Address

Addr returns the address for the given key

func (*ChainSeed) GenesisInitFunc

func (cs *ChainSeed) GenesisInitFunc(cst cbor.IpldStore, bs blockstoreutil.Blockstore) (*types.BlockHeader, error)

GenesisInitFunc is a th.GenesisInitFunc using the chain seed

func (*ChainSeed) GiveKey

func (cs *ChainSeed) GiveKey(ctx context.Context, t *testing.T, nd *node.Node, key int) address.Address

GiveKey gives the given key to the given node

func (*ChainSeed) GiveMiner

func (cs *ChainSeed) GiveMiner(t *testing.T, nd *node.Node, which int) (address.Address, address.Address)

GiveMiner gives the specified miner to the node. Returns the address and the owner addresss

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 MustCreateStorageMinerResult

type MustCreateStorageMinerResult struct {
	MinerAddress *address.Address
	Err          error
}

MustCreateStorageMinerResult contains the result of a CreateStorageMiner command

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.configModule structure, and node.configModule 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.

Jump to

Keyboard shortcuts

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