* first commit * gaia cleanup * ... * staking multihooks * missing module function return args * bank module name constant * working, module interface for x/ * got this thing compiling * make test compiles and passes * remove expanded simulation invariants * genesis issue * continued * continued * register crisis routes thought mm * begin blocker to mm * end blocker to mm * empty routes not initialized * move gaia initChainer sanity check to baseapp * remove codecs from module manager * reorging genesis stuff * module manager passed by reference/bugfixes from working last commit int int * move invariant checks from gaia to crisis * typo * basic refactors cmd/gaia/init * working * MultiStakingHooks from types to x/staking/types int * default module manager order of operations from input modules * working * typo * add AppModuleBasic * moduleBasicManager / non-test code compiles * working attempting to get tests passing * make test passes * sim random genesis fix * export bug * ... * genutil module * genutil working * refactored - happy with non-testing code in cmd/ * ... * lint fixes * comment improvement * cli test fix * compile housing * working through compile errors * working gettin' compilin' * non-test code compiles * move testnet to its own module * reworking tests int * bez staging PR 1 comments * concise module function-of names * moved all tests from genesis_test.go to other genutil tests * genaccounts package, add genutil and genaccounts to app.go * docs for genutil genaccounts * genaccounts iterate fn * non-test code with genaccounts/ now compiles * working test compiling * debugging tests * resolved all make test compile errors * test debuggin * resolved all unit tests, introduced param module * cli-test compile fixes * staking initialization bug * code comment improvements, changelog entries * BasicGaiaApp -> ModuleBasics * highlevel explanation in types/module.go * @alexanderbez comment revisions * @fedekunze PR comments * @alexanderbez PR comments (x2) * @cwgoes comments (minor updates) * @fedekunze suggestions * panic on init with multiple validator updates from different modules * initchain panic makes validate genesis fail int * AppModuleGenesis seperation int * test * remove init panic logic in validate genesis replaced with TODO * set maxprocs to match system's GOMAXPROCS * Update circleci * Cap maxprocs in CI to 4 * @alexanderbez recent comments addressed * less blocks in twouble sims int * runsim error output flag * -e on import_export as well * error out int * Try to fix failures * runsim |
||
|---|---|---|
| .. | ||
| cli_test.go | ||
| doc.go | ||
| README.md | ||
| test_helpers.go | ||
Gaia CLI Integration tests
The gaia cli integration tests live in this folder. You can run the full suite by running:
$ go test -mod=readonly -p 4 `go list ./cmd/gaia/cli_test/...` -tags=cli_test
# OR!
$ make test_cli
NOTE: While the full suite runs in parallel, some of the tests can take up to a minute to complete
Test Structure
This integration suite uses a thin wrapper over the os/exec package. This allows the integration test to run against built binaries (both gaiad and gaiacli are used) while being written in golang. This allows tests to take advantage of the various golang code we have for operations like marshal/unmarshal, crypto, etc...
NOTE: The tests will use whatever
gaiadorgaiaclibinaries are available in your$PATH. You can check which binary will be run by the suite by runningwhich gaiadorwhich gaiacli. If you have your$GOPATHproperly setup they should be in$GOPATH/bin/gaia*. This will ensure that your test uses the latest binary you have built
Tests generally follow this structure:
func TestMyNewCommand(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
proc := f.GDStart()
defer proc.Stop(false)
// Your test code goes here...
f.Cleanup()
}
This boilerplate above:
- Ensures the tests run in parallel. Because the tests are calling out to
os/execfor many operations these tests can take a long time to run. - Creates
.gaiadand.gaiaclifolders in a new temp folder. - Uses
gaiaclito create 2 accounts for use in testing:fooandbar - Creates a genesis file with coins (
1000footoken,1000feetoken,150stake) controlled by thefookey - Generates an initial bonding transaction (
gentx) to make thefookey a validator at genesis - Starts
gaiadand stops it once the test exits - Cleans up test state on a successful run
Notes when adding/running tests
- Because the tests run against a built binary, you should make sure you build every time the code changes and you want to test again, otherwise you will be testing against an older version. If you are adding new tests this can easily lead to confusing test results.
- The
test_helpers.gofile is organized according to the format ofgaiacliandgaiadcommands. There are comments with section headers describing the different areas. Helper functions to call CLI functionality are generally named after the command (e.g.gaiacli query staking validatorwould beQueryStakingValidator). Try to keep functions grouped by their position in the command tree. - Test state that is needed by
txandquerycommands (home,chain_id, etc...) is stored on theFixturesobject. This makes constructing your new tests almost trivial. - Sometimes if you exit a test early there can be still running
gaiadandgaiacliprocesses that will interrupt subsequent runs. Still runninggaiacliprocesses will block access to the keybase while still runninggaiadprocesses will block ports and prevent new tests from spinning up. You can ensure new tests spin up clean by runningpkill -9 gaiad && pkill -9 gaiaclibefore each test run. - Most
queryandtxcommands take a variadicflagsargument. This pattern allows for the creation of a general function which is easily modified by adding flags. See theTxSendfunction and its use for a good example. Tx*functions follow a general pattern and return(success bool, stdout string, stderr string). This allows for easy testing of multiple different flag configurations. SeeTestGaiaCLICreateValidatororTestGaiaCLISubmitProposalfor a good example of the pattern.