types

package
v0.0.0-...-1c4572a Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const FloatDiff = 0.00001

Variables

View Source
var (
	CliCmd       string //chain33 cli可执行文件名
	CheckTimeout int    //用例check时超时次数

)

Functions

func AutoTestLogFormat

func AutoTestLogFormat() log15.Format

customize log15 log format

func CalcTxUtxoAmount

func CalcTxUtxoAmount(log map[string]interface{}, key string) float64

calculate total amount in tx in/out utxo set, key = ["keyinput" | "keyoutput"]

func CalcUtxoAvailAmount

func CalcUtxoAvailAmount(addr string, txHash string) (float64, error)

calculate available utxo with specific addr and TxHash

func CalcUtxoSpendAmount

func CalcUtxoSpendAmount(addr string, txHash string) (float64, error)

calculate spend utxo with specific addr and TxHash

func CheckBalanceDeltaWithAddr

func CheckBalanceDeltaWithAddr(log map[string]interface{}, addr string, delta float64) bool

diff balance

func CheckFrozenDeltaWithAddr

func CheckFrozenDeltaWithAddr(log map[string]interface{}, addr string, delta float64) bool

func GetAutoTestConfig

func GetAutoTestConfig(dapp string) reflect.Type

获取测试配置类型

func GetTxInfo

func GetTxInfo(txHash string) (string, bool)

get tx receipt with tx hash code if exist

func GetTxRecpTyname

func GetTxRecpTyname(txInfo map[string]interface{}) (tyname string, bSuccess bool)

get tx query -s TxHash

func Init

func Init(cliCmd string, checkTimeout int)

超时次数等于总超时时间除以每次check时睡眠时间

func IsBalanceEqualFloat

func IsBalanceEqualFloat(f1 float64, f2 float64) bool

according to the accuracy of coins balance

func RegisterAutoTest

func RegisterAutoTest(at AutoTest)

注册测试配置类型

func RunChain33Cli

func RunChain33Cli(para []string) (string, error)

invoke chain33 client

func SendPrivacyTxCommand

func SendPrivacyTxCommand(cmd string) (string, bool)

隐私交易执行回执哈希为json格式,需要解析

func SendTxCommand

func SendTxCommand(cmd string) (string, bool)

excute

Types

type AutoTest

type AutoTest interface {
	GetName() string
	GetTestConfigType() reflect.Type
}

dapp实现auto test的接口,需要提供每个dapp对应的测试配置类型,并注册

type BaseCase

type BaseCase struct {
	ID        string   `toml:"id"`
	Command   string   `toml:"command"`
	Dep       []string `toml:"dep,omitempty"`
	CheckItem []string `toml:"checkItem,omitempty"`
	Repeat    int      `toml:"repeat,omitempty"`
	Fail      bool     `toml:"fail,omitempty"`
}

base test case

func (*BaseCase) GetBaseCase

func (t *BaseCase) GetBaseCase() *BaseCase

func (*BaseCase) GetCmd

func (t *BaseCase) GetCmd() string

func (*BaseCase) GetDep

func (t *BaseCase) GetDep() []string

func (*BaseCase) GetID

func (t *BaseCase) GetID() string

func (*BaseCase) GetRepeat

func (t *BaseCase) GetRepeat() int

func (*BaseCase) SendCommand

func (t *BaseCase) SendCommand(packID string) (PackFunc, error)

interface CaseFunc implementing by BaseCase

func (*BaseCase) SetDependData

func (t *BaseCase) SetDependData(interface{})

type BaseCasePack

type BaseCasePack struct {
	TCase      CaseFunc
	CheckTimes int
	TxHash     string
	TxReceipt  string
	PackID     string
	FLog       log15.Logger
	TLog       log15.Logger
}

pack testCase with some check info

func (*BaseCasePack) CheckResult

func (pack *BaseCasePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool)

func (*BaseCasePack) GetBaseCase

func (pack *BaseCasePack) GetBaseCase() *BaseCase

func (*BaseCasePack) GetBasePack

func (pack *BaseCasePack) GetBasePack() *BaseCasePack

func (*BaseCasePack) GetCheckHandlerMap

func (pack *BaseCasePack) GetCheckHandlerMap() interface{}

func (*BaseCasePack) GetDependData

func (pack *BaseCasePack) GetDependData() interface{}

func (*BaseCasePack) GetPackID

func (pack *BaseCasePack) GetPackID() string

func (*BaseCasePack) GetTxHash

func (pack *BaseCasePack) GetTxHash() string

func (*BaseCasePack) GetTxReceipt

func (pack *BaseCasePack) GetTxReceipt() string

func (*BaseCasePack) SetLogger

func (pack *BaseCasePack) SetLogger(fLog log15.Logger, tLog log15.Logger)

func (*BaseCasePack) SetPackID

func (pack *BaseCasePack) SetPackID(id string)

type CaseFunc

type CaseFunc interface {
	//获取用例id
	GetID() string
	//获取命令行
	GetCmd() string
	//获取依赖数组
	GetDep() []string
	//获取重复次数
	GetRepeat() int
	//直接获取基类类型指针,方便获取所有成员
	GetBaseCase() *BaseCase
	//一个用例的输入依赖于另一个用例输出,设置依赖的输出数据
	SetDependData(interface{})
	//执行用例命令,并返回用例打包结构
	SendCommand(packId string) (PackFunc, error)
}

interface for testCase

type CheckHandlerFunc

type CheckHandlerFunc func(CheckHandlerParamType) bool

type CheckHandlerFuncDiscard

type CheckHandlerFuncDiscard func(map[string]interface{}) bool

check item handler 适配autotest早期版本,handlerfunc的参数为json的map形式,后续统一使用chain33的TxDetailResult结构体结构

type CheckHandlerMap

type CheckHandlerMap map[string]CheckHandlerFunc

type CheckHandlerMapDiscard

type CheckHandlerMapDiscard map[string]CheckHandlerFuncDiscard

type CheckHandlerParamType

type CheckHandlerParamType *chain33Type.TxDetailResult

建议使用

type PackFunc

type PackFunc interface {
	//获取id
	GetPackID() string
	//设置id
	SetPackID(id string)
	//获取用例的基类指针
	GetBaseCase() *BaseCase
	//获取交易哈希
	GetTxHash() string
	//获取交易回执,json字符串
	GetTxReceipt() string
	//获取基类打包类型指针,提供直接访问成员
	GetBasePack() *BaseCasePack
	//设置log15日志
	SetLogger(fLog log15.Logger, tLog log15.Logger)
	//获取check函数字典
	GetCheckHandlerMap() interface{}
	//获取依赖数据
	GetDependData() interface{}
	//执行结果check
	CheckResult(interface{}) (bool, bool)
}

interface for check testCase result

func DefaultSend

func DefaultSend(testCase CaseFunc, testPack PackFunc, packID string) (PackFunc, error)

default send command implementation, only for transaction type case

type SimpleCase

type SimpleCase struct {
	BaseCase
}

func (*SimpleCase) SendCommand

func (testCase *SimpleCase) SendCommand(packID string) (PackFunc, error)

type SimplePack

type SimplePack struct {
	BaseCasePack
}

func (*SimplePack) CheckResult

func (pack *SimplePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool)

simple case needn't check

Jump to

Keyboard shortcuts

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