types

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: BSD-3-Clause Imports: 10 Imported by: 53

Documentation

Overview

Package types 定义autotest包基础结构体、接口、以及函数

Index

Constants

View Source
const FloatDiff = 0.00001

FloatDiff const

Variables

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

)

var

Functions

func AutoTestLogFormat

func AutoTestLogFormat() log15.Format

AutoTestLogFormat customize log15 log format

func CalcTxUtxoAmount

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

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

func CalcUtxoAvailAmount

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

CalcUtxoAvailAmount calculate available utxo with specific addr and TxHash

func CalcUtxoSpendAmount

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

CalcUtxoSpendAmount calculate spend utxo with specific addr and TxHash

func CheckBalanceDeltaWithAddr

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

CheckBalanceDeltaWithAddr diff balance

func CheckFrozenDeltaWithAddr

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

CheckFrozenDeltaWithAddr check

func GetAutoTestConfig

func GetAutoTestConfig(dapp string) reflect.Type

GetAutoTestConfig 获取测试配置类型

func GetTxInfo

func GetTxInfo(txHash string) (string, bool)

GetTxInfo get tx receipt with tx hash code if exist

func GetTxRecpTyname

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

GetTxRecpTyname get tx query -s TxHash

func Init

func Init(cliCmd string, checkTimeout int)

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

func IsBalanceEqualFloat

func IsBalanceEqualFloat(f1 float64, f2 float64) bool

IsBalanceEqualFloat according to the accuracy of coins balance

func RegisterAutoTest

func RegisterAutoTest(at AutoTest)

RegisterAutoTest 注册测试配置类型

func RunChain33Cli

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

RunChain33Cli invoke chain33 client

func SendPrivacyTxCommand

func SendPrivacyTxCommand(cmd string) (string, bool)

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

func SendTxCommand

func SendTxCommand(cmd string) (string, bool)

SendTxCommand excute

Types

type AutoTest

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

AutoTest 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"`
}

BaseCase base test case

func (*BaseCase) GetBaseCase

func (t *BaseCase) GetBaseCase() *BaseCase

GetBaseCase 获取基础用例

func (*BaseCase) GetCmd

func (t *BaseCase) GetCmd() string

GetCmd 获取cmd

func (*BaseCase) GetDep

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

GetDep 获取dep

func (*BaseCase) GetID

func (t *BaseCase) GetID() string

GetID 获取id

func (*BaseCase) GetRepeat

func (t *BaseCase) GetRepeat() int

GetRepeat 获取repeat

func (*BaseCase) SendCommand

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

SendCommand interface CaseFunc implementing by BaseCase

func (*BaseCase) SetDependData

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

SetDependData 获取依赖数据

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) GetPackID

func (pack *BaseCasePack) GetPackID() string

GetPackID 获取pack id

func (*BaseCasePack) GetTxHash

func (pack *BaseCasePack) GetTxHash() string

GetTxHash 获取交易hash

func (*BaseCasePack) GetTxReceipt

func (pack *BaseCasePack) GetTxReceipt() string

GetTxReceipt 获取交易接收方

func (*BaseCasePack) SetLogger

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

SetLogger 设置日志

func (*BaseCasePack) SetPackID

func (pack *BaseCasePack) SetPackID(id string)

SetPackID 设置pack id

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

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

CheckHandlerFuncDiscard 检查func

type CheckHandlerMap

type CheckHandlerMap map[string]CheckHandlerFunc

CheckHandlerMap 检查map

type CheckHandlerMapDiscard

type CheckHandlerMapDiscard map[string]CheckHandlerFuncDiscard

CheckHandlerMapDiscard 检查map

type CheckHandlerParamType

type CheckHandlerParamType *chain33Type.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

func DefaultSend

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

DefaultSend default send command implementation, only for transaction type case

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

Jump to

Keyboard shortcuts

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