Documentation
¶
Index ¶
- Constants
- 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(address types.Address, rpcClient *jsonrpc.Client, t *testing.T) *big.Int
- func MethodSig(name string) []byte
- func MultiJoin(t *testing.T, srvs ...*TestServer)
- func MultiJoinSerial(t *testing.T, srvs []*TestServer)
- func ToLocalIPv4LibP2pAddr(port int, nodeID string) string
- 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 ConsensusType
- type IBFTServerConfigCallback
- type IBFTServersManager
- type InitIBFTResult
- type PreparedTransaction
- type ReservedPort
- type SrvAccount
- type TestServer
- func (t *TestServer) DeployContract(ctx context.Context, binary string) (web3.Address, error)
- func (t *TestServer) GenerateGenesis() error
- func (t *TestServer) GetLatestBlockHeight() (uint64, error)
- func (t *TestServer) GrpcAddr() string
- func (t *TestServer) InitIBFT() (*InitIBFTResult, error)
- func (t *TestServer) JSONRPC() *jsonrpc.Client
- func (t *TestServer) JsonRPCAddr() string
- func (t *TestServer) Operator() proto.SystemClient
- func (t *TestServer) ReleaseReservedPorts()
- func (t *TestServer) SendRawTx(ctx context.Context, tx *PreparedTransaction, signerKey *ecdsa.PrivateKey) (*web3.Receipt, error)
- func (t *TestServer) SendTxn(ctx context.Context, txn *web3.Transaction) (*web3.Receipt, error)
- func (t *TestServer) Start(ctx context.Context) error
- func (t *TestServer) Stop()
- func (t *TestServer) TxnPoolOperator() txpoolProto.TxnPoolOperatorClient
- func (t *TestServer) TxnTo(ctx context.Context, address web3.Address, method string) *web3.Receipt
- func (t *TestServer) WaitForReady(ctx context.Context) error
- func (t *TestServer) WaitForReceipt(ctx context.Context, hash web3.Hash) (*web3.Receipt, error)
- type TestServerConfig
- func (t *TestServerConfig) Premine(addr types.Address, amount *big.Int)
- func (t *TestServerConfig) SetBlockGasTarget(target uint64)
- func (t *TestServerConfig) SetBlockLimit(limit uint64)
- func (t *TestServerConfig) SetBootnodes(bootnodes []string)
- func (t *TestServerConfig) SetConsensus(c ConsensusType)
- func (t *TestServerConfig) SetDevInterval(interval int)
- func (t *TestServerConfig) SetIBFTDir(ibftDir string)
- func (t *TestServerConfig) SetIBFTDirPrefix(ibftDirPrefix string)
- func (t *TestServerConfig) SetLocals(locals []string)
- func (t *TestServerConfig) SetNoLocals(noLocals bool)
- func (t *TestServerConfig) SetPriceLimit(priceLimit *uint64)
- func (t *TestServerConfig) SetSeal(state bool)
- func (t *TestServerConfig) SetShowsLog(f bool)
- type TestServerConfigCallback
Constants ¶
const ( DefaultGasPrice = 1879048192 // 0x70000000 DefaultGasLimit = 5242880 // 0x500000 )
Variables ¶
This section is empty.
Functions ¶
func EcrecoverFromBlockhash ¶
func GetAccountBalance ¶
GetAccountBalance is a helper method for fetching the Balance field of an account
func MultiJoin ¶
func MultiJoin(t *testing.T, srvs ...*TestServer)
func MultiJoinSerial ¶
func MultiJoinSerial(t *testing.T, srvs []*TestServer)
func ToLocalIPv4LibP2pAddr ¶
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 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 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) DeployContract ¶
DeployContract deploys a contract with account 0 and returns the address
func (*TestServer) GenerateGenesis ¶
func (t *TestServer) GenerateGenesis() error
func (*TestServer) GetLatestBlockHeight ¶
func (t *TestServer) GetLatestBlockHeight() (uint64, error)
func (*TestServer) GrpcAddr ¶
func (t *TestServer) GrpcAddr() string
func (*TestServer) InitIBFT ¶
func (t *TestServer) InitIBFT() (*InitIBFTResult, error)
func (*TestServer) JSONRPC ¶
func (t *TestServer) JSONRPC() *jsonrpc.Client
func (*TestServer) JsonRPCAddr ¶
func (t *TestServer) JsonRPCAddr() string
func (*TestServer) Operator ¶
func (t *TestServer) Operator() proto.SystemClient
func (*TestServer) ReleaseReservedPorts ¶
func (t *TestServer) ReleaseReservedPorts()
func (*TestServer) SendRawTx ¶
func (t *TestServer) SendRawTx(ctx context.Context, tx *PreparedTransaction, signerKey *ecdsa.PrivateKey) (*web3.Receipt, error)
SendRawTx signs the transaction with the provided private key, executes it, and returns the receipt
func (*TestServer) SendTxn ¶
func (t *TestServer) SendTxn(ctx context.Context, txn *web3.Transaction) (*web3.Receipt, error)
func (*TestServer) Stop ¶
func (t *TestServer) Stop()
func (*TestServer) TxnPoolOperator ¶
func (t *TestServer) TxnPoolOperator() txpoolProto.TxnPoolOperatorClient
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
Seal bool // Flag indicating if blocks should be sealed
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)
Consensus ConsensusType // Consensus Type
Bootnodes []string // Bootnode Addresses
Locals []string // Accounts whose transactions are treated as locals
NoLocals bool // Flag to disable price exemptions for locally transactions
PriceLimit *uint64 // Minimum gas price limit to enforce for acceptance into the pool
DevInterval int // Dev consensus update interval [s]
BlockGasLimit uint64 // Block gas limit
BlockGasTarget uint64 // Gas target for new blocks
ShowsLog bool
}
TestServerConfig for the test server
func (*TestServerConfig) Premine ¶
func (t *TestServerConfig) Premine(addr types.Address, amount *big.Int)
CALLBACKS // Premine callback specifies an account with a balance (in WEI)
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) 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) 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) SetLocals ¶
func (t *TestServerConfig) SetLocals(locals []string)
SetLocals sets locals
func (*TestServerConfig) SetNoLocals ¶
func (t *TestServerConfig) SetNoLocals(noLocals bool)
SetLocals sets NoLocals flag
func (*TestServerConfig) SetPriceLimit ¶
func (t *TestServerConfig) SetPriceLimit(priceLimit *uint64)
SetLocals sets PriceLimit
func (*TestServerConfig) SetSeal ¶
func (t *TestServerConfig) SetSeal(state bool)
SetSeal callback toggles the seal mode
func (*TestServerConfig) SetShowsLog ¶
func (t *TestServerConfig) SetShowsLog(f bool)
SetShowsLog sets flag for logging
type TestServerConfigCallback ¶
type TestServerConfigCallback func(*TestServerConfig)