Categorycosmossdk.io/systemtests
modulepackage
1.1.0
Repository: https://github.com/cosmos/cosmos-sdk.git
Documentation: pkg.go.dev

# README

System Tests

This package contains the testing framework for black-box system tests. It includes a test runner that sets up a multi-node blockchain locally for use in tests. The framework provides utilities and helpers for easy access and setup in tests.

Components

  • CLI: Command-line interface wrapper for interacting with the chain or keyring
  • Servers: Server instances to run the blockchain environment.
  • Events: Event listeners
  • RPC: Remote Procedure Call setup for communication.

Dependencies

  • testify: Testing toolkit.
  • gjson: JSON parser.
  • sjson: JSON modifier.

Server and client-side operations are executed on the host machine.

Developer

Test strategy

System tests cover the full stack via cli and a running (multi node) network. They are more expensive (in terms of time/ cpu) to run compared to unit or integration tests. Therefore, we focus on the critical path and do not cover every condition.

How to use

Read the getting_started.md guide to get started.

Execute a single test

go test -tags system_test -count=1 -v . --run TestStakeUnstake  -verbose

Test cli parameters

  • -verbose verbose output
  • -wait-time duration - time to wait for chain events (default 30s)
  • -nodes-count int - number of nodes in the cluster (default 4)

Port ranges

With n nodes:

  • 26657 - 26657+n - RPC
  • 1317 - 1317+n - API
  • 9090 - 9090+n - GRPC
  • 16656 - 16656+n - P2P

For example Node 3 listens on 26660 for RPC calls

Resources

Disclaimer

This is based on the system test framework in wasmd built by Confio.

# Functions

No description provided by the author
CaptureAllEventsConsumer is an `EventConsumer` that captures all events until `done()` is called to stop or timeout happens.
CaptureSingleEventConsumer consumes one event.
No description provided by the author
No description provided by the author
GetGenesisBalance return the balance amount for an address from the given genesis json.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
InitializerWithBinary creates new SingleHostTestnetCmdInitializer from sut with given binary.
IsV2 checks if the tests run with simapp v2.
No description provided by the author
LoadValidatorPubKey load validator nodes consensus pub key from disk.
LoadValidatorPubKeyForNode load validator nodes consensus pub key for given node number.
MustCopyFile copies the file from the source path `src` to the destination path `dest` and returns an open file handle to `dest`.
MustCopyFilesInDir copies all files (excluding directories) from the source directory `src` to the destination directory `dest`.
No description provided by the author
NewCLIWrapper constructor.
NewCLIWrapperX extended constructor.
NewEventListener event listener.
No description provided by the author
NewRPCClient constructor.
NewSingleHostTestnetCmdInitializer constructor.
No description provided by the author
No description provided by the author
No description provided by the author
QueryCometValidatorPowerForNode returns the validator's power from tendermint RPC endpoint.
RequireTxFailure require the received response to contain any failure code and the passed msgs From CometBFT v1, an RPC error won't return ABCI response, and error must be parsed.
RequireTxSuccess require the received response to contain the success code.
RunRestQueries runs given Rest testcases by making requests and checking response with expected output.
RunRestQueriesIgnoreNumbers runs given rest testcases by making requests and checking response with expected output ignoring number values This method is used when number values in response are non-deterministic.
No description provided by the author
No description provided by the author
No description provided by the author
SetConsensusMaxGas max gas that can be consumed in a block.
No description provided by the author
No description provided by the author
No description provided by the author
StoreTempFile creates a temporary file in the test's temporary directory with the provided content.
TimeoutConsumer is an event consumer decorator with a max wait time.
No description provided by the author

# Variables

DefaultApiPort is the port for the node to interact with.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrOutOfGasMatcher requires error with "out of gas" message.
ErrPostFailedMatcher requires post failed.
ErrTimeoutMatcher requires time out message.
ExecBinaryUnversionedRegExp regular expression to extract the unversioned binary name.
No description provided by the author
No description provided by the author
No description provided by the author
WorkDir is the directory where tests are executed.

# Structs

CLIWrapper provides a more convenient way to interact with the CLI binary from the Go tests.
EventListener watches for events on the chain.
ModifyConfigYamlInitializer testnet cmd prior to --single-host param.
No description provided by the author
No description provided by the author
RPCClient is a test helper to interact with a node via the RPC endpoint.
SingleHostTestnetCmdInitializer default testnet cmd that supports the --single-host param.
SystemUnderTest blockchain provisioning.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author