Documentation ¶
Index ¶
- Constants
- Variables
- func EcrecoverFromBlockhash(hash types.Hash, signature []byte) (types.Address, error)
- func EthToWei(ethValue int64) *big.Int
- func EthToWeiPrecise(ethValue int64, decimals int64) *big.Int
- func GetAccountBalance(t *testing.T, address types.Address, rpcClient *jsonrpc.Client) *big.Int
- func GetStakedAmount(from types.Address, rpcClient *jsonrpc.Client) (*big.Int, error)
- func GetValidatorSet(from types.Address, rpcClient *jsonrpc.Client) ([]types.Address, error)
- func MethodSig(name string) []byte
- func MethodSigWithParams(nameWithParams string) []byte
- func MultiJoin(t *testing.T, srvs ...*TestServer)
- func MultiJoinSerial(t *testing.T, srvs []*TestServer)
- func StakeAmount(from types.Address, senderKey *ecdsa.PrivateKey, amount *big.Int, ...) error
- func ToLocalIPv4LibP2pAddr(port int, nodeID string) string
- func UnstakeAmount(from types.Address, senderKey *ecdsa.PrivateKey, srv *TestServer) (*ethgo.Receipt, error)
- func WaitForServersToSeal(servers []*TestServer, desiredHeight uint64) []error
- func WaitUntilBlockMined(ctx context.Context, srv *TestServer, desiredHeight uint64) (uint64, error)
- func WaitUntilPeerConnects(ctx context.Context, srv *TestServer, requiredNum int) (*proto.PeersListResponse, error)
- func WaitUntilTxPoolFilled(ctx context.Context, srv *TestServer, requiredNum uint64) (*txpoolProto.TxnPoolStatusResp, error)
- type AtomicErrors
- type ConsensusType
- type IBFTServerConfigCallback
- type IBFTServersManager
- type InitIBFTResult
- type PredeployParams
- type PreparedTransaction
- type ReservedPort
- type SrvAccount
- type TestServer
- func (t *TestServer) CallJSONRPC(req map[string]interface{}) map[string]interface{}
- func (t *TestServer) DeployContract(ctx context.Context, binary string, privateKey *ecdsa.PrivateKey) (ethgo.Address, error)
- func (t *TestServer) GenerateGenesis() error
- func (t *TestServer) GenesisPredeploy() error
- func (t *TestServer) GetGasTotal(txHashes []ethgo.Hash) uint64
- func (t *TestServer) GetLatestBlockHeight() (uint64, error)
- func (t *TestServer) GetStdout() io.Writer
- func (t *TestServer) GrpcAddr() string
- func (t *TestServer) HTTPJSONRPCURL() string
- func (t *TestServer) IBFTOperator() ibftOp.IbftOperatorClient
- func (t *TestServer) InvokeMethod(ctx context.Context, contractAddress types.Address, method string, ...) *ethgo.Receipt
- func (t *TestServer) JSONRPC() *jsonrpc.Client
- func (t *TestServer) JSONRPCAddr() string
- func (t *TestServer) LibP2PAddr() string
- func (t *TestServer) Operator() proto.SystemClient
- func (t *TestServer) ReleaseReservedPorts()
- func (t *TestServer) SecretsInit() (*InitIBFTResult, error)
- func (t *TestServer) SendRawTx(ctx context.Context, tx *PreparedTransaction, signerKey *ecdsa.PrivateKey) (*ethgo.Receipt, error)
- func (t *TestServer) SignTx(transaction *types.Transaction, privateKey *ecdsa.PrivateKey) (*types.Transaction, error)
- func (t *TestServer) Start(ctx context.Context) error
- func (t *TestServer) Stop()
- func (t *TestServer) SwitchIBFTType(typ fork.IBFTType, from uint64, to, deployment *uint64) error
- func (t *TestServer) Txn(key *wallet.Key) *Txn
- func (t *TestServer) TxnPoolOperator() txpoolProto.TxnPoolOperatorClient
- func (t *TestServer) WSJSONRPCURL() string
- func (t *TestServer) WaitForReady(ctx context.Context) error
- func (t *TestServer) WaitForReceipt(ctx context.Context, hash ethgo.Hash) (*ethgo.Receipt, error)
- type TestServerConfig
- func (t *TestServerConfig) DataDir() string
- func (t *TestServerConfig) Premine(addr types.Address, amount *big.Int)
- func (t *TestServerConfig) PremineValidatorBalance(balance *big.Int)
- func (t *TestServerConfig) PrivateKey() (*ecdsa.PrivateKey, error)
- func (t *TestServerConfig) SetBlockGasTarget(target uint64)
- func (t *TestServerConfig) SetBlockLimit(limit uint64)
- func (t *TestServerConfig) SetBlockTime(blockTime uint64)
- func (t *TestServerConfig) SetBootnodes(bootnodes []string)
- func (t *TestServerConfig) SetConsensus(c ConsensusType)
- func (t *TestServerConfig) SetDevInterval(interval int)
- func (t *TestServerConfig) SetDevStakingAddresses(stakingAddresses []types.Address)
- func (t *TestServerConfig) SetEpochSize(epochSize uint64)
- func (t *TestServerConfig) SetIBFTBaseTimeout(baseTimeout uint64)
- func (t *TestServerConfig) SetIBFTDir(ibftDir string)
- func (t *TestServerConfig) SetIBFTDirPrefix(ibftDirPrefix string)
- func (t *TestServerConfig) SetIBFTPoS(value bool)
- func (t *TestServerConfig) SetLogsDir(dir string)
- func (t *TestServerConfig) SetMaxValidatorCount(val uint64)
- func (t *TestServerConfig) SetMinValidatorCount(val uint64)
- func (t *TestServerConfig) SetName(name string)
- func (t *TestServerConfig) SetPredeployParams(params *PredeployParams)
- func (t *TestServerConfig) SetPriceLimit(priceLimit *uint64)
- func (t *TestServerConfig) SetSaveLogs(f bool)
- func (t *TestServerConfig) SetShowsLog(f bool)
- func (t *TestServerConfig) SetSigner(signer *crypto.EIP155Signer)
- func (t *TestServerConfig) SetValidatorType(vt validators.ValidatorType)
- type TestServerConfigCallback
- type Txn
- func (t *Txn) Complete() bool
- func (t *Txn) Deploy(input []byte) *Txn
- func (t *Txn) GasLimit(gas uint64) *Txn
- func (t *Txn) GasPrice(price uint64) *Txn
- func (t *Txn) NoFail(tt *testing.T)
- func (t *Txn) Nonce(nonce uint64) *Txn
- func (t *Txn) Receipt() *ethgo.Receipt
- func (t *Txn) Send() *Txn
- func (t *Txn) To(to ethgo.Address) *Txn
- func (t *Txn) Transfer(to ethgo.Address, value *big.Int) *Txn
- func (t *Txn) Value(value *big.Int) *Txn
- func (t *Txn) Wait()
Constants ¶
const ( DefaultGasPrice = 1879048192 // 0x70000000 DefaultGasLimit = 5242880 // 0x500000 )
Variables ¶
var (
DefaultTimeout = time.Minute
)
Functions ¶
func EcrecoverFromBlockhash ¶
func GetAccountBalance ¶
GetAccountBalance is a helper method for fetching the Balance field of an account
func GetStakedAmount ¶
GetStakedAmount is a helper function for getting the staked amount on the Staking SC
func GetValidatorSet ¶
GetValidatorSet returns the validator set from the SC
func MethodSigWithParams ¶
MethodSigWithParams returns the signature of a function
func MultiJoin ¶
func MultiJoin(t *testing.T, srvs ...*TestServer)
func MultiJoinSerial ¶
func MultiJoinSerial(t *testing.T, srvs []*TestServer)
func StakeAmount ¶
func StakeAmount( from types.Address, senderKey *ecdsa.PrivateKey, amount *big.Int, srv *TestServer, ) error
StakeAmount is a helper function for staking an amount on the Staking SC
func ToLocalIPv4LibP2pAddr ¶
func UnstakeAmount ¶
func UnstakeAmount( from types.Address, senderKey *ecdsa.PrivateKey, srv *TestServer, ) (*ethgo.Receipt, error)
UnstakeAmount is a helper function for unstaking the entire amount on the Staking SC
func WaitForServersToSeal ¶
func WaitForServersToSeal(servers []*TestServer, desiredHeight uint64) []error
func WaitUntilBlockMined ¶
func WaitUntilBlockMined(ctx context.Context, srv *TestServer, desiredHeight uint64) (uint64, error)
WaitUntilBlockMined waits until server mined block with bigger height than given height otherwise returns timeout
func WaitUntilPeerConnects ¶
func WaitUntilPeerConnects(ctx context.Context, srv *TestServer, requiredNum int) (*proto.PeersListResponse, error)
WaitUntilPeerConnects waits until server connects to required number of peers otherwise returns timeout
func WaitUntilTxPoolFilled ¶
func WaitUntilTxPoolFilled( ctx context.Context, srv *TestServer, requiredNum uint64, ) (*txpoolProto.TxnPoolStatusResp, error)
WaitUntilTxPoolFilled waits until node has required number of transactions in txpool, otherwise returns timeout
Types ¶
type AtomicErrors ¶
func NewAtomicErrors ¶
func NewAtomicErrors(capacity int) AtomicErrors
func (*AtomicErrors) Append ¶
func (a *AtomicErrors) Append(err error)
func (*AtomicErrors) Errors ¶
func (a *AtomicErrors) Errors() []error
type ConsensusType ¶
type ConsensusType int
const ( ConsensusIBFT ConsensusType = iota ConsensusDev ConsensusDummy )
type IBFTServerConfigCallback ¶
type IBFTServerConfigCallback func(index int, config *TestServerConfig)
type IBFTServersManager ¶
type IBFTServersManager struct {
// contains filtered or unexported fields
}
func NewIBFTServersManager ¶
func NewIBFTServersManager( t *testing.T, numNodes int, ibftDirPrefix string, callback IBFTServerConfigCallback, ) *IBFTServersManager
func (*IBFTServersManager) GetServer ¶
func (m *IBFTServersManager) GetServer(i int) *TestServer
func (*IBFTServersManager) StartServers ¶
func (m *IBFTServersManager) StartServers(ctx context.Context)
func (*IBFTServersManager) StopServers ¶
func (m *IBFTServersManager) StopServers()
type InitIBFTResult ¶
type PredeployParams ¶
type PreparedTransaction ¶
type ReservedPort ¶
type ReservedPort struct {
// contains filtered or unexported fields
}
ReservedPort keeps available port until use
func FindAvailablePort ¶
func FindAvailablePort(from, to int) *ReservedPort
func FindAvailablePorts ¶
func FindAvailablePorts(n, from, to int) ([]ReservedPort, error)
func (*ReservedPort) Close ¶
func (p *ReservedPort) Close() error
func (*ReservedPort) IsClosed ¶
func (p *ReservedPort) IsClosed() bool
func (*ReservedPort) Port ¶
func (p *ReservedPort) Port() int
type TestServer ¶
type TestServer struct { Config *TestServerConfig // contains filtered or unexported fields }
func NewTestServer ¶
func NewTestServer(t *testing.T, rootDir string, callback TestServerConfigCallback) *TestServer
func NewTestServers ¶
func NewTestServers(t *testing.T, num int, conf func(*TestServerConfig)) []*TestServer
func (*TestServer) CallJSONRPC ¶
func (t *TestServer) CallJSONRPC(req map[string]interface{}) map[string]interface{}
func (*TestServer) DeployContract ¶
func (t *TestServer) DeployContract( ctx context.Context, binary string, privateKey *ecdsa.PrivateKey, ) (ethgo.Address, error)
DeployContract deploys a contract with account 0 and returns the address
func (*TestServer) GenerateGenesis ¶
func (t *TestServer) GenerateGenesis() error
func (*TestServer) GenesisPredeploy ¶
func (t *TestServer) GenesisPredeploy() error
func (*TestServer) GetGasTotal ¶
func (t *TestServer) GetGasTotal(txHashes []ethgo.Hash) uint64
GetGasTotal waits for the total gas used sum for the passed in transactions
func (*TestServer) GetLatestBlockHeight ¶
func (t *TestServer) GetLatestBlockHeight() (uint64, error)
func (*TestServer) GetStdout ¶
func (t *TestServer) GetStdout() io.Writer
GetStdout returns the combined stdout writers of the server
func (*TestServer) GrpcAddr ¶
func (t *TestServer) GrpcAddr() string
func (*TestServer) HTTPJSONRPCURL ¶
func (t *TestServer) HTTPJSONRPCURL() string
func (*TestServer) IBFTOperator ¶
func (t *TestServer) IBFTOperator() ibftOp.IbftOperatorClient
func (*TestServer) InvokeMethod ¶
func (t *TestServer) InvokeMethod( ctx context.Context, contractAddress types.Address, method string, fromKey *ecdsa.PrivateKey, ) *ethgo.Receipt
func (*TestServer) JSONRPC ¶
func (t *TestServer) JSONRPC() *jsonrpc.Client
func (*TestServer) JSONRPCAddr ¶
func (t *TestServer) JSONRPCAddr() string
func (*TestServer) LibP2PAddr ¶
func (t *TestServer) LibP2PAddr() string
func (*TestServer) Operator ¶
func (t *TestServer) Operator() proto.SystemClient
func (*TestServer) ReleaseReservedPorts ¶
func (t *TestServer) ReleaseReservedPorts()
func (*TestServer) SecretsInit ¶
func (t *TestServer) SecretsInit() (*InitIBFTResult, error)
func (*TestServer) SendRawTx ¶
func (t *TestServer) SendRawTx( ctx context.Context, tx *PreparedTransaction, signerKey *ecdsa.PrivateKey, ) (*ethgo.Receipt, error)
SendRawTx signs the transaction with the provided private key, executes it, and returns the receipt
func (*TestServer) SignTx ¶
func (t *TestServer) SignTx( transaction *types.Transaction, privateKey *ecdsa.PrivateKey, ) (*types.Transaction, error)
SignTx is a helper method for signing transactions
func (*TestServer) Stop ¶
func (t *TestServer) Stop()
func (*TestServer) SwitchIBFTType ¶
func (*TestServer) TxnPoolOperator ¶
func (t *TestServer) TxnPoolOperator() txpoolProto.TxnPoolOperatorClient
func (*TestServer) WSJSONRPCURL ¶
func (t *TestServer) WSJSONRPCURL() string
func (*TestServer) WaitForReady ¶
func (t *TestServer) WaitForReady(ctx context.Context) error
func (*TestServer) WaitForReceipt ¶
type TestServerConfig ¶
type TestServerConfig struct { ReservedPorts []ReservedPort JSONRPCPort int // The JSON RPC endpoint port GRPCPort int // The GRPC endpoint port LibP2PPort int // The Libp2p endpoint port RootDir string // The root directory for test environment IBFTDirPrefix string // The prefix of data directory for IBFT IBFTDir string // The name of data directory for IBFT PremineAccts []*SrvAccount // Accounts with existing balances (genesis accounts) GenesisValidatorBalance *big.Int // Genesis the balance for the validators DevStakers []types.Address // List of initial staking addresses for the staking SC Consensus ConsensusType // Consensus MechanismType ValidatorType validators.ValidatorType // Validator Type Bootnodes []string // Bootnode Addresses PriceLimit *uint64 // Minimum gas price limit to enforce for acceptance into the pool DevInterval int // Dev consensus update interval [s] EpochSize uint64 // The epoch size in blocks for the IBFT layer BlockGasLimit uint64 // Block gas limit BlockGasTarget uint64 // Gas target for new blocks ShowsLog bool // Flag specifying if logs are shown Name string // Name of the server SaveLogs bool // Flag specifying if logs are saved LogsDir string // Directory where logs are saved IsPos bool // Specifies the mechanism used for IBFT (PoA / PoS) Signer *crypto.EIP155Signer // Signer used for transactions MinValidatorCount uint64 // Min validator count MaxValidatorCount uint64 // Max validator count BlockTime uint64 // Minimum block generation time (in s) IBFTBaseTimeout uint64 // Base Timeout in seconds for IBFT PredeployParams *PredeployParams }
TestServerConfig for the test server
func (*TestServerConfig) DataDir ¶
func (t *TestServerConfig) DataDir() string
DataDir returns path of data directory server uses
func (*TestServerConfig) Premine ¶
func (t *TestServerConfig) Premine(addr types.Address, amount *big.Int)
Premine callback specifies an account with a balance (in WEI)
func (*TestServerConfig) PremineValidatorBalance ¶
func (t *TestServerConfig) PremineValidatorBalance(balance *big.Int)
PremineValidatorBalance callback sets the genesis balance of the validator the server manages (in WEI)
func (*TestServerConfig) PrivateKey ¶
func (t *TestServerConfig) PrivateKey() (*ecdsa.PrivateKey, error)
PrivateKey returns a private key in data directory
func (*TestServerConfig) SetBlockGasTarget ¶
func (t *TestServerConfig) SetBlockGasTarget(target uint64)
SetBlockGasTarget sets the gas target for the test server
func (*TestServerConfig) SetBlockLimit ¶
func (t *TestServerConfig) SetBlockLimit(limit uint64)
SetBlockLimit sets the block gas limit
func (*TestServerConfig) SetBlockTime ¶
func (t *TestServerConfig) SetBlockTime(blockTime uint64)
func (*TestServerConfig) SetBootnodes ¶
func (t *TestServerConfig) SetBootnodes(bootnodes []string)
SetBootnodes sets bootnodes
func (*TestServerConfig) SetConsensus ¶
func (t *TestServerConfig) SetConsensus(c ConsensusType)
SetConsensus callback sets consensus
func (*TestServerConfig) SetDevInterval ¶
func (t *TestServerConfig) SetDevInterval(interval int)
SetDevInterval sets the update interval for the dev consensus
func (*TestServerConfig) SetDevStakingAddresses ¶
func (t *TestServerConfig) SetDevStakingAddresses(stakingAddresses []types.Address)
SetDevStakingAddresses sets the Staking smart contract staker addresses for the dev mode. These addresses should be passed into the `ibft-validator` flag in genesis generation. Since invoking the dev consensus will not generate the ibft base folders, this is the only way to signalize to the genesis creation process who the validators are
func (*TestServerConfig) SetEpochSize ¶
func (t *TestServerConfig) SetEpochSize(epochSize uint64)
SetEpochSize sets the epoch size for the consensus layer. It controls the rate at which the validator set is updated
func (*TestServerConfig) SetIBFTBaseTimeout ¶
func (t *TestServerConfig) SetIBFTBaseTimeout(baseTimeout uint64)
func (*TestServerConfig) SetIBFTDir ¶
func (t *TestServerConfig) SetIBFTDir(ibftDir string)
SetIBFTDir callback sets the name of data directory for IBFT
func (*TestServerConfig) SetIBFTDirPrefix ¶
func (t *TestServerConfig) SetIBFTDirPrefix(ibftDirPrefix string)
SetIBFTDirPrefix callback sets prefix of IBFT directories
func (*TestServerConfig) SetIBFTPoS ¶
func (t *TestServerConfig) SetIBFTPoS(value bool)
SetIBFTPoS sets the flag indicating the IBFT mechanism
func (*TestServerConfig) SetLogsDir ¶
func (t *TestServerConfig) SetLogsDir(dir string)
SetLogsDir sets the directory where logs are saved
func (*TestServerConfig) SetMaxValidatorCount ¶
func (t *TestServerConfig) SetMaxValidatorCount(val uint64)
SetMaxValidatorCount sets the max validator count
func (*TestServerConfig) SetMinValidatorCount ¶
func (t *TestServerConfig) SetMinValidatorCount(val uint64)
SetMinValidatorCount sets the min validator count
func (*TestServerConfig) SetName ¶
func (t *TestServerConfig) SetName(name string)
SetName sets the name of the server
func (*TestServerConfig) SetPredeployParams ¶
func (t *TestServerConfig) SetPredeployParams(params *PredeployParams)
func (*TestServerConfig) SetPriceLimit ¶
func (t *TestServerConfig) SetPriceLimit(priceLimit *uint64)
SetPriceLimit sets the gas price limit
func (*TestServerConfig) SetSaveLogs ¶
func (t *TestServerConfig) SetSaveLogs(f bool)
SetSaveLogs sets flag for saving logs
func (*TestServerConfig) SetShowsLog ¶
func (t *TestServerConfig) SetShowsLog(f bool)
SetShowsLog sets flag for logging
func (*TestServerConfig) SetSigner ¶
func (t *TestServerConfig) SetSigner(signer *crypto.EIP155Signer)
func (*TestServerConfig) SetValidatorType ¶
func (t *TestServerConfig) SetValidatorType(vt validators.ValidatorType)
SetValidatorType callback sets validator type
type TestServerConfigCallback ¶
type TestServerConfigCallback func(*TestServerConfig)