testutils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 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 added in v0.3.0

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

func HexPrivKeyToAddr added in v0.3.6

func HexPrivKeyToAddr(keyHex string) common.Address

func HexToBytes

func HexToBytes(s string) []byte

func HexToHash32

func HexToHash32(s string) common.Hash

func HexToU256 added in v0.4.0

func HexToU256(s string) *uint256.Int

func JoinBytes added in v0.3.6

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 added in v0.1.2

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

func MustHexToPrivKey added in v0.1.1

func MustHexToPrivKey(key string) *ecdsa.PrivateKey

func MustSignTx added in v0.1.1

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, addresses ...gethcmn.Address) gethfilters.FilterCriteria

func NewBlockRangeFilter

func NewBlockRangeFilter(from, to int64) gethfilters.FilterCriteria

func NewTopicsFilter

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

func ReadKeysFromFile added in v0.1.6

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 added in v0.1.2

func ToJSON(v interface{}) string

func ToPrettyJSON

func ToPrettyJSON(v interface{}) string

func UintToBytes32 added in v0.3.6

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 added in v0.3.0

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 added in v0.1.2

type TestApp struct {
	*app.App
	TestPubkey crypto.PubKey
	StateRoot  []byte
	StartTime  time.Time

	CfgCopy *param.ChainConfig
	// contains filtered or unexported fields
}

func CreateTestApp added in v0.1.2

func CreateTestApp(keys ...string) *TestApp

func CreateTestAppInArchiveMode added in v0.4.0

func CreateTestAppInArchiveMode(keys ...string) *TestApp

func CreateTestAppWithArgs added in v0.3.6

func CreateTestAppWithArgs(args TestAppInitArgs) *TestApp

func CreateTestAppWithSyncDB added in v0.4.3

func CreateTestAppWithSyncDB(keys ...string) *TestApp

func (*TestApp) AddBlocksToHistory added in v0.1.5

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

func (*TestApp) AddTxsInBlock added in v0.1.3

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

func (*TestApp) Call added in v0.1.2

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

func (*TestApp) CallAtHeight added in v0.4.0

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

func (*TestApp) CallWithABI added in v0.3.6

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

func (*TestApp) CheckNewTxABCI added in v0.1.3

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

func (*TestApp) CheckTxABCI added in v0.3.6

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

func (*TestApp) DeployContractInBlock added in v0.1.2

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

func (*TestApp) Destroy added in v0.1.2

func (_app *TestApp) Destroy()

func (*TestApp) DestroyWithoutCheck added in v0.3.3

func (_app *TestApp) DestroyWithoutCheck()

func (*TestApp) EnsureTxFailed added in v0.1.3

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

func (*TestApp) EnsureTxFailedWithOutData added in v0.3.0

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

func (*TestApp) EnsureTxSuccess added in v0.1.3

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

func (*TestApp) EstimateGas added in v0.1.2

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

func (*TestApp) ExecTxInBlock added in v0.1.2

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

func (*TestApp) ExecTxsInBlock added in v0.1.3

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

func (*TestApp) GetBalance added in v0.1.2

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

func (*TestApp) GetBlock added in v0.1.2

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

func (*TestApp) GetCode added in v0.1.2

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

func (*TestApp) GetDynamicArray added in v0.4.0

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

func (*TestApp) GetMinGasPrice added in v0.3.0

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

func (*TestApp) GetNonce added in v0.1.2

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

func (*TestApp) GetSep20FromAddressCount added in v0.1.2

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

func (*TestApp) GetSep20ToAddressCount added in v0.1.2

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

func (*TestApp) GetSeq added in v0.3.6

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

func (*TestApp) GetStorageAt added in v0.1.2

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

func (*TestApp) GetTestPubkey added in v0.1.6

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

func (*TestApp) GetToAddressCount added in v0.1.2

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

func (*TestApp) GetTx added in v0.1.2

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

func (*TestApp) GetTxsByAddr added in v0.1.2

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

func (*TestApp) MakeAndExecTxInBlock added in v0.1.2

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

func (*TestApp) MakeAndExecTxInBlockWithGas added in v0.3.0

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

func (*TestApp) MakeAndSignTx added in v0.1.2

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

func (*TestApp) MakeAndSignTxWithAllArgs added in v0.3.6

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 added in v0.3.0

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

func (*TestApp) MakeAndSignTxWithNonce added in v0.3.6

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

func (*TestApp) RecheckTxABCI added in v0.3.0

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

func (*TestApp) ReloadApp added in v0.3.0

func (_app *TestApp) ReloadApp() *TestApp

func (*TestApp) SetMinGasPrice added in v0.3.6

func (_app *TestApp) SetMinGasPrice(gp uint64)

func (*TestApp) StoreBlocks added in v0.1.5

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

func (*TestApp) WaitMS added in v0.1.2

func (_app *TestApp) WaitMS(n int64)

func (*TestApp) WaitNextBlock added in v0.1.3

func (_app *TestApp) WaitNextBlock(currHeight int64)

type TestAppInitArgs added in v0.3.6

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