Documentation
¶
Index ¶
- Constants
- Variables
- func HasTestVerboseFlag() bool
- type App
- func (a App) APIQuery(ctx context.Context, chainAPI, namespace, module, method string, ...) []byte
- func (a *App) Binary() string
- func (a App) CLIQuery(chainRPC, module, method string, args ...string) []byte
- func (a App) CLIQueryTx(chainRPC, txHash string) (txResponse TxResponse)
- func (a App) CLITx(chainRPC, module, method string, args ...string) TxResponse
- func (a *App) Config() chainconfig.Config
- func (a *App) EditConfig(apply func(*chainconfig.Config))
- func (a *App) EnableFaucet(coins, coinsMax []string) (faucetAddr string)
- func (a *App) EnsureSteady()
- func (a *App) Generate(msg string, shouldFail bool, args ...string)
- func (a *App) GenerateTSClient() bool
- func (a *App) MustServe(ctx context.Context)
- func (a *App) RandomizeServerPorts() Hosts
- func (a *App) RunChainAndSimulateTxs(servers Hosts)
- func (a *App) RunSimulationTxs(ctx context.Context, servers Hosts)
- func (a *App) Scaffold(msg string, shouldFail bool, typeName string, args ...string)
- func (a *App) SendListTxsAndQueryFirst(ctx context.Context, servers Hosts, module string, name multiformatname.Name, ...)
- func (a *App) SendMapTxsAndQuery(ctx context.Context, servers Hosts, module string, name multiformatname.Name, ...)
- func (a *App) SendSingleTxsAndQuery(ctx context.Context, servers Hosts, module string, name multiformatname.Name, ...)
- func (a *App) SendTxsAndQuery(ctx context.Context, servers Hosts, module string, name multiformatname.Name, ...)
- func (a *App) Serve(msg string, options ...ExecOption) (ok bool)
- func (a *App) SetConfigPath(path string)
- func (a *App) SetHomePath(homePath string)
- func (a *App) Simulate(numBlocks, blockSize int)
- func (a *App) SourcePath() string
- func (a *App) UseRandomHomeDir() (homeDirPath string)
- func (a *App) WaitChainUp(ctx context.Context, chainAPI string)
- type AppOption
- type Env
- func (e Env) App(namespace, appPath string, options ...AppOption) App
- func (e Env) AppHome(name string) string
- func (e Env) Ctx() context.Context
- func (e Env) Exec(msg string, steps step.Steps, options ...ExecOption) (ok bool)
- func (e Env) HasFailed() bool
- func (e Env) Home() string
- func (e Env) IsAppServed(ctx context.Context, apiAddr string) error
- func (e Env) IsFaucetServed(ctx context.Context, faucetClient cosmosfaucet.HTTPClient) error
- func (e Env) Must(ok bool)
- func (e Env) RequireExpectations()
- func (e Env) ScaffoldApp(namespace string, flags ...string) App
- func (e Env) SetCleanup(f func())
- func (e Env) T() *testing.T
- func (e Env) TmpDir() (path string)
- type ExecOption
- type Hosts
- type TxResponse
Constants ¶
const ServeTimeout = time.Minute * 15
Variables ¶
Functions ¶
func HasTestVerboseFlag ¶
func HasTestVerboseFlag() bool
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) Binary ¶
Binary returns the binary name of the app. Can be executed directly w/o any path after app.Serve is called, since it should be in the $PATH.
func (App) CLIQueryTx ¶ added in v29.1.0
func (a App) CLIQueryTx(chainRPC, txHash string) (txResponse TxResponse)
func (App) CLITx ¶ added in v29.1.0
func (a App) CLITx(chainRPC, module, method string, args ...string) TxResponse
func (*App) Config ¶
func (a *App) Config() chainconfig.Config
func (*App) EditConfig ¶
func (a *App) EditConfig(apply func(*chainconfig.Config))
func (*App) EnableFaucet ¶
EnableFaucet enables faucet by finding a random port for the app faucet and update config.yml with this port and provided coins options.
func (*App) EnsureSteady ¶
func (a *App) EnsureSteady()
EnsureSteady ensures that app living at the path can compile and its tests are passing.
func (*App) Generate ¶ added in v29.1.0
Generate executes a code generation command in the app and optionally validates if it should fail. - msg: description of the generation operation. - shouldFail: whether the generation is expected to fail. - args: arguments for the generation command.
func (*App) GenerateTSClient ¶
GenerateTSClient runs the command to generate the Typescript client code.
func (*App) MustServe ¶ added in v29.1.0
MustServe serves the application and ensures success, failing the test if serving fails. It uses the provided context to allow cancellation.
func (*App) RandomizeServerPorts ¶
RandomizeServerPorts randomizes server ports for the app at path, updates its config.yml and returns new values.
func (*App) RunChainAndSimulateTxs ¶ added in v29.1.0
RunChainAndSimulateTxs starts the blockchain network and runs transaction simulations.
func (*App) RunSimulationTxs ¶ added in v29.1.0
RunSimulationTxs runs different types of transactions for modules and queries the chain.
func (*App) Scaffold ¶ added in v29.1.0
Scaffold scaffolds a new module or component in the app and optionally validates if it should fail. - msg: description of the scaffolding operation. - shouldFail: whether the scaffolding is expected to fail. - typeName: the type of the scaffold (e.g., "map", "message"). - args: additional arguments for the scaffold command.
func (*App) SendListTxsAndQueryFirst ¶ added in v29.1.0
func (a *App) SendListTxsAndQueryFirst( ctx context.Context, servers Hosts, module string, name multiformatname.Name, fields field.Fields, )
SendListTxsAndQueryFirst sends a list transaction and queries the first element using both CLI and API.
func (*App) SendMapTxsAndQuery ¶ added in v29.1.0
func (a *App) SendMapTxsAndQuery( ctx context.Context, servers Hosts, module string, name multiformatname.Name, fields field.Fields, index field.Field, )
SendMapTxsAndQuery sends a map transaction and queries the element using both CLI and API.
func (*App) SendSingleTxsAndQuery ¶ added in v29.1.0
func (a *App) SendSingleTxsAndQuery( ctx context.Context, servers Hosts, module string, name multiformatname.Name, fields field.Fields, )
SendSingleTxsAndQuery submits a single transaction and queries the result from both CLI and API.
func (*App) SendTxsAndQuery ¶ added in v29.1.0
func (a *App) SendTxsAndQuery( ctx context.Context, servers Hosts, module string, name multiformatname.Name, fields field.Fields, index string, )
SendTxsAndQuery sends a transaction and queries the element using both CLI and API.
func (*App) Serve ¶
func (a *App) Serve(msg string, options ...ExecOption) (ok bool)
Serve serves an application lives under path with options where msg describes the execution from the serving action. unless calling with Must(), Serve() will not exit test runtime on failure.
func (*App) SetConfigPath ¶
func (*App) SetHomePath ¶
func (*App) SourcePath ¶
func (*App) UseRandomHomeDir ¶
UseRandomHomeDir sets in the blockchain config files generated temporary directories for home directories. Returns the random home directory.
type AppOption ¶
type AppOption func(*App)
func AppConfigPath ¶
func AppHomePath ¶
func AppTestTimeout ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env provides an isolated testing environment and what's needed to make it possible.
func (Env) Exec ¶
Exec executes a command step with options where msg describes the expectation from the test. unless calling with Must(), Exec() will not exit test runtime on failure.
func (Env) IsAppServed ¶
IsAppServed checks that app is served properly and servers are started to listening before ctx canceled.
func (Env) IsFaucetServed ¶
func (e Env) IsFaucetServed(ctx context.Context, faucetClient cosmosfaucet.HTTPClient) error
IsFaucetServed checks that faucet of the app is served properly.
func (Env) Must ¶
Must fails the immediately if not ok. t.Fail() needs to be called for the failing tests before running Must().
func (Env) RequireExpectations ¶
func (e Env) RequireExpectations()
func (Env) ScaffoldApp ¶ added in v29.1.0
ScaffoldApp scaffolds an app to a unique appPath and returns it.
func (Env) SetCleanup ¶
func (e Env) SetCleanup(f func())
SetCleanup registers a function to be called when the test (or subtest) and all its subtests complete.
type ExecOption ¶
type ExecOption func(*execOptions)
func ExecCtx ¶
func ExecCtx(ctx context.Context) ExecOption
ExecCtx sets cancelation context for the execution.
func ExecRetry ¶
func ExecRetry() ExecOption
ExecRetry retries command until it is successful before context is canceled.
func ExecShouldError ¶
func ExecShouldError() ExecOption
ExecShouldError sets the expectations of a command's execution to end with a failure.
func ExecStderr ¶
func ExecStderr(w io.Writer) ExecOption
ExecStderr captures stderr of an execution.
func ExecStdout ¶
func ExecStdout(w io.Writer) ExecOption
ExecStdout captures stdout of an execution.
type Hosts ¶
type Hosts struct { RPC string P2P string Prof string GRPC string GRPCWeb string API string Faucet string }
Hosts contains the "hostname:port" addresses for different service hosts.
type TxResponse ¶ added in v29.1.0
type TxResponse struct { Code int `json:"code"` Codespace string `json:"codespace"` RawLog string `json:"raw_log"` TxHash string `json:"txhash"` Height string `json:"height"` Data string `json:"data"` Info string `json:"info"` GasWanted string `json:"gas_wanted"` GasUsed string `json:"gas_used"` Timestamp string `json:"timestamp"` }