swamp

package
v0.9.3-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTestTimeout = time.Minute * 5

DefaultTestTimeout should be used as the default timout on all the Swamp tests. It's generously set to 5 minutes to give enough time for CI.

Variables

This section is empty.

Functions

func FillBlocks added in v0.7.0

func FillBlocks(ctx context.Context, cctx testnode.Context, accounts []string, bsize, blocks int) chan error

FillBlocks produces the given amount of contiguous blocks with customizable size. The returned channel reports when the process is finished.

Types

type Config added in v0.7.0

type Config struct {
	*core.TestConfig
}

Config struct represents a set of pre-requisite attributes from the test scenario

func DefaultConfig added in v0.7.0

func DefaultConfig() *Config

DefaultConfig creates a celestia-app instance with a block time of around 100ms

type Option

type Option func(*Config)

Option for modifying Swamp's Config.

func WithBlockTime

func WithBlockTime(t time.Duration) Option

WithBlockTime sets a custom interval for block creation.

type Swamp

type Swamp struct {
	Network     mocknet.Mocknet
	BridgeNodes []*nodebuilder.Node
	FullNodes   []*nodebuilder.Node
	LightNodes  []*nodebuilder.Node

	ClientContext testnode.Context
	Accounts      []string
	// contains filtered or unexported fields
}

Swamp represents the main functionality that is needed for the test-case: - Network to link the nodes - CoreClient to share between Bridge nodes - Slices of created Bridge/Full/Light Nodes - trustedHash taken from the CoreClient and shared between nodes

func NewSwamp

func NewSwamp(t *testing.T, options ...Option) *Swamp

NewSwamp creates a new instance of Swamp.

func (*Swamp) Connect

func (s *Swamp) Connect(t *testing.T, peerA, peerB peer.ID)

Connect allows to connect peers after hard disconnection.

func (*Swamp) Disconnect

func (s *Swamp) Disconnect(t *testing.T, peerA, peerB peer.ID)

Disconnect allows to break a connection between two peers without any possibility to re-establish it. Order is very important here. We have to unlink peers first, and only after that call disconnect. This is hard disconnect and peers will not be able to reconnect. In order to reconnect peers again, please use swamp.Connect

func (*Swamp) GetCoreBlockHashByHeight

func (s *Swamp) GetCoreBlockHashByHeight(ctx context.Context, height int64) libhead.Hash

GetCoreBlockHashByHeight returns a tendermint block's hash by provided height

func (*Swamp) NewBridgeNode

func (s *Swamp) NewBridgeNode(options ...fx.Option) *nodebuilder.Node

NewBridgeNode creates a new instance of a BridgeNode providing a default config and a mockstore to the NewNodeWithStore method

func (*Swamp) NewFullNode

func (s *Swamp) NewFullNode(options ...fx.Option) *nodebuilder.Node

NewFullNode creates a new instance of a FullNode providing a default config and a mockstore to the NewNodeWithStore method

func (*Swamp) NewLightNode

func (s *Swamp) NewLightNode(options ...fx.Option) *nodebuilder.Node

NewLightNode creates a new instance of a LightNode providing a default config and a mockstore to the NewNodeWithStore method

func (*Swamp) NewNodeWithConfig

func (s *Swamp) NewNodeWithConfig(nodeType node.Type, cfg *nodebuilder.Config, options ...fx.Option) *nodebuilder.Node

func (*Swamp) NewNodeWithStore

func (s *Swamp) NewNodeWithStore(
	t node.Type,
	store nodebuilder.Store,
	options ...fx.Option,
) *nodebuilder.Node

NewNodeWithStore creates a new instance of Node with predefined Store. Afterwards, the instance is stored in the swamp's Nodes' slice according to the node's type provided from the user.

func (*Swamp) RemoveNode

func (s *Swamp) RemoveNode(n *nodebuilder.Node, t node.Type) error

RemoveNode removes a node from the swamp's node slice this allows reusage of the same var in the test scenario if the user needs to stop and start the same node

func (*Swamp) WaitTillHeight

func (s *Swamp) WaitTillHeight(ctx context.Context, height int64) libhead.Hash

WaitTillHeight holds the test execution until the given amount of blocks has been produced by the CoreClient.

Jump to

Keyboard shortcuts

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