cosmos-sdk/x/bank/client/testutil/cli_helpers.go

58 lines
2.1 KiB
Go
Raw Normal View History

package testutil
2020-04-29 08:52:30 -07:00
import (
"fmt"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client"
2020-04-29 08:52:30 -07:00
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/tests"
Add CLI tests for simd, distribution (#6095) * Added cli integration base setup * Added cmd to simapp * Fixed ci-lint issues * Fixed ci-lint issues * Addressed changes in Makefile * Updated simd to latest * Removed testnet and replay commands * Modified tx command for simcli * Did code cleanup * Removed duplication in Makefile * Refactored cli_test * Added build-sim to Makefile * Added test-cli to circleci * Added tests for staking txns * Addressed format issues * refctored tests code * Added tests for send, staking * Removed test_hepers file * Moved test_cover to contrib * Added codec in fixtures * Migrated tests to respective modules * Exported helper methods * Moved helpers to bank * Added codec to fixtures * Migrated tests to modules * Removed auth helpers from staking * Did minor code cleanup * Added test-cli to Makefile * Updated github actions * Did code refactor * Fixed github actions for cli-test * Added tests for recover keys and fee deduction * Did minor code cleanup * Added build flag to cli_tests * Moved cli_test to tests * Modified path in Makefile * Updated codec std in fixtures * Added doc for cli tests * Remove ibc genesis validation * Fix issue number * Added missing imports * Add tests for distribution and simd * Modified naming for test functions * Added test for withdraw rewards * Modified test function names * Fixed import format * Migrated helpers to package cli * Fixed github test actions * Fixed test coverage in actions * Added build sim to actions * Apply Alessio patch for tests * Removed unused imports * Added init for go tests * try fix tests * goimports what wasn't goimports'd * try fix ci * add relevant tags to integration tests * run integration tests separately * use go build -o flag and let compiler gemerate the binary with the right extension for the HOST platform rename cli-test to test-integration * update ci * rename Co-authored-by: atheesh <atheesh1> Co-authored-by: kaustubhkapatral <54210167+kaustubhkapatral@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-05-01 13:16:17 -07:00
"github.com/cosmos/cosmos-sdk/tests/cli"
2020-04-29 08:52:30 -07:00
sdk "github.com/cosmos/cosmos-sdk/types"
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
2020-04-29 08:52:30 -07:00
)
func MsgSendExec(clientCtx client.Context, from, to, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{from.String(), to.String(), amount.String()}
args = append(args, extraArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewSendTxCmd(), args)
}
func QueryBalancesExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{address.String()}
args = append(args, extraArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.GetBalancesCmd(), args)
}
// ----------------------------------------------------------------------------
// TODO: REMOVE ALL FUNCTIONS BELOW.
//
// REF: https://github.com/cosmos/cosmos-sdk/issues/6571
// ----------------------------------------------------------------------------
2020-04-29 08:52:30 -07:00
// TxSend is simcli tx send
Add CLI tests for simd, distribution (#6095) * Added cli integration base setup * Added cmd to simapp * Fixed ci-lint issues * Fixed ci-lint issues * Addressed changes in Makefile * Updated simd to latest * Removed testnet and replay commands * Modified tx command for simcli * Did code cleanup * Removed duplication in Makefile * Refactored cli_test * Added build-sim to Makefile * Added test-cli to circleci * Added tests for staking txns * Addressed format issues * refctored tests code * Added tests for send, staking * Removed test_hepers file * Moved test_cover to contrib * Added codec in fixtures * Migrated tests to respective modules * Exported helper methods * Moved helpers to bank * Added codec to fixtures * Migrated tests to modules * Removed auth helpers from staking * Did minor code cleanup * Added test-cli to Makefile * Updated github actions * Did code refactor * Fixed github actions for cli-test * Added tests for recover keys and fee deduction * Did minor code cleanup * Added build flag to cli_tests * Moved cli_test to tests * Modified path in Makefile * Updated codec std in fixtures * Added doc for cli tests * Remove ibc genesis validation * Fix issue number * Added missing imports * Add tests for distribution and simd * Modified naming for test functions * Added test for withdraw rewards * Modified test function names * Fixed import format * Migrated helpers to package cli * Fixed github test actions * Fixed test coverage in actions * Added build sim to actions * Apply Alessio patch for tests * Removed unused imports * Added init for go tests * try fix tests * goimports what wasn't goimports'd * try fix ci * add relevant tags to integration tests * run integration tests separately * use go build -o flag and let compiler gemerate the binary with the right extension for the HOST platform rename cli-test to test-integration * update ci * rename Co-authored-by: atheesh <atheesh1> Co-authored-by: kaustubhkapatral <54210167+kaustubhkapatral@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-05-01 13:16:17 -07:00
func TxSend(f *cli.Fixtures, from string, to sdk.AccAddress, amount sdk.Coin, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx send --keyring-backend=test %s %s %s %v", f.SimdBinary, from, to, amount, f.Flags())
Add CLI tests for simd, distribution (#6095) * Added cli integration base setup * Added cmd to simapp * Fixed ci-lint issues * Fixed ci-lint issues * Addressed changes in Makefile * Updated simd to latest * Removed testnet and replay commands * Modified tx command for simcli * Did code cleanup * Removed duplication in Makefile * Refactored cli_test * Added build-sim to Makefile * Added test-cli to circleci * Added tests for staking txns * Addressed format issues * refctored tests code * Added tests for send, staking * Removed test_hepers file * Moved test_cover to contrib * Added codec in fixtures * Migrated tests to respective modules * Exported helper methods * Moved helpers to bank * Added codec to fixtures * Migrated tests to modules * Removed auth helpers from staking * Did minor code cleanup * Added test-cli to Makefile * Updated github actions * Did code refactor * Fixed github actions for cli-test * Added tests for recover keys and fee deduction * Did minor code cleanup * Added build flag to cli_tests * Moved cli_test to tests * Modified path in Makefile * Updated codec std in fixtures * Added doc for cli tests * Remove ibc genesis validation * Fix issue number * Added missing imports * Add tests for distribution and simd * Modified naming for test functions * Added test for withdraw rewards * Modified test function names * Fixed import format * Migrated helpers to package cli * Fixed github test actions * Fixed test coverage in actions * Added build sim to actions * Apply Alessio patch for tests * Removed unused imports * Added init for go tests * try fix tests * goimports what wasn't goimports'd * try fix ci * add relevant tags to integration tests * run integration tests separately * use go build -o flag and let compiler gemerate the binary with the right extension for the HOST platform rename cli-test to test-integration * update ci * rename Co-authored-by: atheesh <atheesh1> Co-authored-by: kaustubhkapatral <54210167+kaustubhkapatral@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-05-01 13:16:17 -07:00
return cli.ExecuteWriteRetStdStreams(f.T, cli.AddFlags(cmd, flags), clientkeys.DefaultKeyPass)
2020-04-29 08:52:30 -07:00
}
// QueryBalances executes the bank query balances command for a given address and
// flag set.
Add CLI tests for simd, distribution (#6095) * Added cli integration base setup * Added cmd to simapp * Fixed ci-lint issues * Fixed ci-lint issues * Addressed changes in Makefile * Updated simd to latest * Removed testnet and replay commands * Modified tx command for simcli * Did code cleanup * Removed duplication in Makefile * Refactored cli_test * Added build-sim to Makefile * Added test-cli to circleci * Added tests for staking txns * Addressed format issues * refctored tests code * Added tests for send, staking * Removed test_hepers file * Moved test_cover to contrib * Added codec in fixtures * Migrated tests to respective modules * Exported helper methods * Moved helpers to bank * Added codec to fixtures * Migrated tests to modules * Removed auth helpers from staking * Did minor code cleanup * Added test-cli to Makefile * Updated github actions * Did code refactor * Fixed github actions for cli-test * Added tests for recover keys and fee deduction * Did minor code cleanup * Added build flag to cli_tests * Moved cli_test to tests * Modified path in Makefile * Updated codec std in fixtures * Added doc for cli tests * Remove ibc genesis validation * Fix issue number * Added missing imports * Add tests for distribution and simd * Modified naming for test functions * Added test for withdraw rewards * Modified test function names * Fixed import format * Migrated helpers to package cli * Fixed github test actions * Fixed test coverage in actions * Added build sim to actions * Apply Alessio patch for tests * Removed unused imports * Added init for go tests * try fix tests * goimports what wasn't goimports'd * try fix ci * add relevant tags to integration tests * run integration tests separately * use go build -o flag and let compiler gemerate the binary with the right extension for the HOST platform rename cli-test to test-integration * update ci * rename Co-authored-by: atheesh <atheesh1> Co-authored-by: kaustubhkapatral <54210167+kaustubhkapatral@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-05-01 13:16:17 -07:00
func QueryBalances(f *cli.Fixtures, address sdk.AccAddress, flags ...string) sdk.Coins {
cmd := fmt.Sprintf("%s query bank balances %s %v", f.SimdBinary, address, f.Flags())
Add CLI tests for simd, distribution (#6095) * Added cli integration base setup * Added cmd to simapp * Fixed ci-lint issues * Fixed ci-lint issues * Addressed changes in Makefile * Updated simd to latest * Removed testnet and replay commands * Modified tx command for simcli * Did code cleanup * Removed duplication in Makefile * Refactored cli_test * Added build-sim to Makefile * Added test-cli to circleci * Added tests for staking txns * Addressed format issues * refctored tests code * Added tests for send, staking * Removed test_hepers file * Moved test_cover to contrib * Added codec in fixtures * Migrated tests to respective modules * Exported helper methods * Moved helpers to bank * Added codec to fixtures * Migrated tests to modules * Removed auth helpers from staking * Did minor code cleanup * Added test-cli to Makefile * Updated github actions * Did code refactor * Fixed github actions for cli-test * Added tests for recover keys and fee deduction * Did minor code cleanup * Added build flag to cli_tests * Moved cli_test to tests * Modified path in Makefile * Updated codec std in fixtures * Added doc for cli tests * Remove ibc genesis validation * Fix issue number * Added missing imports * Add tests for distribution and simd * Modified naming for test functions * Added test for withdraw rewards * Modified test function names * Fixed import format * Migrated helpers to package cli * Fixed github test actions * Fixed test coverage in actions * Added build sim to actions * Apply Alessio patch for tests * Removed unused imports * Added init for go tests * try fix tests * goimports what wasn't goimports'd * try fix ci * add relevant tags to integration tests * run integration tests separately * use go build -o flag and let compiler gemerate the binary with the right extension for the HOST platform rename cli-test to test-integration * update ci * rename Co-authored-by: atheesh <atheesh1> Co-authored-by: kaustubhkapatral <54210167+kaustubhkapatral@users.noreply.github.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2020-05-01 13:16:17 -07:00
out, _ := tests.ExecuteT(f.T, cli.AddFlags(cmd, flags), "")
2020-04-29 08:52:30 -07:00
var balances sdk.Coins
require.NoError(f.T, f.Cdc.UnmarshalJSON([]byte(out), &balances), "out %v\n", out)
return balances
}