utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// RPCTimeout defines rpc timeout
	RPCTimeout = 10 * time.Second
	// RPCInterval defines rpc query interval
	RPCInterval = 300 * time.Millisecond
)

Variables

View Source
var (

	// NewNodes flag indicates to need to start nodes
	NewNodes = flag.Bool("nodes", true, "need to start nodes?")
	// EnableDocker flag indicates to need start docker
	EnableDocker = flag.Bool("docker", false, "test in docker containers?")

	// LocalConf defines local test devconfig
	LocalConf = struct {
		ConfDir, WorkDir, KeyDir string
	}{"./.devconfig/", "./.devconfig/", "./.devconfig/keyfile/"}

	// DockerConf defines docker test devconfig
	DockerConf = struct {
		ConfDir, WorkDir, KeyDir string
	}{"../docker/.devconfig/", "../docker/.devconfig/", "../docker/.devconfig/keyfile/"}
)
View Source
var (
	// ErrItems record functional errors during integration tests
	ErrItems = make([]error, 0, maxErrItems)
)

Functions

func BalanceFor

func BalanceFor(accAddr string, peerAddr string) uint64

BalanceFor get balance of accAddr

func ChainHeightFor

func ChainHeightFor(peerAddr string) (int, error)

ChainHeightFor get chain height of peer's chain

func CircuAccounts

func CircuAccounts() int

CircuAccounts return circuAccounts

func CircuRepeatRandom

func CircuRepeatRandom() bool

CircuRepeatRandom return circuRepeatRandom

func CircuRepeatTxTimes

func CircuRepeatTxTimes() int

CircuRepeatTxTimes return circuRepeatTxTimes

func CircuUnitAccounts

func CircuUnitAccounts() int

CircuUnitAccounts return circuUnitAccounts

func Closing

func Closing(quitCh <-chan os.Signal) bool

Closing check if receive quit signal

func CollAccounts

func CollAccounts() int

CollAccounts return collAccounts

func CollUnitAccounts

func CollUnitAccounts() int

CollUnitAccounts return collUnitAccounts

func GenTestAddr

func GenTestAddr(count int) []string

GenTestAddr defines generate test address

func GetBoolCfgVal

func GetBoolCfgVal(def interface{}, keys ...string) (bool, error)

GetBoolCfgVal get bool value

func GetBoolSpecCfgVal

func GetBoolSpecCfgVal(cfgData CfgData, def interface{}, keys ...string) (bool, error)

GetBoolSpecCfgVal get bool value

func GetCfgVal

func GetCfgVal(def interface{}, keys ...string) (interface{}, error)

GetCfgVal get value from default cfgData

func GetFloatArrayCfgVal

func GetFloatArrayCfgVal(def interface{}, keys ...string) ([]float64, error)

GetFloatArrayCfgVal get float array value

func GetFloatArraySpecCfgVal

func GetFloatArraySpecCfgVal(cfgData CfgData, def interface{}, keys ...string) ([]float64, error)

GetFloatArraySpecCfgVal get float array value

func GetFloatCfgVal

func GetFloatCfgVal(def interface{}, keys ...string) (float64, error)

GetFloatCfgVal get float value

func GetFloatSpecCfgVal

func GetFloatSpecCfgVal(cfgData CfgData, def interface{}, keys ...string) (float64, error)

GetFloatSpecCfgVal get float value

func GetIniKV

func GetIniKV(iniBuf, key string) string

GetIniKV parses ini buff and get value of key

func GetIntArrayCfgVal

func GetIntArrayCfgVal(def interface{}, keys ...string) ([]int, error)

GetIntArrayCfgVal get int array value

func GetIntArraySpecCfgVal

func GetIntArraySpecCfgVal(cfgData CfgData, def interface{}, keys ...string) ([]int, error)

GetIntArraySpecCfgVal get int array value

func GetIntCfgVal

func GetIntCfgVal(def interface{}, keys ...string) (int, error)

GetIntCfgVal get int config value

func GetIntSpecCfgVal

func GetIntSpecCfgVal(cfgData CfgData, def interface{}, keys ...string) (int, error)

GetIntSpecCfgVal get int config vlaue

func GetSpecCfgVal

func GetSpecCfgVal(cfgData CfgData, def interface{}, keys ...string) (
	v interface{}, err error)

GetSpecCfgVal get special cfg value from param cfgdata

func GetStrArrayCfgVal

func GetStrArrayCfgVal(def interface{}, keys ...string) ([]string, error)

GetStrArrayCfgVal get string array value

func GetStrArraySpecCfgVal

func GetStrArraySpecCfgVal(cfgData CfgData, def interface{}, keys ...string) ([]string, error)

GetStrArraySpecCfgVal get string array value

func GetStringCfgVal

func GetStringCfgVal(def interface{}, keys ...string) (string, error)

GetStringCfgVal get string cfg value

func GetStringSpecCfgVal

func GetStringSpecCfgVal(cfgData CfgData, def interface{}, keys ...string) (
	string, error)

GetStringSpecCfgVal get string cfg value

func InitConf

func InitConf(cfgFile string) error

InitConf init config and store them int default variable cfgData

func LoadConf

func LoadConf() error

LoadConf load config file

func LoadJSONFromFile

func LoadJSONFromFile(fileName string, result interface{}) error

LoadJSONFromFile load json from file to result

func MinerAccounts

func MinerAccounts(keyFiles ...string) ([]string, []*acc.Account)

MinerAccounts get miners' accounts

func MinerAddrs

func MinerAddrs() []string

MinerAddrs gets miners addresses from config file

func ParseIPlist

func ParseIPlist(fileName string) ([]string, error)

ParseIPlist parse ip list from json file

func PeerAddrs

func PeerAddrs() []string

PeerAddrs gets execute transactions peers addresses from config file

func PrepareEnv

func PrepareEnv(count int) error

PrepareEnv prepare env

func RemoveKeystoreFiles

func RemoveKeystoreFiles(addrs ...string)

RemoveKeystoreFiles removes key store files

func SplitAddrAccounts

func SplitAddrAccounts() int

SplitAddrAccounts return splitAddrAccounts

func SplitAddrRepeatRandom

func SplitAddrRepeatRandom() bool

SplitAddrRepeatRandom return splitAddrRepeatRandom

func SplitAddrRepeatTxTimes

func SplitAddrRepeatTxTimes() int

SplitAddrRepeatTxTimes return splitAddrRepeatTxTimes

func SplitAddrTestEnable

func SplitAddrTestEnable() bool

SplitAddrTestEnable return splitAddrTestEnable

func SplitAddrUnitAccounts

func SplitAddrUnitAccounts() int

SplitAddrUnitAccounts return splitAddrUnitAccounts

func StartDockerNodes

func StartDockerNodes() error

StartDockerNodes start nodes

func StartLocalNodes

func StartLocalNodes(peerCount int) ([]*os.Process, error)

StartLocalNodes start local nodes

func StartProcess

func StartProcess(args ...string) (*os.Process, error)

StartProcess starts a process with args and default process attributions

func StopLocalNodes

func StopLocalNodes(processes ...*os.Process) error

StopLocalNodes stop local nodes

func StopNodes

func StopNodes() error

StopNodes stop nodes

func TearDown

func TearDown(count int) error

TearDown clean resource and files

func TickerDurationTxs

func TickerDurationTxs() time.Duration

TickerDurationTxs get ticker duration for calc tx count

func TimesToUpdateAddrs

func TimesToUpdateAddrs() int

TimesToUpdateAddrs return timesToUpdateAddrs

func TokenAccounts

func TokenAccounts() int

TokenAccounts return tokenAccounts

func TokenBalanceFor

func TokenBalanceFor(
	addr string, tokenHash string, tokenIndex uint32, peerAddr string,
) uint64

TokenBalanceFor get token balance of addr

func TokenRepeatRandom

func TokenRepeatRandom() bool

TokenRepeatRandom return circuRepeatRandom

func TokenRepeatTxTimes

func TokenRepeatTxTimes() int

TokenRepeatTxTimes return tokenRepeatTxTimes

func TokenTestEnable

func TokenTestEnable() bool

TokenTestEnable return tokenTestEnable

func TokenUnitAccounts

func TokenUnitAccounts() int

TokenUnitAccounts return tokenUnitAccounts

func TryRecordError

func TryRecordError(err error) bool

TryRecordError try to record error during integration test

func TxTestEnable

func TxTestEnable() bool

TxTestEnable return txTestEnable

func UnlockAccount

func UnlockAccount(addr string) *acc.Account

UnlockAccount defines unlock account

func WaitAllNodesHeightHigher

func WaitAllNodesHeightHigher(addrs []string, h int, timeout time.Duration) error

WaitAllNodesHeightHigher wait all nodes' height is higher than h

func WaitBalanceEnough

func WaitBalanceEnough(addr string, amount uint64, checkPeer string,
	timeout time.Duration) (uint64, error)

WaitBalanceEnough wait balance of addr is more than amount

func WaitBalanceEqual

func WaitBalanceEqual(addr string, amount uint64, checkPeer string,
	timeout time.Duration) (uint64, error)

WaitBalanceEqual wait balance of addr is more than amount

func WaitOneAddrBalanceEnough

func WaitOneAddrBalanceEnough(addrs []string, amount uint64, checkPeer string,
	timeout time.Duration) (string, uint64, error)

WaitOneAddrBalanceEnough wait one addr's balance more than amount

func WaitTokenBalanceEnough

func WaitTokenBalanceEnough(
	addr string, amount uint64, thash string, idx uint32, checkPeer string,
	timeout time.Duration,
) (uint64, error)

WaitTokenBalanceEnough wait tokken balance of addr is more than amount

func WaitTokenBalanceEqualTo

func WaitTokenBalanceEqualTo(
	addr string, amount uint64, thash string, idx uint32, checkPeer string, timeout time.Duration,
) error

WaitTokenBalanceEqualTo wait token balance of addr equal to amount

Types

type CfgData

type CfgData map[string]*json.RawMessage

CfgData define config data responding conf.json

func InitSpecConf

func InitSpecConf(cfgFile string) (CfgData, error)

InitSpecConf inits config and return CfgData variable

Jump to

Keyboard shortcuts

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