Documentation ¶
Index ¶
- Constants
- Variables
- func DirSize(path string) (int64, error)
- func FindRandomListenPorts(n int) (ports []string)
- func GetStorage(t *testing.T) storage.Storage
- func IP2Local(ipAddr string) string
- func KeyOf(t *testing.T, trie *trie.Trie, value []byte) []byte
- func TempDir(t *testing.T) string
- func TrieLen(t *testing.T, trie *trie.Batch) int
- type Network
- func (n *Network) AddProposerFromDynasties(node *Node)
- func (n *Network) AddRandomProposer(node *Node)
- func (n *Network) Cleanup()
- func (n *Network) FindProposer(ts int64, parent *core.Block) *keyutil.AddrKeyPair
- func (n *Network) LogTestHook() *test.Hook
- func (n *Network) NewNode() *Node
- func (n *Network) NewNodeWithConfig(cfg *NodeConfig) *Node
- func (n *Network) NewSeedNode() *Node
- func (n *Network) NewSeedNodeWithConfig(cfg *NodeConfig) *Node
- func (n *Network) Start()
- func (n *Network) Stop()
- func (n *Network) WaitForEstablished()
- type Node
- func (node *Node) AddProposers(pairs keyutil.AddrKeyPairs)
- func (node *Node) GenesisBlock() *core.Block
- func (node *Node) IsStarted() bool
- func (node *Node) Restart()
- func (node *Node) Start()
- func (node *Node) Stop()
- func (node *Node) String() string
- func (node *Node) Tail() *core.Block
- func (node *Node) WaitUntilBlockAcceptedOnChain(hash []byte, timeLimit time.Duration) error
- func (node *Node) WaitUntilTailHeight(height uint64, timeLimit time.Duration) error
- type NodeConfig
- func (cfg *NodeConfig) AddProposer(proposer *keyutil.AddrKeyPair) *NodeConfig
- func (cfg *NodeConfig) AddProposerFromDynasties(exclude []*keyutil.AddrKeyPair) *NodeConfig
- func (cfg *NodeConfig) AddRandomProposer() *NodeConfig
- func (cfg *NodeConfig) GetListenAddrs() []string
- func (cfg *NodeConfig) SetChainID(chainID uint32) *NodeConfig
- func (cfg *NodeConfig) SetDataDir(dir string) *NodeConfig
- func (cfg *NodeConfig) SetGenesisFrom(c *Node) *NodeConfig
- func (cfg *NodeConfig) SetPorts(baseport int) *NodeConfig
- func (cfg *NodeConfig) SetRandomDataDir() *NodeConfig
- func (cfg *NodeConfig) SetRandomGenesis(dynastySize int) *NodeConfig
- func (cfg *NodeConfig) SetRandomPorts() *NodeConfig
- func (cfg *NodeConfig) SetSeed(seed *Node) *NodeConfig
- func (cfg *NodeConfig) String() string
Constants ¶
const (
TestAliasName = "mediblocmainnet"
)
contants
Variables ¶
var (
ErrExecutionTimeout = errors.New("execution timeout")
)
Error types of testutil package.
Functions ¶
func FindRandomListenPorts ¶
FindRandomListenPorts returns empty ports
Types ¶
type Network ¶
type Network struct { DynastySize int Seed *Node Nodes []*Node // contains filtered or unexported fields }
Network is set of nodes.
func NewNetworkWithDynastySize ¶
NewNetworkWithDynastySize creates network with dynasty size.
func (*Network) AddProposerFromDynasties ¶
AddProposerFromDynasties chooses proposer from dynasties.
func (*Network) AddRandomProposer ¶
AddRandomProposer sets random proposer.
func (*Network) FindProposer ¶
FindProposer returns block proposer for time stamp
func (*Network) LogTestHook ¶
LogTestHook returns test hook for log messages.
func (*Network) NewNodeWithConfig ¶
func (n *Network) NewNodeWithConfig(cfg *NodeConfig) *Node
NewNodeWithConfig creates node with custom config
func (*Network) NewSeedNodeWithConfig ¶
func (n *Network) NewSeedNodeWithConfig(cfg *NodeConfig) *Node
NewSeedNodeWithConfig creates seed node.
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 (*Node) AddProposers ¶
func (node *Node) AddProposers(pairs keyutil.AddrKeyPairs)
AddProposers adds multiple proposers.
func (*Node) GenesisBlock ¶
GenesisBlock returns genesis block.
func (*Node) WaitUntilBlockAcceptedOnChain ¶
WaitUntilBlockAcceptedOnChain waits until the block is accepted on the blockchain
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 (*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.