testutil

package
v0.0.0-...-84d53aa Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestAliasName = "mediblocmainnet"
)

contants

Variables

View Source
var (
	ErrExecutionTimeout = errors.New("execution timeout")
)

Error types of testutil package.

Functions

func DirSize

func DirSize(path string) (int64, error)

DirSize returns dir size

func FindRandomListenPorts

func FindRandomListenPorts(n int) (ports []string)

FindRandomListenPorts returns empty ports

func GetStorage

func GetStorage(t *testing.T) storage.Storage

GetStorage return storage

func IP2Local

func IP2Local(ipAddr string) string

IP2Local changes ip address to localhost address

func KeyOf

func KeyOf(t *testing.T, trie *trie.Trie, value []byte) []byte

KeyOf find the key at which a given value can be found in the trie batch

func TempDir

func TempDir(t *testing.T) string

TempDir make temporary directory for test

func TrieLen

func TrieLen(t *testing.T, trie *trie.Batch) int

TrieLen counts the number of trie members

Types

type Network

type Network struct {
	DynastySize int
	Seed        *Node
	Nodes       []*Node
	// contains filtered or unexported fields
}

Network is set of nodes.

func NewNetwork

func NewNetwork(t *testing.T) *Network

NewNetwork creates network.

func NewNetworkWithDynastySize

func NewNetworkWithDynastySize(t *testing.T, dynastySize int) *Network

NewNetworkWithDynastySize creates network with dynasty size.

func (*Network) AddProposerFromDynasties

func (n *Network) AddProposerFromDynasties(node *Node)

AddProposerFromDynasties chooses proposer from dynasties.

func (*Network) AddRandomProposer

func (n *Network) AddRandomProposer(node *Node)

AddRandomProposer sets random proposer.

func (*Network) Cleanup

func (n *Network) Cleanup()

Cleanup cleans up directories and files.

func (*Network) FindProposer

func (n *Network) FindProposer(ts int64, parent *core.Block) *keyutil.AddrKeyPair

FindProposer returns block proposer for time stamp

func (*Network) LogTestHook

func (n *Network) LogTestHook() *test.Hook

LogTestHook returns test hook for log messages.

func (*Network) NewNode

func (n *Network) NewNode() *Node

NewNode creates node.

func (*Network) NewNodeWithConfig

func (n *Network) NewNodeWithConfig(cfg *NodeConfig) *Node

NewNodeWithConfig creates node with custom config

func (*Network) NewSeedNode

func (n *Network) NewSeedNode() *Node

NewSeedNode creates seed node.

func (*Network) NewSeedNodeWithConfig

func (n *Network) NewSeedNodeWithConfig(cfg *NodeConfig) *Node

NewSeedNodeWithConfig creates seed node.

func (*Network) Start

func (n *Network) Start()

Start starts nodes in network.

func (*Network) Stop

func (n *Network) Stop()

Stop stops nodes in network

func (*Network) WaitForEstablished

func (n *Network) WaitForEstablished()

WaitForEstablished waits until connections between peers are established.

type Node

type Node struct {
	Med    *medlet.Medlet
	Config *NodeConfig
	// contains filtered or unexported fields
}

Node is node for testing.

func NewNode

func NewNode(t *testing.T, cfg *NodeConfig) *Node

NewNode creates node for test.

func (*Node) AddProposers

func (node *Node) AddProposers(pairs keyutil.AddrKeyPairs)

AddProposers adds multiple proposers.

func (*Node) GenesisBlock

func (node *Node) GenesisBlock() *core.Block

GenesisBlock returns genesis block.

func (*Node) IsStarted

func (node *Node) IsStarted() bool

IsStarted returns whether it has been started.

func (*Node) Restart

func (node *Node) Restart()

Restart restart node

func (*Node) Start

func (node *Node) Start()

Start starts test node.

func (*Node) Stop

func (node *Node) Stop()

Stop stops test node.

func (*Node) String

func (node *Node) String() string

String returns summary of test node.

func (*Node) Tail

func (node *Node) Tail() *core.Block

Tail returns tail block.

func (*Node) WaitUntilBlockAcceptedOnChain

func (node *Node) WaitUntilBlockAcceptedOnChain(hash []byte, timeLimit time.Duration) error

WaitUntilBlockAcceptedOnChain waits until the block is accepted on the blockchain

func (*Node) WaitUntilTailHeight

func (node *Node) WaitUntilTailHeight(height uint64, timeLimit time.Duration) error

WaitUntilTailHeight waits until blockchain has a designated height or timeout

type NodeConfig

type NodeConfig struct {
	Config *medletpb.Config

	Genesis   *corepb.Genesis
	Dynasties keyutil.AddrKeyPairs
	TokenDist keyutil.AddrKeyPairs
	// contains filtered or unexported fields
}

NodeConfig is configuration for test node.

func NewConfig

func NewConfig(t *testing.T) *NodeConfig

NewConfig returns configuration of node.

func (*NodeConfig) AddProposer

func (cfg *NodeConfig) AddProposer(proposer *keyutil.AddrKeyPair) *NodeConfig

AddProposer adds a proposer.

func (*NodeConfig) AddProposerFromDynasties

func (cfg *NodeConfig) AddProposerFromDynasties(exclude []*keyutil.AddrKeyPair) *NodeConfig

AddProposerFromDynasties chooses proposer from dynasties.

func (*NodeConfig) AddRandomProposer

func (cfg *NodeConfig) AddRandomProposer() *NodeConfig

AddRandomProposer sets random proposer.

func (*NodeConfig) GetListenAddrs

func (cfg *NodeConfig) GetListenAddrs() []string

GetListenAddrs returns listen address of a node.

func (*NodeConfig) SetChainID

func (cfg *NodeConfig) SetChainID(chainID uint32) *NodeConfig

SetChainID sets chain ID.

func (*NodeConfig) SetDataDir

func (cfg *NodeConfig) SetDataDir(dir string) *NodeConfig

SetDataDir sets data dir.

func (*NodeConfig) SetGenesisFrom

func (cfg *NodeConfig) SetGenesisFrom(c *Node) *NodeConfig

SetGenesisFrom sets genesis configruation from other node's config.

func (*NodeConfig) SetPorts

func (cfg *NodeConfig) SetPorts(baseport int) *NodeConfig

SetPorts sets ports.

func (*NodeConfig) SetRandomDataDir

func (cfg *NodeConfig) SetRandomDataDir() *NodeConfig

SetRandomDataDir sets random data dir.

func (*NodeConfig) SetRandomGenesis

func (cfg *NodeConfig) SetRandomGenesis(dynastySize int) *NodeConfig

SetRandomGenesis sets random genesis configuration.

func (*NodeConfig) SetRandomPorts

func (cfg *NodeConfig) SetRandomPorts() *NodeConfig

SetRandomPorts sets random ports.

func (*NodeConfig) SetSeed

func (cfg *NodeConfig) SetSeed(seed *Node) *NodeConfig

SetSeed sets a seed node address.

func (*NodeConfig) String

func (cfg *NodeConfig) String() string

String returns summary of test config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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