testutils

package
v0.4.5-0...-e935ded Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGasLimit    = 1000000
	DefaultGasPrice    = 0
	DefaultInitBalance = uint64(10000000)
	BlockInterval      = 5 * time.Second
)

Variables

This section is empty.

Functions

func CompileSolStr

func CompileSolStr(s string) (code, rtCode string, _abi abi.ABI, err error)

func GenKeyAndAddr

func GenKeyAndAddr() (string, common.Address)

func GetIntEvn

func GetIntEvn(env string, defaultVal int) (val int)

func HexPrivKeyToAddr

func HexPrivKeyToAddr(keyHex string) common.Address

func HexToBytes

func HexToBytes(s string) []byte

func HexToHash32

func HexToHash32(s string) common.Hash

func HexToU256

func HexToU256(s string) *uint256.Int

func JoinBytes

func JoinBytes(a ...[]byte) []byte

func KeysToGenesisAlloc

func KeysToGenesisAlloc(balance *uint256.Int, keys []string) gethcore.GenesisAlloc

func MustCompileSolStr

func MustCompileSolStr(s string) (code, rtCode string, _abi abi.ABI)

func MustEncodeTx

func MustEncodeTx(tx *gethtypes.Transaction) []byte

func MustHexToPrivKey

func MustHexToPrivKey(key string) *ecdsa.PrivateKey

func MustSignTx

func MustSignTx(tx *gethtypes.Transaction,
	chainID *big.Int, privKey string) *gethtypes.Transaction

func NewAddressFilter

func NewAddressFilter(addrs ...gethcmn.Address) gethfilters.FilterCriteria

func NewBlockHashFilter

func NewBlockHashFilter(hash *gethcmn.Hash) gethfilters.FilterCriteria

func NewBlockRangeFilter

func NewBlockRangeFilter(from, to int64) gethfilters.FilterCriteria

func NewTopicsFilter

func NewTopicsFilter(topics [][]gethcmn.Hash) gethfilters.FilterCriteria

func ReadKeysFromFile

func ReadKeysFromFile(fname string, count int) (res []string)

read private keys from a file

func ToHexutilBig

func ToHexutilBig(n int64) *hexutil.Big

func ToHexutilBytes

func ToHexutilBytes(s []byte) *hexutil.Bytes

func ToHexutilU64

func ToHexutilU64(n uint64) *hexutil.Uint64

func ToJSON

func ToJSON(v interface{}) string

func ToPrettyJSON

func ToPrettyJSON(v interface{}) string

func UintToBytes32

func UintToBytes32(n uint64) []byte

Types

type FilterBuilder

type FilterBuilder struct {
	// contains filtered or unexported fields
}

func NewFilterBuilder

func NewFilterBuilder() *FilterBuilder

func (*FilterBuilder) Addresses

func (fb *FilterBuilder) Addresses(addrs ...gethcmn.Address) *FilterBuilder

func (*FilterBuilder) BlockHash

func (fb *FilterBuilder) BlockHash(blockHash gethcmn.Hash) *FilterBuilder

func (*FilterBuilder) BlockRange

func (fb *FilterBuilder) BlockRange(from, to int64) *FilterBuilder

func (*FilterBuilder) Build

func (*FilterBuilder) Topics

func (fb *FilterBuilder) Topics(topics [][]gethcmn.Hash) *FilterBuilder

type MdbBlockBuilder

type MdbBlockBuilder struct {
	// contains filtered or unexported fields
}

func NewMdbBlockBuilder

func NewMdbBlockBuilder() *MdbBlockBuilder

func (*MdbBlockBuilder) Build

func (bb *MdbBlockBuilder) Build() *modbtypes.Block

func (*MdbBlockBuilder) FailedTx

func (bb *MdbBlockBuilder) FailedTx(txHash gethcmn.Hash, statusStr string, outData []byte) *MdbBlockBuilder

func (*MdbBlockBuilder) Hash

func (bb *MdbBlockBuilder) Hash(hash gethcmn.Hash) *MdbBlockBuilder

func (*MdbBlockBuilder) Height

func (bb *MdbBlockBuilder) Height(h int64) *MdbBlockBuilder

func (*MdbBlockBuilder) Tx

func (bb *MdbBlockBuilder) Tx(txHash gethcmn.Hash, logs ...types.Log) *MdbBlockBuilder

func (*MdbBlockBuilder) TxWithAddr

func (bb *MdbBlockBuilder) TxWithAddr(txHash gethcmn.Hash, fromAddr, toAddr gethcmn.Address) *MdbBlockBuilder

type TestApp

type TestApp struct {
	*app.App
	TestPubkey crypto.PubKey
	StateRoot  []byte
	StartTime  time.Time
	// contains filtered or unexported fields
}

func CreateTestApp

func CreateTestApp(keys ...string) *TestApp

func CreateTestAppInArchiveMode

func CreateTestAppInArchiveMode(keys ...string) *TestApp

func CreateTestAppWithArgs

func CreateTestAppWithArgs(args TestAppInitArgs) *TestApp

func CreateTestAppWithSyncDB

func CreateTestAppWithSyncDB(keys ...string) *TestApp

func (*TestApp) AddBlocksToHistory

func (_app *TestApp) AddBlocksToHistory(blocks ...*modbtypes.Block)

func (*TestApp) AddTxsInBlock

func (_app *TestApp) AddTxsInBlock(height int64, txs ...*gethtypes.Transaction) int64

func (*TestApp) Call

func (_app *TestApp) Call(sender, contractAddr gethcmn.Address, data []byte) (int, string, []byte)

func (*TestApp) CallAtHeight

func (_app *TestApp) CallAtHeight(sender, contractAddr gethcmn.Address, data []byte, height int64) (int, string, []byte)

func (*TestApp) CallWithABI

func (_app *TestApp) CallWithABI(sender, contractAddr gethcmn.Address,
	abi ethutils.ABIWrapper, methodName string, args ...interface{}) []interface{}

func (*TestApp) CheckNewTxABCI

func (_app *TestApp) CheckNewTxABCI(tx *gethtypes.Transaction) uint32

func (*TestApp) CheckTxABCI

func (_app *TestApp) CheckTxABCI(tx *gethtypes.Transaction, newTx bool) (uint32, string)

func (*TestApp) DeployContractInBlock

func (_app *TestApp) DeployContractInBlock(privKey string, data []byte) (*gethtypes.Transaction, int64, gethcmn.Address)

func (*TestApp) Destroy

func (_app *TestApp) Destroy()

func (*TestApp) DestroyWithoutCheck

func (_app *TestApp) DestroyWithoutCheck()

func (*TestApp) EnsureTxFailed

func (_app *TestApp) EnsureTxFailed(hash gethcmn.Hash, msg string)

func (*TestApp) EnsureTxFailedWithOutData

func (_app *TestApp) EnsureTxFailedWithOutData(hash gethcmn.Hash, statusStr, outData string)

func (*TestApp) EnsureTxSuccess

func (_app *TestApp) EnsureTxSuccess(hash gethcmn.Hash)

func (*TestApp) EstimateGas

func (_app *TestApp) EstimateGas(sender gethcmn.Address, tx *gethtypes.Transaction) (int, string, int64)

func (*TestApp) ExecTxInBlock

func (_app *TestApp) ExecTxInBlock(tx *gethtypes.Transaction) int64

func (*TestApp) ExecTxsInBlock

func (_app *TestApp) ExecTxsInBlock(txs ...*gethtypes.Transaction) int64

func (*TestApp) GetBalance

func (_app *TestApp) GetBalance(addr gethcmn.Address) *big.Int

func (*TestApp) GetBlock

func (_app *TestApp) GetBlock(h int64) *motypes.Block

func (*TestApp) GetCode

func (_app *TestApp) GetCode(addr gethcmn.Address) []byte

func (*TestApp) GetDynamicArray

func (_app *TestApp) GetDynamicArray(addr gethcmn.Address, arrSlot string) [][]byte

func (*TestApp) GetMinGasPrice

func (_app *TestApp) GetMinGasPrice(isLast bool) uint64

func (*TestApp) GetNonce

func (_app *TestApp) GetNonce(addr gethcmn.Address) uint64

func (*TestApp) GetSep20FromAddressCount

func (_app *TestApp) GetSep20FromAddressCount(contract, addr gethcmn.Address) int64

func (*TestApp) GetSep20ToAddressCount

func (_app *TestApp) GetSep20ToAddressCount(contract, addr gethcmn.Address) int64

func (*TestApp) GetSeq

func (_app *TestApp) GetSeq(addr gethcmn.Address) uint64

func (*TestApp) GetStorageAt

func (_app *TestApp) GetStorageAt(addr gethcmn.Address, key []byte) []byte

func (*TestApp) GetTestPubkey

func (_app *TestApp) GetTestPubkey() crypto.PubKey

func (*TestApp) GetToAddressCount

func (_app *TestApp) GetToAddressCount(addr gethcmn.Address) int64

func (*TestApp) GetTx

func (_app *TestApp) GetTx(h gethcmn.Hash) (tx *motypes.Transaction)

func (*TestApp) GetTxsByAddr

func (_app *TestApp) GetTxsByAddr(addr gethcmn.Address) []*motypes.Transaction

func (*TestApp) MakeAndExecTxInBlock

func (_app *TestApp) MakeAndExecTxInBlock(privKey string,
	toAddr gethcmn.Address, val int64, data []byte) (*gethtypes.Transaction, int64)

func (*TestApp) MakeAndExecTxInBlockWithGas

func (_app *TestApp) MakeAndExecTxInBlockWithGas(privKey string,
	toAddr gethcmn.Address, val int64, data []byte, gasLimit uint64, gasPrice int64) (*gethtypes.Transaction, int64)

func (*TestApp) MakeAndSignTx

func (_app *TestApp) MakeAndSignTx(hexPrivKey string,
	toAddr *gethcmn.Address, val int64, data []byte) (*gethtypes.Transaction, gethcmn.Address)

func (*TestApp) MakeAndSignTxWithAllArgs

func (_app *TestApp) MakeAndSignTxWithAllArgs(hexPrivKey string,
	toAddr *gethcmn.Address, val int64, data []byte, gasLimit uint64, gasPrice int64,
	nonce int64) (*gethtypes.Transaction, gethcmn.Address)

func (*TestApp) MakeAndSignTxWithGas

func (_app *TestApp) MakeAndSignTxWithGas(hexPrivKey string,
	toAddr *gethcmn.Address, val int64, data []byte, gasLimit uint64, gasPrice int64) (*gethtypes.Transaction, gethcmn.Address)

func (*TestApp) MakeAndSignTxWithNonce

func (_app *TestApp) MakeAndSignTxWithNonce(hexPrivKey string,
	toAddr *gethcmn.Address, val int64, data []byte, nonce int64) (*gethtypes.Transaction, gethcmn.Address)

func (*TestApp) RecheckTxABCI

func (_app *TestApp) RecheckTxABCI(tx *gethtypes.Transaction) uint32

func (*TestApp) ReloadApp

func (_app *TestApp) ReloadApp() *TestApp

func (*TestApp) SetMinGasPrice

func (_app *TestApp) SetMinGasPrice(gp uint64)

func (*TestApp) StoreBlocks

func (_app *TestApp) StoreBlocks(blocks ...*modbtypes.Block)

func (*TestApp) WaitMS

func (_app *TestApp) WaitMS(n int64)

func (*TestApp) WaitNextBlock

func (_app *TestApp) WaitNextBlock(currHeight int64)

type TestAppInitArgs

type TestAppInitArgs struct {
	StartHeight *int64
	StartTime   *time.Time
	ValPubKey   *crypto.PubKey
	InitAmt     *uint256.Int
	PrivKeys    []string
	ArchiveMode bool
	WithSyncDB  bool
}

Jump to

Keyboard shortcuts

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