framework

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(source, destination string) error

func RunCommand

func RunCommand(args []string, stdout io.Writer) error

RunCommand - calls a command line function

Types

type ClusterOption

type ClusterOption func(*TestClusterConfig)

func WithBlockGasLimit

func WithBlockGasLimit(blockGasLimit uint64) ClusterOption

func WithBootnodeCount

func WithBootnodeCount(cnt int) ClusterOption

func WithBridge

func WithBridge() ClusterOption

func WithContractDeployerAllowListAdmin

func WithContractDeployerAllowListAdmin(addr types.Address) ClusterOption

func WithContractDeployerAllowListEnabled

func WithContractDeployerAllowListEnabled(addr types.Address) ClusterOption

func WithContractDeployerBlockListAdmin

func WithContractDeployerBlockListAdmin(addr types.Address) ClusterOption

func WithContractDeployerBlockListEnabled

func WithContractDeployerBlockListEnabled(addr types.Address) ClusterOption

func WithEpochReward

func WithEpochReward(epochReward int) ClusterOption

func WithEpochSize

func WithEpochSize(epochSize int) ClusterOption

func WithGenesisState

func WithGenesisState(databasePath string, stateRoot types.Hash) ClusterOption

func WithMintableNativeToken

func WithMintableNativeToken(mintableToken bool) ClusterOption

func WithNativeTokenConfig

func WithNativeTokenConfig(tokenConfigRaw string) ClusterOption

func WithNonValidators

func WithNonValidators(num int) ClusterOption

func WithNumBlockConfirmations

func WithNumBlockConfirmations(numBlockConfirmations uint64) ClusterOption

func WithPremine

func WithPremine(addresses ...types.Address) ClusterOption

func WithPropertyTestLogging

func WithPropertyTestLogging() ClusterOption

func WithSecretsCallback

func WithSecretsCallback(fn func([]types.Address, *TestClusterConfig)) ClusterOption

func WithTransactionsAllowListAdmin

func WithTransactionsAllowListAdmin(addr types.Address) ClusterOption

func WithTransactionsAllowListEnabled

func WithTransactionsAllowListEnabled(addr types.Address) ClusterOption

func WithTransactionsBlockListAdmin

func WithTransactionsBlockListAdmin(addr types.Address) ClusterOption

func WithTransactionsBlockListEnabled

func WithTransactionsBlockListEnabled(addr types.Address) ClusterOption

func WithValidatorSnapshot

func WithValidatorSnapshot(validatorsLen uint64) ClusterOption

type TestBridge

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

func NewTestBridge

func NewTestBridge(t *testing.T, clusterConfig *TestClusterConfig) (*TestBridge, error)

func (*TestBridge) DepositERC20

func (t *TestBridge) DepositERC20(rootTokenAddr, rootPredicateAddr types.Address, receivers, amounts string) error

DepositERC20 function invokes bridge deposit ERC20 tokens (from the root to the child chain) with given receivers and amounts

func (*TestBridge) JSONRPCAddr

func (t *TestBridge) JSONRPCAddr() string

func (*TestBridge) SendExitTransaction

func (t *TestBridge) SendExitTransaction(exitHelper types.Address, exitID uint64,
	rootJSONRPCAddr, childJSONRPCAddr string) error

SendExitTransaction sends exit transaction to the root chain

func (*TestBridge) Start

func (t *TestBridge) Start() error

func (*TestBridge) Stop

func (t *TestBridge) Stop()

func (*TestBridge) WaitUntil

func (t *TestBridge) WaitUntil(pollFrequency, timeout time.Duration, handler func() (bool, error)) error

func (*TestBridge) WithdrawERC20

func (t *TestBridge) WithdrawERC20(senderKey, receivers, amounts, jsonRPCEndpoint string) error

WithdrawERC20 function is used to invoke bridge withdraw ERC20 tokens (from the child to the root chain) with given receivers and amounts

type TestCluster

type TestCluster struct {
	Config  *TestClusterConfig
	Servers []*TestServer
	Bridge  *TestBridge
	// contains filtered or unexported fields
}

func NewPropertyTestCluster

func NewPropertyTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *TestCluster

func NewTestCluster

func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *TestCluster

func (*TestCluster) Call

func (c *TestCluster) Call(t *testing.T, to types.Address, method *abi.Method,
	args ...interface{}) map[string]interface{}

func (*TestCluster) Deploy

func (c *TestCluster) Deploy(t *testing.T, sender ethgo.Key, bytecode []byte) *TestTxn

func (*TestCluster) ExistsCode

func (c *TestCluster) ExistsCode(t *testing.T, addr ethgo.Address) bool

func (*TestCluster) Fail

func (c *TestCluster) Fail(err error)

func (*TestCluster) InitSecrets

func (c *TestCluster) InitSecrets(prefix string, count int) ([]types.Address, error)

InitSecrets initializes account(s) secrets with given prefix. (secrets are being stored in the temp directory created by given e2e test execution)

func (*TestCluster) InitTestServer

func (c *TestCluster) InitTestServer(t *testing.T,
	dataDir string, isValidator bool, relayer bool)

func (*TestCluster) MethodTxn

func (c *TestCluster) MethodTxn(t *testing.T, sender ethgo.Key, target types.Address, input []byte) *TestTxn

func (*TestCluster) SendTxn

func (c *TestCluster) SendTxn(t *testing.T, sender ethgo.Key, txn *ethgo.Transaction) *TestTxn

SendTxn sends a transaction

func (*TestCluster) Stats

func (c *TestCluster) Stats(t *testing.T)

func (*TestCluster) Stop

func (c *TestCluster) Stop()

func (*TestCluster) Transfer

func (c *TestCluster) Transfer(t *testing.T, sender ethgo.Key, target types.Address, value *big.Int) *TestTxn

func (*TestCluster) WaitForBlock

func (c *TestCluster) WaitForBlock(n uint64, timeout time.Duration) error

func (*TestCluster) WaitForGeneric

func (c *TestCluster) WaitForGeneric(dur time.Duration, fn func(*TestServer) bool) error

WaitForGeneric waits until all running servers returns true from fn callback or timeout defined by dur occurs

func (*TestCluster) WaitForReady

func (c *TestCluster) WaitForReady(t *testing.T)

func (*TestCluster) WaitUntil

func (c *TestCluster) WaitUntil(timeout, pollFrequency time.Duration, handler func() bool) error

type TestClusterConfig

type TestClusterConfig struct {
	Name                 string
	Premine              []string // address[:amount]
	PremineValidators    []string // address[:amount]
	StakeAmounts         []string // address[:amount]
	MintableNativeToken  bool
	HasBridge            bool
	BootnodeCount        int
	NonValidatorCount    int
	WithLogs             bool
	WithStdout           bool
	LogsDir              string
	TmpDir               string
	BlockGasLimit        uint64
	ValidatorPrefix      string
	Binary               string
	ValidatorSetSize     uint64
	EpochSize            int
	EpochReward          int
	NativeTokenConfigRaw string
	SecretsCallback      func([]types.Address, *TestClusterConfig)

	ContractDeployerAllowListAdmin   []types.Address
	ContractDeployerAllowListEnabled []types.Address
	ContractDeployerBlockListAdmin   []types.Address
	ContractDeployerBlockListEnabled []types.Address
	TransactionsAllowListAdmin       []types.Address
	TransactionsAllowListEnabled     []types.Address
	TransactionsBlockListAdmin       []types.Address
	TransactionsBlockListEnabled     []types.Address

	NumBlockConfirmations uint64

	InitialTrieDB    string
	InitialStateRoot types.Hash

	IsPropertyTest bool
	// contains filtered or unexported fields
}

func (*TestClusterConfig) Dir

func (c *TestClusterConfig) Dir(name string) string

func (*TestClusterConfig) GetStdout

func (c *TestClusterConfig) GetStdout(name string, custom ...io.Writer) io.Writer

type TestServer

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

func NewTestServer

func NewTestServer(t *testing.T, clusterConfig *TestClusterConfig, callback TestServerConfigCallback) *TestServer

func (*TestServer) Conn

func (t *TestServer) Conn() proto.SystemClient

func (*TestServer) DataDir

func (t *TestServer) DataDir() string

func (*TestServer) Delegate

func (t *TestServer) Delegate(amount uint64, secrets string, validatorAddr ethgo.Address) error

Delegate delegates given amount by the account in secrets to validatorAddr validator

func (*TestServer) GrpcAddr

func (t *TestServer) GrpcAddr() string

func (*TestServer) HasValidatorSealed

func (t *TestServer) HasValidatorSealed(firstBlock, lastBlock uint64, validators polybft.AccountSet,
	validatorAddr ethgo.Address) (bool, error)

HasValidatorSealed checks whether given validator has signed at least single block for the given range of blocks

func (*TestServer) JSONRPC

func (t *TestServer) JSONRPC() *jsonrpc.Client

func (*TestServer) JSONRPCAddr

func (t *TestServer) JSONRPCAddr() string

func (*TestServer) RegisterValidator

func (t *TestServer) RegisterValidator(secrets string, stake string) error

RegisterValidator is a wrapper function which registers new validator with given balance and stake

func (*TestServer) Stake

func (t *TestServer) Stake(amount uint64) error

Stake stakes given amount to validator account encapsulated by given server instance

func (*TestServer) Start

func (t *TestServer) Start()

func (*TestServer) Stop

func (t *TestServer) Stop()

func (*TestServer) TxnPoolOperator

func (t *TestServer) TxnPoolOperator() txpoolProto.TxnPoolOperatorClient

func (*TestServer) Undelegate

func (t *TestServer) Undelegate(amount uint64, secrets string, validatorAddr ethgo.Address) error

Undelegate undelegates given amount by the account in secrets from validatorAddr validator

func (*TestServer) Unstake

func (t *TestServer) Unstake(amount uint64) error

Unstake unstakes given amount from validator account encapsulated by given server instance

func (*TestServer) WaitForNonZeroBalance

func (t *TestServer) WaitForNonZeroBalance(address ethgo.Address, dur time.Duration) (*big.Int, error)

func (*TestServer) WhitelistValidator

func (t *TestServer) WhitelistValidator(address, secrets string) error

WhitelistValidator invokes whitelist-validator helper CLI command, which sends whitelist transaction to ChildValidatorSet

func (*TestServer) Withdraw

func (t *TestServer) Withdraw(secrets string, recipient ethgo.Address) error

Withdraw withdraws available balance to provided recipient address

type TestServerConfig

type TestServerConfig struct {
	Name                  string
	JSONRPCPort           int64
	GRPCPort              int64
	P2PPort               int64
	Seal                  bool
	DataDir               string
	Chain                 string
	LogLevel              string
	Relayer               bool
	NumBlockConfirmations uint64
}

type TestServerConfigCallback

type TestServerConfigCallback func(*TestServerConfig)

type TestTxn

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

func (*TestTxn) Failed

func (t *TestTxn) Failed() bool

Failed returns whether the transaction failed

func (*TestTxn) Receipt

func (t *TestTxn) Receipt() *ethgo.Receipt

Receipt returns the receipt of the transaction

func (*TestTxn) Reverted

func (t *TestTxn) Reverted() bool

Reverted returns whether the transaction failed and was reverted consuming all the gas from the call

func (*TestTxn) Succeed

func (t *TestTxn) Succeed() bool

Succeed returns whether the transaction succeed and it was not reverted

func (*TestTxn) Txn

func (t *TestTxn) Txn() *ethgo.Transaction

Txn returns the raw transaction that was sent

func (*TestTxn) Wait

func (t *TestTxn) Wait() error

Wait waits for the transaction to be executed

Jump to

Keyboard shortcuts

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