Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setup for cli_test #6033

Merged
merged 61 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
014caf8
Added cli integration base setup
sahith-narahari Apr 14, 2020
a42c097
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 14, 2020
df53367
Added cmd to simapp
sahith-narahari Apr 15, 2020
c2e22b9
Fixed ci-lint issues
sahith-narahari Apr 15, 2020
13b5531
Fixed ci-lint issues
sahith-narahari Apr 15, 2020
858e744
Addressed changes in Makefile
sahith-narahari Apr 16, 2020
0755f09
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 16, 2020
0ae1966
Updated simd to latest
sahith-narahari Apr 16, 2020
6f362fd
Removed testnet and replay commands
sahith-narahari Apr 17, 2020
5136a91
Modified tx command for simcli
sahith-narahari Apr 17, 2020
295b023
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 17, 2020
df2424a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 17, 2020
da5b8e3
Did code cleanup
sahith-narahari Apr 17, 2020
6e82b44
Merge branch 'sahith/add-cli-tests' of github.com:regen-network/cosmo…
sahith-narahari Apr 18, 2020
0ef94f2
Removed duplication in Makefile
sahith-narahari Apr 18, 2020
6670f90
Refactored cli_test
sahith-narahari Apr 20, 2020
e130c40
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 20, 2020
bc88c76
Added build-sim to Makefile
sahith-narahari Apr 20, 2020
baa4b60
Added test-cli to circleci
sahith-narahari Apr 20, 2020
828092c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 20, 2020
85fae47
Added tests for staking txns
Apr 21, 2020
5d33cbd
Addressed format issues
sahith-narahari Apr 21, 2020
349e09d
Merge branch 'sahith/add-staking-tests' of github.com:regen-network/c…
sahith-narahari Apr 21, 2020
61b6692
refctored tests code
Apr 21, 2020
0258675
Added tests for send, staking
sahith-narahari Apr 21, 2020
8815250
Merge remote-tracking branch 'origin/atheesh/cli-test-send' into athe…
sahith-narahari Apr 21, 2020
1b9c2ec
Removed test_hepers file
sahith-narahari Apr 21, 2020
3101ed3
Moved test_cover to contrib
sahith-narahari Apr 21, 2020
09efc33
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 21, 2020
93f1b09
Added codec in fixtures
Apr 22, 2020
cf27dff
Merge pull request #32 from vitwit/atheesh/cli-test-send
kaustubhkapatral Apr 22, 2020
d31c20d
Migrated tests to respective modules
sahith-narahari Apr 22, 2020
c083a83
Exported helper methods
sahith-narahari Apr 23, 2020
4f03138
Merge branch 'sahith/add-base-setup' of github.com:regen-network/cosm…
sahith-narahari Apr 23, 2020
82c0abc
Moved helpers to bank
sahith-narahari Apr 23, 2020
e67c965
Added codec to fixtures
sahith-narahari Apr 23, 2020
71365b7
Migrated tests to modules
sahith-narahari Apr 23, 2020
878bf70
Removed auth helpers from staking
sahith-narahari Apr 23, 2020
b272b89
Did minor code cleanup
sahith-narahari Apr 23, 2020
c94c654
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 23, 2020
b3335b4
Added test-cli to Makefile
sahith-narahari Apr 23, 2020
6f79058
Merge pull request #33 from regen-network/sahith/add-staking-tests
sahith-narahari Apr 24, 2020
2fb801c
Updated github actions
sahith-narahari Apr 24, 2020
b867814
Merge branch 'sahith/add-base-setup' of github.com:regen-network/cosm…
sahith-narahari Apr 24, 2020
f41876b
Did code refactor
sahith-narahari Apr 24, 2020
8237441
Fixed github actions for cli-test
sahith-narahari Apr 24, 2020
7197e7d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 24, 2020
2600b5d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/add…
sahith-narahari Apr 27, 2020
044d318
Did minor code cleanup
sahith-narahari Apr 27, 2020
6e90919
Added build flag to cli_tests
sahith-narahari Apr 27, 2020
5fc398c
Moved cli_test to tests
sahith-narahari Apr 27, 2020
f351b47
Merge branch 'master' into sahith/add-base-setup
aaronc Apr 28, 2020
e400f11
Modified path in Makefile
sahith-narahari Apr 28, 2020
53e8e9c
Merge branch 'sahith/add-base-setup' of github.com:regen-network/cosm…
sahith-narahari Apr 28, 2020
e3913ae
Updated codec std in fixtures
sahith-narahari Apr 28, 2020
8454ecc
Added doc for cli tests
sahith-narahari Apr 28, 2020
0b167c6
Remove ibc genesis validation
anilcse Apr 28, 2020
55b8d0d
Fix issue number
anilcse Apr 28, 2020
5e2446b
Merge branch 'master' into sahith/add-base-setup
aaronc Apr 29, 2020
56fcb11
Merge branch 'master' into sahith/add-base-setup
aaronc Apr 29, 2020
22d58ee
Merge branch 'master' into sahith/add-base-setup
aaronc Apr 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ jobs:
file: ./coverage.txt # optional
fail_ci_if_error: true
if: "env.GIT_DIFF != ''"
cli-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: cli-test
run: |
make cli-test
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
SIMAPP = ./simapp
MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf

export GO111MODULE = on
export BUILDDIR

# The below include contains the tools and runsim targets.
include contrib/devtools/Makefile
Expand Down Expand Up @@ -166,6 +168,10 @@ test-sim-benchmark-invariants:
-Enabled=true -NumBlocks=1000 -BlockSize=200 \
-Period=1 -Commit=true -Seed=57 -v -timeout 24h

cli-test: build-sim
@go test -mod=readonly -p 4 `go list ./tests/cli/tests/...` -tags=cli_test -v
@go test -mod=readonly -p 4 `go list ./x/.../client/cli_test/...` -tags=cli_test -v

.PHONY: \
test-sim-nondeterminism \
test-sim-custom-genesis-fast \
Expand All @@ -174,7 +180,8 @@ test-sim-after-import \
test-sim-custom-genesis-multi-seed \
test-sim-multi-seed-short \
test-sim-multi-seed-long \
test-sim-benchmark-invariants
test-sim-benchmark-invariants \
cli-test

SIM_NUM_BLOCKS ?= 500
SIM_BLOCK_SIZE ?= 200
Expand All @@ -193,7 +200,7 @@ test-sim-profile:
.PHONY: test-sim-profile test-sim-benchmark

test-cover:
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
@export VERSION=$(VERSION); bash -x contrib/test_cover.sh
.PHONY: test-cover

benchmark:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cover.sh → contrib/test_cover.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

PKGS=$(go list ./... | grep -v '/simapp')
PKGS=$(go list ./... | grep -v '/simapp' | grep -v '/cli_test')

set -e
echo "mode: atomic" > coverage.txt
Expand Down
13 changes: 13 additions & 0 deletions tests/cli/helpers/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package helpers

const (
Denom = "stake"
KeyFoo = "foo"
KeyBar = "bar"
FooDenom = "footoken"
FeeDenom = "feetoken"
Fee2Denom = "fee2token"
KeyBaz = "baz"
KeyVesting = "vesting"
KeyFooBarBaz = "foobarbaz"
)
49 changes: 49 additions & 0 deletions tests/cli/helpers/executors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package helpers

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/tests"
)

func ExecuteWriteCheckErr(t *testing.T, cmdStr string, writes ...string) {
require.True(t, ExecuteWrite(t, cmdStr, writes...))
}

func ExecuteWrite(t *testing.T, cmdStr string, writes ...string) (exitSuccess bool) {
exitSuccess, _, _ = ExecuteWriteRetStdStreams(t, cmdStr, writes...)
return
}

func ExecuteWriteRetStdStreams(t *testing.T, cmdStr string, writes ...string) (bool, string, string) {
proc := tests.GoExecuteT(t, cmdStr)

// Enables use of interactive commands
for _, write := range writes {
_, err := proc.StdinPipe.Write([]byte(write + "\n"))
require.NoError(t, err)
}

// Read both stdout and stderr from the process
stdout, stderr, err := proc.ReadAll()
if err != nil {
fmt.Println("Err on proc.ReadAll()", err, cmdStr)
}

// Log output.
if len(stdout) > 0 {
t.Log("Stdout:", string(stdout))
}
if len(stderr) > 0 {
t.Log("Stderr:", string(stderr))
}

// Wait for process to exit
proc.Wait()

// Return succes, stdout, stderr
return proc.ExitState.Success(), string(stdout), string(stderr)
}
78 changes: 78 additions & 0 deletions tests/cli/helpers/fixtures.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package helpers

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/cosmos/cosmos-sdk/std"
"github.com/stretchr/testify/require"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/simapp"
)

var cdc = std.MakeCodec(simapp.ModuleBasics)

// Fixtures is used to setup the testing environment
type Fixtures struct {
BuildDir string
RootDir string
SimdBinary string
SimcliBinary string
ChainID string
RPCAddr string
Port string
SimdHome string
SimcliHome string
P2PAddr string
Cdc *codec.Codec
T *testing.T
}

// NewFixtures creates a new instance of Fixtures with many vars set
func NewFixtures(t *testing.T) *Fixtures {
tmpDir, err := ioutil.TempDir("", "sdk_integration_"+t.Name()+"_")
require.NoError(t, err)

servAddr, port, err := server.FreeTCPAddr()
require.NoError(t, err)

p2pAddr, _, err := server.FreeTCPAddr()
require.NoError(t, err)

buildDir := os.Getenv("BUILDDIR")
require.NotNil(t, buildDir)

return &Fixtures{
T: t,
BuildDir: buildDir,
RootDir: tmpDir,
SimdBinary: filepath.Join(buildDir, "simd"),
SimcliBinary: filepath.Join(buildDir, "simcli"),
SimdHome: filepath.Join(tmpDir, ".simd"),
SimcliHome: filepath.Join(tmpDir, ".simcli"),
RPCAddr: servAddr,
P2PAddr: p2pAddr,
Cdc: cdc,
Port: port,
}
}

// GenesisFile returns the path of the genesis file
func (f Fixtures) GenesisFile() string {
return filepath.Join(f.SimdHome, "config", "genesis.json")
}

// GenesisFile returns the application's genesis state
func (f Fixtures) GenesisState() simapp.GenesisState {
genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile())
require.NoError(f.T, err)

var appState simapp.GenesisState
require.NoError(f.T, f.Cdc.UnmarshalJSON(genDoc.AppState, &appState))
return appState
}
Loading