Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateMeanGas(ctx context.Context, rpcAddress, msgType string, fromHeight int64, ...) (float64, int64, error)
- func CalculateMeanGasFromRecentBlocks(ctx context.Context, rpcAddress, msgType string, blocks int64) (float64, int64, error)
- func DecodeBlockData(data types.Data) ([]sdk.Msg, error)
- func DefaultAppConfig() *srvconfig.Config
- func DefaultGenesisState(fundedAccounts ...string) (map[string]json.RawMessage, keyring.Keyring, error)
- func DefaultParams() *tmproto.ConsensusParams
- func DefaultTendermintConfig() *config.Config
- func GetFreePort() int
- func QueryTx(clientCtx client.Context, hashHexStr string, prove bool) (*rpctypes.ResultTx, error)
- func ReadBlockHeights(ctx context.Context, rpcAddress string, fromHeight, toHeight int64) ([]*types.Block, error)
- func ReadBlockchain(ctx context.Context, rpcAddress string) ([]*types.Block, error)
- func ReadRecentBlocks(ctx context.Context, rpcAddress string, blocks int64) ([]*types.Block, error)
- func SignAndBroadcastTx(encCfg encoding.Config, c client.Context, account string, msg ...sdk.Msg) (res *sdk.TxResponse, err error)
- type Context
- func DefaultNetwork(t *testing.T) (accounts []string, cctx Context)
- func New(t testing.TB, cparams *tmproto.ConsensusParams, tmCfg *config.Config, ...) (*node.Node, srvtypes.Application, Context, error)
- func NewNetwork(t testing.TB, cparams *tmproto.ConsensusParams, tmCfg *config.Config, ...) (cctx Context, rpcAddr, grpcAddr string)
- func StartGRPCServer(app srvtypes.Application, appCfg *srvconfig.Config, cctx Context) (Context, func() error, error)
- func StartNode(tmNode *node.Node, cctx Context) (Context, func() error, error)
- func (c *Context) FillBlock(squareSize int, accounts []string, broadcastMode string) (*sdk.TxResponse, error)
- func (c *Context) GenesisTime() (time.Time, error)
- func (c *Context) GoContext() context.Context
- func (c *Context) HeightForTimestamp(timestamp time.Time) (int64, error)
- func (c *Context) LatestHeight() (int64, error)
- func (c *Context) LatestTimestamp() (time.Time, error)
- func (c *Context) PostData(account, broadcastMode string, ns appns.Namespace, blobData []byte) (*sdk.TxResponse, error)
- func (c *Context) WaitForBlocks(n int64) error
- func (c *Context) WaitForHeight(h int64) (int64, error)
- func (c *Context) WaitForHeightWithTimeout(h int64, t time.Duration) (int64, error)
- func (c *Context) WaitForNextBlock() error
- func (c *Context) WaitForTimestamp(t time.Time) (time.Time, error)
- func (c *Context) WaitForTimestampWithTimeout(t time.Time, d time.Duration) (time.Time, error)
- func (c *Context) WaitForTx(hashHexStr string, blocks int) (*rpctypes.ResultTx, error)
- type GenesisOption
Constants ¶
const (
DefaultTimeout = 30 * time.Second
)
Variables ¶
var NodeEVMPrivateKey, _ = crypto.HexToECDSA("64a1d6f0e760a8d62b4afdde4096f16f51b401eaaecc915740f71770ea76a8ad")
NodeEVMPrivateKey the key used to initialize the test node validator. Its corresponding address is: "0x9c2B12b5a07FC6D719Ed7646e5041A7E85758329".
Functions ¶
func CalculateMeanGas ¶
func DefaultAppConfig ¶
DefaultAppConfig wraps the default config described in the server
func DefaultGenesisState ¶
func DefaultGenesisState(fundedAccounts ...string) (map[string]json.RawMessage, keyring.Keyring, error)
DefaultGenesisState returns a default genesis state and a keyring with accounts that have coins. It adds a default "validator" account that is funded and used for the valop address of the single validator. The keyring accounts are based on the fundedAccounts parameter.
func DefaultParams ¶
func DefaultParams() *tmproto.ConsensusParams
func DefaultTendermintConfig ¶
func GetFreePort ¶
func GetFreePort() int
func ReadBlockHeights ¶
func ReadBlockchain ¶
func ReadRecentBlocks ¶
Types ¶
type Context ¶
func DefaultNetwork ¶
DefaultNetwork starts a single valiator celestia-app network using test friendly defaults. These defaults include all default values and genesis params, modified for fast block times and 300 funded accounts. The returned client.Context has a keyring with all of the funded keys stored in it, which can be accessed using the returned accounts.
func New ¶
func New( t testing.TB, cparams *tmproto.ConsensusParams, tmCfg *config.Config, supressLog bool, genState map[string]json.RawMessage, kr keyring.Keyring, chainID string, ) (*node.Node, srvtypes.Application, Context, error)
New creates a ready to use tendermint node that operates a single validator celestia-app network using the provided genesis state. The provided keyring is stored in the client.Context that is returned.
NOTE: the forced delay between blocks, TimeIotaMs in the consensus parameters, is set to the lowest possible value (1ms).
func NewNetwork ¶
func NewNetwork( t testing.TB, cparams *tmproto.ConsensusParams, tmCfg *config.Config, appCfg *srvconfig.Config, accounts []string, genesisOpts ...GenesisOption, ) (cctx Context, rpcAddr, grpcAddr string)
NewNetwork starts a single valiator celestia-app network using the provided configurations. Provided accounts will be funded and their keys can be accessed in keyring returned client.Context. All rpc, p2p, and grpc addresses in the provided configs are overwritten to use open ports. The node can be accessed via the returned client.Context or via the returned rpc and grpc addresses. Provided genesis options will be applied after all accounts have been initialized.
func StartGRPCServer ¶
func StartGRPCServer(app srvtypes.Application, appCfg *srvconfig.Config, cctx Context) (Context, func() error, error)
StartGRPCServer starts the grpc server using the provided application and config. A grpc client connection to that server is also added to the client context. The returned function should be used to shutdown the server.
func StartNode ¶
StartNode starts the tendermint node along with a local core rpc client. The rpc is returned via the client.Context. The function returned should be called during cleanup to teardown the node, core client, along with canceling the internal context.Context in the returned Context.
func (*Context) FillBlock ¶
func (c *Context) FillBlock(squareSize int, accounts []string, broadcastMode string) (*sdk.TxResponse, error)
FillBlock creates and submits a single transaction that is large enough to create a square of the desired size. broadcast mode indicates if the tx should be submitted async, sync, or block. (see flags.BroadcastModeSync). If broadcast mode is the string zero value, then it will be set to block.
func (*Context) GenesisTime ¶
GenesisTime returns the genesis block time.
func (*Context) HeightForTimestamp ¶
HeightForTimestamp returns the block height for the first block after a given timestamp.
func (*Context) LatestHeight ¶
LatestHeight returns the latest height of the network or an error if the query fails.
func (*Context) LatestTimestamp ¶
LatestTimestamp returns the latest timestamp of the network or an error if the query fails.
func (*Context) PostData ¶
func (c *Context) PostData(account, broadcastMode string, ns appns.Namespace, blobData []byte) (*sdk.TxResponse, error)
PostData will create and submit PFB transaction containing the namespace and blobData. This function blocks until the PFB has been included in a block and returns an error if the transaction is invalid or is rejected by the mempool.
func (*Context) WaitForBlocks ¶
WaitForBlocks waits until n blocks have been committed, returning an error upon failure.
func (*Context) WaitForHeight ¶
WaitForHeight performs a blocking check where it waits for a block to be committed after a given block. If that height is not reached within a timeout, an error is returned. Regardless, the latest height queried is returned.
func (*Context) WaitForHeightWithTimeout ¶
WaitForHeightWithTimeout is the same as WaitForHeight except the caller can provide a custom timeout.
func (*Context) WaitForNextBlock ¶
WaitForNextBlock waits for the next block to be committed, returning an error upon failure.
func (*Context) WaitForTimestamp ¶
WaitForTimestamp performs a blocking check where it waits for a block to be committed after a given timestamp. If that height is not reached within a timeout, an error is returned. Regardless, the latest timestamp queried is returned.
func (*Context) WaitForTimestampWithTimeout ¶
WaitForTimestampWithTimeout waits for a block with a timestamp greater than t.
type GenesisOption ¶
type GenesisOption func(state map[string]json.RawMessage) map[string]json.RawMessage
GenesisOption allows for arbitrary changes to be made on the genesis state after initial accounts have been added. It accepts the genesis state as input and is expected to return the modifed genesis as output.
func ImmediateProposals ¶
func ImmediateProposals(codec codec.Codec) GenesisOption
ImmediateProposals sets the thresholds for getting a gov proposal to very low levels.
func SetBlobParams ¶
func SetBlobParams(codec codec.Codec, params blobtypes.Params) GenesisOption
SetBlobParams will set the provided blob params as genesis state.