iotex-core: github.com/iotexproject/iotex-core/testutil Index | Files

package testutil

import "github.com/iotexproject/iotex-core/testutil"

Index

Package Files

file.go gas.go network.go signedaction.go timestamp.go wait.go

Constants

const TestGasLimit uint64 = 20000

TestGasLimit represents the gas limit used for test actions

const TestGasPriceInt64 = 0

TestGasPriceInt64 represents the gas price for test actions in int64

Variables

var ErrTimeout = errors.New("timed out")

ErrTimeout is returned when time is up

var TestGasPrice = big.NewInt(unit.Qev)

TestGasPrice represents the gas price for test actions in big int

func CleanupPath Uses

func CleanupPath(t *testing.T, path string)

CleanupPath detects the existence of test DB file and removes it if found

func PathOfTempFile Uses

func PathOfTempFile(dirName string) (string, error)

PathOfTempFile returns path of a new temporary file

func RandomPort Uses

func RandomPort() int

RandomPort returns a random port number between 30000 and 50000

func SignalChan Uses

func SignalChan(interval, timeout time.Duration) <-chan struct{}

SignalChan returns a channel that will be written every interval until timeout

func SignedCandidateRegister Uses

func SignedCandidateRegister(
    nonce uint64,
    name, operatorAddrStr, rewardAddrStr, ownerAddrStr, amountStr string,
    duration uint32,
    autoStake bool,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    registererPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedCandidateRegister returns a signed candidate register

func SignedCandidateUpdate Uses

func SignedCandidateUpdate(
    nonce uint64,
    name, operatorAddrStr, rewardAddrStr string,
    gasLimit uint64,
    gasPrice *big.Int,
    registererPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedCandidateUpdate returns a signed candidate update

func SignedChangeCandidate Uses

func SignedChangeCandidate(
    nonce uint64,
    candName string,
    bucketIndex uint64,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    stakerPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedChangeCandidate returns a signed change candidate

func SignedCreateStake Uses

func SignedCreateStake(nonce uint64,
    candidateName, amount string,
    duration uint32,
    autoStake bool,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    stakerPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedCreateStake returns a signed create stake

func SignedDepositToStake Uses

func SignedDepositToStake(
    nonce uint64,
    index uint64,
    amount string,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    depositorPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedDepositToStake returns a signed deposit to stake

func SignedExecution Uses

func SignedExecution(contractAddr string, executorPriKey crypto.PrivateKey, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) (action.SealedEnvelope, error)

SignedExecution return a signed execution

func SignedReclaimStake Uses

func SignedReclaimStake(
    withdraw bool,
    nonce uint64,
    bucketIndex uint64,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    reclaimerPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedReclaimStake returns a signed unstake or withdraw stake

func SignedRestake Uses

func SignedRestake(
    nonce uint64,
    index uint64,
    duration uint32,
    autoStake bool,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    restakerPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedRestake returns a signed restake

func SignedTransfer Uses

func SignedTransfer(recipientAddr string, senderPriKey crypto.PrivateKey, nonce uint64, amount *big.Int, payload []byte, gasLimit uint64, gasPrice *big.Int) (action.SealedEnvelope, error)

SignedTransfer return a signed transfer

func SignedTransferStake Uses

func SignedTransferStake(
    nonce uint64,
    voterAddress string,
    bucketIndex uint64,
    payload []byte,
    gasLimit uint64,
    gasPrice *big.Int,
    stakerPriKey crypto.PrivateKey,
) (action.SealedEnvelope, error)

SignedTransferStake returns a signed transfer stake

func TimestampNow Uses

func TimestampNow() time.Time

TimestampNow returns current time from new clock

func TimestampNowFromClock Uses

func TimestampNowFromClock(c clock.Clock) time.Time

TimestampNowFromClock get now time from specific clock

func WaitUntil Uses

func WaitUntil(interval, timeout time.Duration, f CheckCondition) error

WaitUntil periodically checks whether the condition specified in CheckCondition function is satisfied If an error is returned, it either comes from CheckCondition function or time is up before the given condition is satisfied

type CheckCondition Uses

type CheckCondition func() (bool, error)

CheckCondition defines a func type that checks whether a certain condition is satisfied

Package testutil imports 14 packages (graph) and is imported by 1 packages. Updated 2020-03-14. Refresh now. Tools for package owners.