Documentation
¶
Overview ¶
Package types 定义autotest包基础结构体、接口、以及函数
Index ¶
- Constants
- Variables
- func AutoTestLogFormat() log15.Format
- func CalcTxUtxoAmount(log map[string]interface{}, key string) float64
- func CalcUtxoAvailAmount(addr string, txHash string) (float64, error)
- func CalcUtxoSpendAmount(addr string, txHash string) (float64, error)
- func CheckBalanceDeltaWithAddr(log map[string]interface{}, addr string, delta float64) bool
- func CheckFrozenDeltaWithAddr(log map[string]interface{}, addr string, delta float64) bool
- func GetAutoTestConfig(dapp string) reflect.Type
- func GetTxInfo(txHash string) (string, bool)
- func GetTxRecpTyname(txInfo map[string]interface{}) (tyname string, bSuccess bool)
- func Init(cliCmd string, checkTimeout int)
- func IsBalanceEqualFloat(f1 float64, f2 float64) bool
- func RegisterAutoTest(at AutoTest)
- func RunTuringchainCli(para []string) (string, error)
- func SendPrivacyTxCommand(cmd string) (string, bool)
- func SendTxCommand(cmd string) (string, bool)
- type AutoTest
- type BaseCase
- type BaseCasePack
- func (pack *BaseCasePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool)
- func (pack *BaseCasePack) GetBaseCase() *BaseCase
- func (pack *BaseCasePack) GetBasePack() *BaseCasePack
- func (pack *BaseCasePack) GetCheckHandlerMap() interface{}
- func (pack *BaseCasePack) GetDependData() interface{}
- func (pack *BaseCasePack) GetPackID() string
- func (pack *BaseCasePack) GetTxHash() string
- func (pack *BaseCasePack) GetTxReceipt() string
- func (pack *BaseCasePack) SetLogger(fLog log15.Logger, tLog log15.Logger)
- func (pack *BaseCasePack) SetPackID(id string)
- type CaseFunc
- type CheckHandlerFunc
- type CheckHandlerFuncDiscard
- type CheckHandlerMap
- type CheckHandlerMapDiscard
- type CheckHandlerParamType
- type PackFunc
- type SimpleCase
- type SimplePack
Constants ¶
const FloatDiff = 0.00001
FloatDiff const
Variables ¶
var ( CliCmd string //turingchain cli可执行文件名 CheckTimeout int //用例check时超时次数 )
var
Functions ¶
func AutoTestLogFormat ¶
AutoTestLogFormat customize log15 log format
func CalcTxUtxoAmount ¶
CalcTxUtxoAmount calculate total amount in tx in/out utxo set, key = ["keyinput" | "keyoutput"]
func CalcUtxoAvailAmount ¶
CalcUtxoAvailAmount calculate available utxo with specific addr and TxHash
func CalcUtxoSpendAmount ¶
CalcUtxoSpendAmount calculate spend utxo with specific addr and TxHash
func CheckBalanceDeltaWithAddr ¶
CheckBalanceDeltaWithAddr diff balance
func CheckFrozenDeltaWithAddr ¶
CheckFrozenDeltaWithAddr check
func GetAutoTestConfig ¶
GetAutoTestConfig 获取测试配置类型
func GetTxRecpTyname ¶
GetTxRecpTyname get tx query -s TxHash
func IsBalanceEqualFloat ¶
IsBalanceEqualFloat according to the accuracy of coins balance
func RunTuringchainCli ¶
RunTuringchainCli invoke turingchain client
func SendPrivacyTxCommand ¶
SendPrivacyTxCommand 隐私交易执行回执哈希为json格式,需要解析
Types ¶
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"`
}
BaseCase base test case
func (*BaseCase) SendCommand ¶
SendCommand interface CaseFunc implementing by BaseCase
type BaseCasePack ¶
type BaseCasePack struct {
TCase CaseFunc
CheckTimes int
TxHash string
TxReceipt string
PackID string
FLog log15.Logger
TLog log15.Logger
}
BaseCasePack pack testCase with some check info
func (*BaseCasePack) CheckResult ¶
func (pack *BaseCasePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool)
CheckResult 检查结果
func (*BaseCasePack) GetBaseCase ¶
func (pack *BaseCasePack) GetBaseCase() *BaseCase
GetBaseCase 获取基础用例
func (*BaseCasePack) GetBasePack ¶
func (pack *BaseCasePack) GetBasePack() *BaseCasePack
GetBasePack 获取基础pack
func (*BaseCasePack) GetCheckHandlerMap ¶
func (pack *BaseCasePack) GetCheckHandlerMap() interface{}
GetCheckHandlerMap 获取map
func (*BaseCasePack) GetDependData ¶
func (pack *BaseCasePack) GetDependData() interface{}
GetDependData 获取依赖数据
func (*BaseCasePack) GetTxReceipt ¶
func (pack *BaseCasePack) GetTxReceipt() string
GetTxReceipt 获取交易接收方
type CaseFunc ¶
type CaseFunc interface {
//获取用例id
GetID() string
//获取命令行
GetCmd() string
//获取依赖数组
GetDep() []string
//获取重复次数
GetRepeat() int
//直接获取基类类型指针,方便获取所有成员
GetBaseCase() *BaseCase
//一个用例的输入依赖于另一个用例输出,设置依赖的输出数据
SetDependData(interface{})
//执行用例命令,并返回用例打包结构
SendCommand(packID string) (PackFunc, error)
}
CaseFunc interface for testCase
type CheckHandlerFunc ¶
type CheckHandlerFunc func(CheckHandlerParamType) bool
CheckHandlerFunc 检查func
type CheckHandlerFuncDiscard ¶
CheckHandlerFuncDiscard 检查func
type CheckHandlerMapDiscard ¶
type CheckHandlerMapDiscard map[string]CheckHandlerFuncDiscard
CheckHandlerMapDiscard 检查map
type CheckHandlerParamType ¶
type CheckHandlerParamType *turingchainType.TxDetailResult
CheckHandlerParamType 检查参数类型
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)
}
PackFunc interface for check testCase result
type SimpleCase ¶
type SimpleCase struct {
BaseCase
}
SimpleCase 简单用例
func (*SimpleCase) SendCommand ¶
func (testCase *SimpleCase) SendCommand(packID string) (PackFunc, error)
SendCommand 发送cmd
type SimplePack ¶
type SimplePack struct {
BaseCasePack
}
SimplePack 简单pack
func (*SimplePack) CheckResult ¶
func (pack *SimplePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool)
CheckResult simple case needn't check