From 5473e9d8f4b08a1b1fc1f61d08ad5b02f90b4b8f Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 27 Apr 2020 13:16:18 -0400 Subject: [PATCH 1/7] fix CLI tests --- cli_test/cli_test.go | 127 +++++++------- cli_test/test_helpers.go | 363 +++++++++++++++++++++------------------ 2 files changed, 256 insertions(+), 234 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 3c5995b9..9a5a742a 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -12,14 +12,13 @@ import ( "path/filepath" "strings" "testing" - "time" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/tests" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" @@ -29,7 +28,7 @@ import ( "github.com/kava-labs/kava/app" ) -func TestGaiaCLIKeysAddMultisig(t *testing.T) { +func TestKavaCLIKeysAddMultisig(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -52,7 +51,7 @@ func TestGaiaCLIKeysAddMultisig(t *testing.T) { f.Cleanup() } -func TestGaiaCLIKeysAddRecover(t *testing.T) { +func TestKavaCLIKeysAddRecover(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -72,7 +71,7 @@ func TestGaiaCLIKeysAddRecover(t *testing.T) { f.Cleanup() } -func TestGaiaCLIKeysAddRecoverHDPath(t *testing.T) { +func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -96,11 +95,11 @@ func TestGaiaCLIKeysAddRecoverHDPath(t *testing.T) { f.Cleanup() } -func TestGaiaCLIMinimumFees(t *testing.T) { +func TestKavaCLIMinimumFees(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") fees := fmt.Sprintf( "--minimum-gas-prices=%s,%s", @@ -134,11 +133,11 @@ func TestGaiaCLIMinimumFees(t *testing.T) { f.Cleanup() } -func TestGaiaCLIGasPrices(t *testing.T) { +func TestKavaCLIGasPrices(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice))) defer proc.Stop(false) @@ -168,11 +167,11 @@ func TestGaiaCLIGasPrices(t *testing.T) { f.Cleanup() } -func TestGaiaCLIFeesDeduction(t *testing.T) { +func TestKavaCLIFeesDeduction(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice))) defer proc.Stop(false) @@ -221,11 +220,11 @@ func TestGaiaCLIFeesDeduction(t *testing.T) { f.Cleanup() } -func TestGaiaCLISend(t *testing.T) { +func TestKavaCLISend(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -258,7 +257,7 @@ func TestGaiaCLISend(t *testing.T) { ) require.Empty(t, stderr) require.True(t, success) - msg := unmarshalStdTx(f.T, stdout) + msg := f.unmarshalStdTx(f.T, stdout) require.NotZero(t, msg.Fee.Gas) require.Len(t, msg.Msgs, 1) require.Len(t, msg.GetSignatures(), 0) @@ -290,12 +289,12 @@ func TestGaiaCLISend(t *testing.T) { f.Cleanup() } -// Note: this was removed from gaia due to update in sdk PR#4062 but is now working -func TestGaiaCLIConfirmTx(t *testing.T) { +// Note: this was removed from kava due to update in sdk PR#4062 but is now working +func TestKavaCLIConfirmTx(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -325,13 +324,13 @@ func TestGaiaCLIConfirmTx(t *testing.T) { require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom)) } -func TestGaiaCLIGasAuto(t *testing.T) { +func TestKavaCLIGasAuto(t *testing.T) { // https://github.com/cosmos/cosmos-sdk/pull/5179 t.Skip() t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -387,18 +386,19 @@ func TestGaiaCLIGasAuto(t *testing.T) { f.Cleanup() } -func TestGaiaCLICreateValidator(t *testing.T) { +func TestKavaCLICreateValidator(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) barAddr := f.KeyAddress(keyBar) barVal := sdk.ValAddress(barAddr) - consPubKey := sdk.MustBech32ifyConsPub(ed25519.GenPrivKey().PubKey()) + consPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, ed25519.GenPrivKey().PubKey()) + require.NoError(t, err) sendTokens := sdk.TokensFromConsensusPower(10) f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") @@ -412,7 +412,7 @@ func TestGaiaCLICreateValidator(t *testing.T) { require.True(f.T, success) require.Empty(f.T, stderr) - msg := unmarshalStdTx(f.T, stdout) + msg := f.unmarshalStdTx(f.T, stdout) require.NotZero(t, msg.Fee.Gas) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -460,7 +460,7 @@ func TestGaiaCLICreateValidator(t *testing.T) { f.Cleanup() } -func TestGaiaCLIQueryRewards(t *testing.T) { +func TestKavaCLIQueryRewards(t *testing.T) { t.Parallel() f := InitFixtures(t) cdc := app.MakeCodec() @@ -476,13 +476,13 @@ func TestGaiaCLIQueryRewards(t *testing.T) { require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz - genFile := filepath.Join(f.GaiadHome, "config", "genesis.json") + genFile := filepath.Join(f.KavadHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) require.NoError(t, genDoc.SaveAs(genFile)) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -493,11 +493,11 @@ func TestGaiaCLIQueryRewards(t *testing.T) { f.Cleanup() } -func TestGaiaCLIQuerySupply(t *testing.T) { +func TestKavaCLIQuerySupply(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -510,11 +510,11 @@ func TestGaiaCLIQuerySupply(t *testing.T) { f.Cleanup() } -func TestGaiaCLISubmitProposal(t *testing.T) { +func TestKavaCLISubmitProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -537,7 +537,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) { fooAddr.String(), "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--generate-only", "-y") require.True(t, success) require.Empty(t, stderr) - msg := unmarshalStdTx(t, stdout) + msg := f.unmarshalStdTx(t, stdout) require.NotZero(t, msg.Fee.Gas) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -576,7 +576,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) { success, stdout, stderr = f.TxGovDeposit(1, fooAddr.String(), sdk.NewCoin(denom, depositTokens), "--generate-only") require.True(t, success) require.Empty(t, stderr) - msg = unmarshalStdTx(t, stdout) + msg = f.unmarshalStdTx(t, stdout) require.NotZero(t, msg.Fee.Gas) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -611,7 +611,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) { success, stdout, stderr = f.TxGovVote(1, gov.OptionYes, fooAddr.String(), "--generate-only") require.True(t, success) require.Empty(t, stderr) - msg = unmarshalStdTx(t, stdout) + msg = f.unmarshalStdTx(t, stdout) require.NotZero(t, msg.Fee.Gas) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -654,7 +654,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) { f.Cleanup() } -func TestGaiaCLISubmitParamChangeProposal(t *testing.T) { +func TestKavaCLISubmitParamChangeProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -718,7 +718,7 @@ func TestGaiaCLISubmitParamChangeProposal(t *testing.T) { f.Cleanup() } -func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) { +func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -735,7 +735,7 @@ func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) { require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz - genFile := filepath.Join(f.GaiadHome, "config", "genesis.json") + genFile := filepath.Join(f.KavadHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) @@ -802,11 +802,11 @@ func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) { f.Cleanup() } -func TestGaiaCLIQueryTxPagination(t *testing.T) { +func TestKavaCLIQueryTxPagination(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -852,11 +852,11 @@ func TestGaiaCLIQueryTxPagination(t *testing.T) { f.Cleanup() } -func TestGaiaCLIValidateSignatures(t *testing.T) { +func TestKavaCLIValidateSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -876,7 +876,7 @@ func TestGaiaCLIValidateSignatures(t *testing.T) { success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name()) require.True(t, success) require.Empty(t, stderr) - stdTx := unmarshalStdTx(t, stdout) + stdTx := f.unmarshalStdTx(t, stdout) require.Equal(t, len(stdTx.Msgs), 1) require.Equal(t, 1, len(stdTx.GetSignatures())) require.Equal(t, fooAddr.String(), stdTx.GetSigners()[0].String()) @@ -891,7 +891,7 @@ func TestGaiaCLIValidateSignatures(t *testing.T) { // modify the transaction stdTx.Memo = "MODIFIED-ORIGINAL-TX-BAD" - bz := marshalStdTx(t, stdTx) + bz := f.marshalStdTx(t, stdTx) modSignedTxFile := WriteToNewTempFile(t, string(bz)) defer os.Remove(modSignedTxFile.Name()) @@ -902,11 +902,11 @@ func TestGaiaCLIValidateSignatures(t *testing.T) { f.Cleanup() } -func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { +func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -918,8 +918,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { success, stdout, stderr := f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only") require.True(t, success) require.Empty(t, stderr) - msg := unmarshalStdTx(t, stdout) - require.Equal(t, msg.Fee.Gas, uint64(client.DefaultGasLimit)) + msg := f.unmarshalStdTx(t, stdout) + require.Equal(t, msg.Fee.Gas, uint64(flags.DefaultGasLimit)) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -927,7 +927,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { success, stdout, stderr = f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--gas=100", "--generate-only") require.True(t, success) require.Empty(t, stderr) - msg = unmarshalStdTx(t, stdout) + msg = f.unmarshalStdTx(t, stdout) require.Equal(t, msg.Fee.Gas, uint64(100)) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 0, len(msg.GetSignatures())) @@ -936,7 +936,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { success, stdout, stderr = f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only") require.True(t, success) require.Empty(t, stderr) - msg = unmarshalStdTx(t, stdout) + msg = f.unmarshalStdTx(t, stdout) require.True(t, msg.Fee.Gas > 0) require.Equal(t, len(msg.Msgs), 1) @@ -952,7 +952,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { // Test sign success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name()) require.True(t, success) - msg = unmarshalStdTx(t, stdout) + msg = f.unmarshalStdTx(t, stdout) require.Equal(t, len(msg.Msgs), 1) require.Equal(t, 1, len(msg.GetSignatures())) require.Equal(t, fooAddr.String(), msg.GetSigners()[0].String()) @@ -986,11 +986,11 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) { f.Cleanup() } -func TestGaiaCLIMultisignInsufficientCosigners(t *testing.T) { +func TestKavaCLIMultisignInsufficientCosigners(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1039,11 +1039,11 @@ func TestGaiaCLIMultisignInsufficientCosigners(t *testing.T) { f.Cleanup() } -func TestGaiaCLIEncode(t *testing.T) { +func TestKavaCLIEncode(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) @@ -1077,11 +1077,11 @@ func TestGaiaCLIEncode(t *testing.T) { require.Equal(t, "deadbeef", decodedTx.Memo) } -func TestGaiaCLIMultisignSortSignatures(t *testing.T) { +func TestKavaCLIMultisignSortSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1142,11 +1142,11 @@ func TestGaiaCLIMultisignSortSignatures(t *testing.T) { f.Cleanup() } -func TestGaiaCLIMultisign(t *testing.T) { +func TestKavaCLIMultisign(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server with minimum fees + // start kavad server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1208,7 +1208,7 @@ func TestGaiaCLIMultisign(t *testing.T) { f.Cleanup() } -func TestGaiaCLIConfig(t *testing.T) { +func TestKavaCLIConfig(t *testing.T) { t.Parallel() f := InitFixtures(t) node := fmt.Sprintf("%s:%s", f.RPCAddr, f.Port) @@ -1222,7 +1222,7 @@ func TestGaiaCLIConfig(t *testing.T) { f.CLIConfig("trace", "false") f.CLIConfig("indent", "true") - config, err := ioutil.ReadFile(path.Join(f.GaiacliHome, "config", "config.toml")) + config, err := ioutil.ReadFile(path.Join(f.KavacliHome, "config", "config.toml")) require.NoError(t, err) expectedConfig := fmt.Sprintf(`broadcast-mode = "block" chain-id = "%s" @@ -1237,7 +1237,7 @@ trust-node = true f.Cleanup() } -func TestGaiadCollectGentxs(t *testing.T) { +func TestKavadCollectGentxs(t *testing.T) { t.Parallel() var customMaxBytes, customMaxGas int64 = 99999999, 1234567 f := NewFixtures(t) @@ -1285,7 +1285,7 @@ func TestGaiadCollectGentxs(t *testing.T) { f.Cleanup(gentxDir) } -func TestGaiadAddGenesisAccount(t *testing.T) { +func TestKavadAddGenesisAccount(t *testing.T) { t.Parallel() f := NewFixtures(t) @@ -1334,12 +1334,11 @@ func TestSlashingGetParams(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) params := f.QuerySlashingParams() - require.Equal(t, time.Duration(120000000000), params.MaxEvidenceAge) require.Equal(t, int64(100), params.SignedBlocksWindow) require.Equal(t, sdk.NewDecWithPrec(5, 1), params.MinSignedPerWindow) @@ -1355,7 +1354,7 @@ func TestValidateGenesis(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start gaiad server + // start kavad server proc := f.GDStart() defer proc.Stop(false) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 1d82792f..1470a81c 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -76,15 +76,17 @@ func init() { type Fixtures struct { BuildDir string RootDir string - GaiadBinary string - GaiacliBinary string + KavadBinary string + KavacliBinary string ChainID string RPCAddr string Port string - GaiadHome string - GaiacliHome string + KavadHome string + KavacliHome string P2PAddr string T *testing.T + + cdc *codec.Codec } // NewFixtures creates a new instance of Fixtures with many vars set @@ -104,26 +106,29 @@ func NewFixtures(t *testing.T) *Fixtures { require.NoError(t, err) } + cdc := app.MakeCodec() + return &Fixtures{ T: t, BuildDir: buildDir, RootDir: tmpDir, - GaiadBinary: filepath.Join(buildDir, "kvd"), - GaiacliBinary: filepath.Join(buildDir, "kvcli"), - GaiadHome: filepath.Join(tmpDir, ".kvd"), - GaiacliHome: filepath.Join(tmpDir, ".kvcli"), + KavadBinary: filepath.Join(buildDir, "kvd"), + KavacliBinary: filepath.Join(buildDir, "kvcli"), + KavadHome: filepath.Join(tmpDir, ".kvd"), + KavacliHome: filepath.Join(tmpDir, ".kvcli"), RPCAddr: servAddr, P2PAddr: p2pAddr, Port: port, + cdc: cdc, } } // GenesisFile returns the path of the genesis file func (f Fixtures) GenesisFile() string { - return filepath.Join(f.GaiadHome, "config", "genesis.json") + return filepath.Join(f.KavadHome, "config", "genesis.json") } -// GenesisFile returns the application's genesis state +// GenesisState returns the application's genesis state func (f Fixtures) GenesisState() simapp.GenesisState { cdc := codec.New() genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile()) @@ -189,24 +194,24 @@ func (f *Fixtures) Cleanup(dirs ...string) { // Flags returns the flags necessary for making most CLI calls func (f *Fixtures) Flags() string { - return fmt.Sprintf("--home=%s --node=%s", f.GaiacliHome, f.RPCAddr) + return fmt.Sprintf("--home=%s --node=%s", f.KavacliHome, f.RPCAddr) } //___________________________________________________________________________________ -// gaiad +// kavad -// UnsafeResetAll is gaiad unsafe-reset-all +// UnsafeResetAll is kavad unsafe-reset-all func (f *Fixtures) UnsafeResetAll(flags ...string) { - cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.GaiadBinary, f.GaiadHome) + cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.KavadBinary, f.KavadHome) executeWrite(f.T, addFlags(cmd, flags)) - err := os.RemoveAll(filepath.Join(f.GaiadHome, "config", "gentx")) + err := os.RemoveAll(filepath.Join(f.KavadHome, "config", "gentx")) require.NoError(f.T, err) } -// GDInit is gaiad init +// GDInit is kavad init // NOTE: GDInit sets the ChainID for the Fixtures instance func (f *Fixtures) GDInit(moniker string, flags ...string) { - cmd := fmt.Sprintf("%s init -o --home=%s %s", f.GaiadBinary, f.GaiadHome, moniker) + cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KavadBinary, f.KavadHome, moniker) _, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) var chainID string @@ -221,78 +226,83 @@ func (f *Fixtures) GDInit(moniker string, flags ...string) { f.ChainID = chainID } -// AddGenesisAccount is gaiad add-genesis-account +// AddGenesisAccount is kavad add-genesis-account func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, flags ...string) { - cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s", f.GaiadBinary, address, coins, f.GaiadHome) + cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s --keyring-backend=test", f.KavadBinary, address, coins, f.KavadHome) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } -// GenTx is gaiad gentx +// GenTx is kavad gentx func (f *Fixtures) GenTx(name string, flags ...string) { - cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s", f.GaiadBinary, name, f.GaiadHome, f.GaiacliHome) - executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) + cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.KavadBinary, name, f.KavadHome, f.KavacliHome) + executeWriteCheckErr(f.T, addFlags(cmd, flags)) } -// CollectGenTxs is gaiad collect-gentxs +// CollectGenTxs is kavad collect-gentxs func (f *Fixtures) CollectGenTxs(flags ...string) { - cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.GaiadBinary, f.GaiadHome) - executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) + cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.KavadBinary, f.KavadHome) + executeWriteCheckErr(f.T, addFlags(cmd, flags)) } -// GDStart runs gaiad start with the appropriate flags and returns a process +// GDStart runs kavad start with the appropriate flags and returns a process func (f *Fixtures) GDStart(flags ...string) *tests.Process { - cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.GaiadBinary, f.GaiadHome, f.RPCAddr, f.P2PAddr) + cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.KavadBinary, f.KavadHome, f.RPCAddr, f.P2PAddr) proc := tests.GoExecuteTWithStdout(f.T, addFlags(cmd, flags)) tests.WaitForTMStart(f.Port) tests.WaitForNextNBlocksTM(1, f.Port) return proc } -// GDTendermint returns the results of gaiad tendermint [query] +// GDTendermint returns the results of kavad tendermint [query] func (f *Fixtures) GDTendermint(query string) string { - cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.GaiadBinary, query, f.GaiadHome) + cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.KavadBinary, query, f.KavadHome) success, stdout, stderr := executeWriteRetStdStreams(f.T, cmd) require.Empty(f.T, stderr) require.True(f.T, success) return strings.TrimSpace(stdout) } -// ValidateGenesis runs gaiad validate-genesis +// ValidateGenesis runs kavad validate-genesis func (f *Fixtures) ValidateGenesis() { - cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.GaiadBinary, f.GaiadHome) + cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.KavadBinary, f.KavadHome) executeWriteCheckErr(f.T, cmd) } //___________________________________________________________________________________ -// gaiacli keys +// kavacli keys -// KeysDelete is gaiacli keys delete +// KeysDelete is kavacli keys delete func (f *Fixtures) KeysDelete(name string, flags ...string) { - cmd := fmt.Sprintf("%s keys delete --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name) + cmd := fmt.Sprintf("%s keys delete --keyring-backend=test --home=%s %s", f.KavacliBinary, + f.KavacliHome, name) executeWrite(f.T, addFlags(cmd, append(append(flags, "-y"), "-f"))) } -// KeysAdd is gaiacli keys add +// KeysAdd is kavacli keys add func (f *Fixtures) KeysAdd(name string, flags ...string) { - cmd := fmt.Sprintf("%s keys add --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name) - executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) + cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s %s", f.KavacliBinary, + f.KavacliHome, name) + executeWriteCheckErr(f.T, addFlags(cmd, flags)) } -// KeysAddRecover prepares gaiacli keys add --recover +// KeysAddRecover prepares kavacli keys add --recover func (f *Fixtures) KeysAddRecover(name, mnemonic string, flags ...string) (exitSuccess bool, stdout, stderr string) { - cmd := fmt.Sprintf("%s keys add --home=%s --recover %s", f.GaiacliBinary, f.GaiacliHome, name) - return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass, mnemonic) + cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s", + f.KavacliBinary, f.KavacliHome, name) + return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), mnemonic) } -// KeysAddRecoverHDPath prepares gaiacli keys add --recover --account --index +// KeysAddRecoverHDPath prepares kavacli keys add --recover --account --index func (f *Fixtures) KeysAddRecoverHDPath(name, mnemonic string, account uint32, index uint32, flags ...string) { - cmd := fmt.Sprintf("%s keys add --home=%s --recover %s --account %d --index %d", f.GaiacliBinary, f.GaiacliHome, name, account, index) - executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass, mnemonic) + cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s --account %d"+ + " --index %d", f.KavacliBinary, f.KavacliHome, name, account, index) + executeWriteCheckErr(f.T, addFlags(cmd, flags), mnemonic) } -// KeysShow is gaiacli keys show +// KeysShow is kavacli keys show func (f *Fixtures) KeysShow(name string, flags ...string) keys.KeyOutput { - cmd := fmt.Sprintf("%s keys show --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name) + cmd := fmt.Sprintf("%s keys show --keyring-backend=test --home=%s %s", f.KavacliBinary, + f.KavacliHome, name) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var ko keys.KeyOutput err := clientkeys.UnmarshalJSON([]byte(out), &ko) @@ -309,88 +319,101 @@ func (f *Fixtures) KeyAddress(name string) sdk.AccAddress { } //___________________________________________________________________________________ -// gaiacli config +// kavacli config -// CLIConfig is gaiacli config +// CLIConfig is kavacli config func (f *Fixtures) CLIConfig(key, value string, flags ...string) { - cmd := fmt.Sprintf("%s config --home=%s %s %s", f.GaiacliBinary, f.GaiacliHome, key, value) + cmd := fmt.Sprintf("%s config --home=%s %s %s", f.KavacliBinary, f.KavacliHome, key, value) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } //___________________________________________________________________________________ -// gaiacli tx send/sign/broadcast +// kavacli tx send/sign/broadcast -// TxSend is gaiacli tx send +// Status is kavacli status +func (f *Fixtures) Status(flags ...string) (bool, string, string) { + cmd := fmt.Sprintf("%s status %s", f.KavacliBinary, f.Flags()) + return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) +} + +// TxSend is kavacli tx send func (f *Fixtures) TxSend(from string, to sdk.AccAddress, amount sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags()) + cmd := fmt.Sprintf("%s tx send --keyring-backend=test %s %s %s %v", f.KavacliBinary, from, + to, amount, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxSign is gaiacli tx sign +// TxSign is kavacli tx sign func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx sign %v --from=%s %v", f.GaiacliBinary, f.Flags(), signer, fileName) + cmd := fmt.Sprintf("%s tx sign %v --keyring-backend=test --from=%s %v", f.KavacliBinary, + f.Flags(), signer, fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxBroadcast is gaiacli tx broadcast +// TxBroadcast is kavacli tx broadcast func (f *Fixtures) TxBroadcast(fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx broadcast %v %v", f.GaiacliBinary, f.Flags(), fileName) + cmd := fmt.Sprintf("%s tx broadcast %v %v", f.KavacliBinary, f.Flags(), fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxEncode is gaiacli tx encode +// TxEncode is kavacli tx encode func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx encode %v %v", f.GaiacliBinary, f.Flags(), fileName) + cmd := fmt.Sprintf("%s tx encode %v %v", f.KavacliBinary, f.Flags(), fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxMultisign is gaiacli tx multisign +// TxMultisign is kavacli tx multisign func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx multisign %v %s %s %s", f.GaiacliBinary, f.Flags(), + cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KavacliBinary, f.Flags(), fileName, name, strings.Join(signaturesFiles, " "), ) - return executeWriteRetStdStreams(f.T, cmd) + return executeWriteRetStdStreams(f.T, addFlags(cmd, flags)) } //___________________________________________________________________________________ -// gaiacli tx staking +// kavacli tx staking -// TxStakingCreateValidator is gaiacli tx staking create-validator +// TxStakingCreateValidator is kavacli tx staking create-validator func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx staking create-validator %v --from=%s --pubkey=%s", f.GaiacliBinary, f.Flags(), from, consPubKey) + cmd := fmt.Sprintf("%s tx staking create-validator %v --keyring-backend=test --from=%s"+ + " --pubkey=%s", f.KavacliBinary, f.Flags(), from, consPubKey) cmd += fmt.Sprintf(" --amount=%v --moniker=%v --commission-rate=%v", amount, from, "0.05") cmd += fmt.Sprintf(" --commission-max-rate=%v --commission-max-change-rate=%v", "0.20", "0.10") cmd += fmt.Sprintf(" --min-self-delegation=%v", "1") return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxStakingUnbond is gaiacli tx staking unbond +// TxStakingUnbond is kavacli tx staking unbond func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool { - cmd := fmt.Sprintf("%s tx staking unbond %s %v --from=%s %v", f.GaiacliBinary, validator, shares, from, f.Flags()) + cmd := fmt.Sprintf("%s tx staking unbond --keyring-backend=test %s %v --from=%s %v", + f.KavacliBinary, validator, shares, from, f.Flags()) return executeWrite(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } //___________________________________________________________________________________ -// gaiacli tx gov +// kavacli tx gov -// TxGovSubmitProposal is gaiacli tx gov submit-proposal +// TxGovSubmitProposal is kavacli tx gov submit-proposal func (f *Fixtures) TxGovSubmitProposal(from, typ, title, description string, deposit sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx gov submit-proposal %v --from=%s --type=%s", f.GaiacliBinary, f.Flags(), from, typ) + cmd := fmt.Sprintf("%s tx gov submit-proposal %v --keyring-backend=test --from=%s --type=%s", + f.KavacliBinary, f.Flags(), from, typ) cmd += fmt.Sprintf(" --title=%s --description=%s --deposit=%s", title, description, deposit) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxGovDeposit is gaiacli tx gov deposit +// TxGovDeposit is kavacli tx gov deposit func (f *Fixtures) TxGovDeposit(proposalID int, from string, amount sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx gov deposit %d %s --from=%s %v", f.GaiacliBinary, proposalID, amount, from, f.Flags()) + cmd := fmt.Sprintf("%s tx gov deposit %d %s --keyring-backend=test --from=%s %v", + f.KavacliBinary, proposalID, amount, from, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxGovVote is gaiacli tx gov vote +// TxGovVote is kavacli tx gov vote func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx gov vote %d %s --from=%s %v", f.GaiacliBinary, proposalID, option, from, f.Flags()) + cmd := fmt.Sprintf("%s tx gov vote %d %s --keyring-backend=test --from=%s %v", + f.KavacliBinary, proposalID, option, from, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } @@ -401,8 +424,8 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal( ) (bool, string, string) { cmd := fmt.Sprintf( - "%s tx gov submit-proposal param-change %s --from=%s %v", - f.GaiacliBinary, proposalPath, from, f.Flags(), + "%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v", + f.KavacliBinary, proposalPath, from, f.Flags(), ) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) @@ -415,19 +438,19 @@ func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal( ) (bool, string, string) { cmd := fmt.Sprintf( - "%s tx gov submit-proposal community-pool-spend %s --from=%s %v", - f.GaiacliBinary, proposalPath, from, f.Flags(), + "%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v", + f.KavacliBinary, proposalPath, from, f.Flags(), ) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } //___________________________________________________________________________________ -// gaiacli query account +// kavacli query account -// QueryAccount is gaiacli query account +// QueryAccount is kavacli query account func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.BaseAccount { - cmd := fmt.Sprintf("%s query account %s %v", f.GaiacliBinary, address, f.Flags()) + cmd := fmt.Sprintf("%s query account %s %v", f.KavacliBinary, address, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var initRes map[string]json.RawMessage err := json.Unmarshal([]byte(out), &initRes) @@ -442,186 +465,186 @@ func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.Ba } //___________________________________________________________________________________ -// gaiacli query txs +// kavacli query txs -// QueryTxs is gaiacli query txs -func (f *Fixtures) QueryTxs(page, limit int, tags ...string) *sdk.SearchTxsResult { - cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags()) +// QueryTxs is kavacli query txs +func (f *Fixtures) QueryTxs(page, limit int, events ...string) *sdk.SearchTxsResult { + cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var result sdk.SearchTxsResult - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &result) + + err := f.cdc.UnmarshalJSON([]byte(out), &result) require.NoError(f.T, err, "out %v\n, err %v", out, err) return &result } // QueryTxsInvalid query txs with wrong parameters and compare expected error -func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, tags ...string) { - cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags()) +func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, events ...string) { + cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags()) _, err := tests.ExecuteT(f.T, cmd, "") require.EqualError(f.T, expectedErr, err) } //___________________________________________________________________________________ -// gaiacli query staking +// kavacli query staking -// QueryStakingValidator is gaiacli query staking validator +// QueryStakingValidator is kavacli query staking validator func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string) staking.Validator { - cmd := fmt.Sprintf("%s query staking validator %s %v", f.GaiacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking validator %s %v", f.KavacliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var validator staking.Validator - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &validator) + + err := f.cdc.UnmarshalJSON([]byte(out), &validator) require.NoError(f.T, err, "out %v\n, err %v", out, err) return validator } -// QueryStakingUnbondingDelegationsFrom is gaiacli query staking unbonding-delegations-from +// QueryStakingUnbondingDelegationsFrom is kavacli query staking unbonding-delegations-from func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []staking.UnbondingDelegation { - cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.GaiacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.KavacliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var ubds []staking.UnbondingDelegation - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &ubds) + + err := f.cdc.UnmarshalJSON([]byte(out), &ubds) require.NoError(f.T, err, "out %v\n, err %v", out, err) return ubds } -// QueryStakingDelegationsTo is gaiacli query staking delegations-to +// QueryStakingDelegationsTo is kavacli query staking delegations-to func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...string) []staking.Delegation { - cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.GaiacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.KavacliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var delegations []staking.Delegation - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &delegations) + + err := f.cdc.UnmarshalJSON([]byte(out), &delegations) require.NoError(f.T, err, "out %v\n, err %v", out, err) return delegations } -// QueryStakingPool is gaiacli query staking pool +// QueryStakingPool is kavacli query staking pool func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool { - cmd := fmt.Sprintf("%s query staking pool %v", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query staking pool %v", f.KavacliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var pool staking.Pool - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &pool) + + err := f.cdc.UnmarshalJSON([]byte(out), &pool) require.NoError(f.T, err, "out %v\n, err %v", out, err) return pool } -// QueryStakingParameters is gaiacli query staking parameters +// QueryStakingParameters is kavacli query staking parameters func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params { - cmd := fmt.Sprintf("%s query staking params %v", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query staking params %v", f.KavacliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var params staking.Params - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), ¶ms) + + err := f.cdc.UnmarshalJSON([]byte(out), ¶ms) require.NoError(f.T, err, "out %v\n, err %v", out, err) return params } //___________________________________________________________________________________ -// gaiacli query gov +// kavacli query gov -// QueryGovParamDeposit is gaiacli query gov param deposit +// QueryGovParamDeposit is kavacli query gov param deposit func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams { - cmd := fmt.Sprintf("%s query gov param deposit %s", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param deposit %s", f.KavacliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var depositParam gov.DepositParams - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &depositParam) + + err := f.cdc.UnmarshalJSON([]byte(out), &depositParam) require.NoError(f.T, err, "out %v\n, err %v", out, err) return depositParam } -// QueryGovParamVoting is gaiacli query gov param voting +// QueryGovParamVoting is kavacli query gov param voting func (f *Fixtures) QueryGovParamVoting() gov.VotingParams { - cmd := fmt.Sprintf("%s query gov param voting %s", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param voting %s", f.KavacliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var votingParam gov.VotingParams - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &votingParam) + + err := f.cdc.UnmarshalJSON([]byte(out), &votingParam) require.NoError(f.T, err, "out %v\n, err %v", out, err) return votingParam } -// QueryGovParamTallying is gaiacli query gov param tallying +// QueryGovParamTallying is kavacli query gov param tallying func (f *Fixtures) QueryGovParamTallying() gov.TallyParams { - cmd := fmt.Sprintf("%s query gov param tallying %s", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param tallying %s", f.KavacliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var tallyingParam gov.TallyParams - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &tallyingParam) + + err := f.cdc.UnmarshalJSON([]byte(out), &tallyingParam) require.NoError(f.T, err, "out %v\n, err %v", out, err) return tallyingParam } -// QueryGovProposals is gaiacli query gov proposals +// QueryGovProposals is kavacli query gov proposals func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals { - cmd := fmt.Sprintf("%s query gov proposals %v", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov proposals %v", f.KavacliBinary, f.Flags()) stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "") if strings.Contains(stderr, "no matching proposals found") { return gov.Proposals{} } require.Empty(f.T, stderr) var out gov.Proposals - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(stdout), &out) + + err := f.cdc.UnmarshalJSON([]byte(stdout), &out) require.NoError(f.T, err) return out } -// QueryGovProposal is gaiacli query gov proposal +// QueryGovProposal is kavacli query gov proposal func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposal { - cmd := fmt.Sprintf("%s query gov proposal %d %v", f.GaiacliBinary, proposalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov proposal %d %v", f.KavacliBinary, proposalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var proposal gov.Proposal - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &proposal) + + err := f.cdc.UnmarshalJSON([]byte(out), &proposal) require.NoError(f.T, err, "out %v\n, err %v", out, err) return proposal } -// QueryGovVote is gaiacli query gov vote +// QueryGovVote is kavacli query gov vote func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...string) gov.Vote { - cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.GaiacliBinary, proposalID, voter, f.Flags()) + cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.KavacliBinary, proposalID, voter, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var vote gov.Vote - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &vote) + + err := f.cdc.UnmarshalJSON([]byte(out), &vote) require.NoError(f.T, err, "out %v\n, err %v", out, err) return vote } -// QueryGovVotes is gaiacli query gov votes +// QueryGovVotes is kavacli query gov votes func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote { - cmd := fmt.Sprintf("%s query gov votes %d %v", f.GaiacliBinary, proposalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov votes %d %v", f.KavacliBinary, proposalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var votes []gov.Vote - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &votes) + + err := f.cdc.UnmarshalJSON([]byte(out), &votes) require.NoError(f.T, err, "out %v\n, err %v", out, err) return votes } -// QueryGovDeposit is gaiacli query gov deposit +// QueryGovDeposit is kavacli query gov deposit func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, flags ...string) gov.Deposit { - cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.GaiacliBinary, proposalID, depositor, f.Flags()) + cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.KavacliBinary, proposalID, depositor, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var deposit gov.Deposit - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &deposit) + + err := f.cdc.UnmarshalJSON([]byte(out), &deposit) require.NoError(f.T, err, "out %v\n, err %v", out, err) return deposit } -// QueryGovDeposits is gaiacli query gov deposits +// QueryGovDeposits is kavacli query gov deposits func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposit { - cmd := fmt.Sprintf("%s query gov deposits %d %v", f.GaiacliBinary, propsalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov deposits %d %v", f.KavacliBinary, propsalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var deposits []gov.Deposit - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(out), &deposits) + + err := f.cdc.UnmarshalJSON([]byte(out), &deposits) require.NoError(f.T, err, "out %v\n, err %v", out, err) return deposits } @@ -631,24 +654,24 @@ func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposi // QuerySigningInfo returns the signing info for a validator func (f *Fixtures) QuerySigningInfo(val string) slashing.ValidatorSigningInfo { - cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.GaiacliBinary, val, f.Flags()) + cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.KavacliBinary, val, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) - cdc := app.MakeCodec() + var sinfo slashing.ValidatorSigningInfo - err := cdc.UnmarshalJSON([]byte(res), &sinfo) + err := f.cdc.UnmarshalJSON([]byte(res), &sinfo) require.NoError(f.T, err) return sinfo } -// QuerySlashingParams is gaiacli query slashing params +// QuerySlashingParams is kavacli query slashing params func (f *Fixtures) QuerySlashingParams() slashing.Params { - cmd := fmt.Sprintf("%s query slashing params %s", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query slashing params %s", f.KavacliBinary, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) - cdc := app.MakeCodec() + var params slashing.Params - err := cdc.UnmarshalJSON([]byte(res), ¶ms) + err := f.cdc.UnmarshalJSON([]byte(res), ¶ms) require.NoError(f.T, err) return params } @@ -658,12 +681,12 @@ func (f *Fixtures) QuerySlashingParams() slashing.Params { // QueryRewards returns the rewards of a delegator func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distribution.QueryDelegatorTotalRewardsResponse { - cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.GaiacliBinary, delAddr, f.Flags()) + cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.KavacliBinary, delAddr, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) - cdc := app.MakeCodec() + var rewards distribution.QueryDelegatorTotalRewardsResponse - err := cdc.UnmarshalJSON([]byte(res), &rewards) + err := f.cdc.UnmarshalJSON([]byte(res), &rewards) require.NoError(f.T, err) return rewards } @@ -673,23 +696,23 @@ func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distrib // QueryTotalSupply returns the total supply of coins func (f *Fixtures) QueryTotalSupply(flags ...string) (totalSupply sdk.Coins) { - cmd := fmt.Sprintf("%s query supply total %s", f.GaiacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query bank total %s", f.KavacliBinary, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) - cdc := app.MakeCodec() - err := cdc.UnmarshalJSON([]byte(res), &totalSupply) + + err := f.cdc.UnmarshalJSON([]byte(res), &totalSupply) require.NoError(f.T, err) return totalSupply } // QueryTotalSupplyOf returns the total supply of a given coin denom func (f *Fixtures) QueryTotalSupplyOf(denom string, flags ...string) sdk.Int { - cmd := fmt.Sprintf("%s query supply total %s %s", f.GaiacliBinary, denom, f.Flags()) + cmd := fmt.Sprintf("%s query bank total %s %s", f.KavacliBinary, denom, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) - cdc := app.MakeCodec() + var supplyOf sdk.Int - err := cdc.UnmarshalJSON([]byte(res), &supplyOf) + err := f.cdc.UnmarshalJSON([]byte(res), &supplyOf) require.NoError(f.T, err) return supplyOf } @@ -746,9 +769,9 @@ func addFlags(cmd string, flags []string) string { return strings.TrimSpace(cmd) } -func queryTags(tags []string) (out string) { - for _, tag := range tags { - out += tag + "&" +func queryEvents(events []string) (out string) { + for _, event := range events { + out += event + "&" } return strings.TrimSuffix(out, "&") } @@ -762,15 +785,15 @@ func WriteToNewTempFile(t *testing.T, s string) *os.File { return fp } -func marshalStdTx(t *testing.T, stdTx auth.StdTx) []byte { - cdc := app.MakeCodec() - bz, err := cdc.MarshalBinaryBare(stdTx) +//nolint:deadcode,unused +func (f *Fixtures) marshalStdTx(t *testing.T, stdTx auth.StdTx) []byte { + bz, err := f.cdc.MarshalBinaryBare(stdTx) require.NoError(t, err) return bz } -func unmarshalStdTx(t *testing.T, s string) (stdTx auth.StdTx) { - cdc := app.MakeCodec() - require.Nil(t, cdc.UnmarshalJSON([]byte(s), &stdTx)) +//nolint:deadcode,unused +func (f *Fixtures) unmarshalStdTx(t *testing.T, s string) (stdTx auth.StdTx) { + require.Nil(t, f.cdc.UnmarshalJSON([]byte(s), &stdTx)) return } From 1cd1b1e259896b79b6589bcf0b1fa4489498be21 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Mon, 27 Apr 2020 13:28:42 -0400 Subject: [PATCH 2/7] update pubkey --- cli_test/cli_test.go | 3 ++- cli_test/test_helpers.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 9a5a742a..e09b48a7 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -397,8 +397,9 @@ func TestKavaCLICreateValidator(t *testing.T) { barAddr := f.KeyAddress(keyBar) barVal := sdk.ValAddress(barAddr) - consPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, ed25519.GenPrivKey().PubKey()) + consPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeValPub, ed25519.GenPrivKey().PubKey()) require.NoError(t, err) + require.NotEmpty(t, consPubKey) sendTokens := sdk.TokensFromConsensusPower(10) f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 1470a81c..b4e06774 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -66,7 +66,7 @@ func init() { // set the address prefixes config := sdk.GetConfig() app.SetBech32AddressPrefixes(config) - config.Seal() + // config.Seal() } //___________________________________________________________________________________ From e33898cc1a16a740d7927c4eb71ec4420eb40f0e Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 28 Apr 2020 10:10:02 -0400 Subject: [PATCH 3/7] rename --- cli_test/cli_test.go | 44 +++---- cli_test/test_helpers.go | 240 +++++++++++++++++++-------------------- 2 files changed, 142 insertions(+), 142 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index e09b48a7..469e265e 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -99,7 +99,7 @@ func TestKavaCLIMinimumFees(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") fees := fmt.Sprintf( "--minimum-gas-prices=%s,%s", @@ -137,7 +137,7 @@ func TestKavaCLIGasPrices(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice))) defer proc.Stop(false) @@ -171,7 +171,7 @@ func TestKavaCLIFeesDeduction(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees minGasPrice, _ := sdk.NewDecFromStr("0.000006") proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice))) defer proc.Stop(false) @@ -224,7 +224,7 @@ func TestKavaCLISend(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -294,7 +294,7 @@ func TestKavaCLIConfirmTx(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -330,7 +330,7 @@ func TestKavaCLIGasAuto(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -390,7 +390,7 @@ func TestKavaCLICreateValidator(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -477,13 +477,13 @@ func TestKavaCLIQueryRewards(t *testing.T) { require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz - genFile := filepath.Join(f.KavadHome, "config", "genesis.json") + genFile := filepath.Join(f.KvdHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) require.NoError(t, genDoc.SaveAs(genFile)) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -498,7 +498,7 @@ func TestKavaCLIQuerySupply(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -515,7 +515,7 @@ func TestKavaCLISubmitProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -736,7 +736,7 @@ func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) { require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz - genFile := filepath.Join(f.KavadHome, "config", "genesis.json") + genFile := filepath.Join(f.KvdHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) genDoc.AppState, err = cdc.MarshalJSON(genesisState) @@ -807,7 +807,7 @@ func TestKavaCLIQueryTxPagination(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -857,7 +857,7 @@ func TestKavaCLIValidateSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -907,7 +907,7 @@ func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -991,7 +991,7 @@ func TestKavaCLIMultisignInsufficientCosigners(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1044,7 +1044,7 @@ func TestKavaCLIEncode(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -1082,7 +1082,7 @@ func TestKavaCLIMultisignSortSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1147,7 +1147,7 @@ func TestKavaCLIMultisign(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server with minimum fees + // start kvd server with minimum fees proc := f.GDStart() defer proc.Stop(false) @@ -1223,7 +1223,7 @@ func TestKavaCLIConfig(t *testing.T) { f.CLIConfig("trace", "false") f.CLIConfig("indent", "true") - config, err := ioutil.ReadFile(path.Join(f.KavacliHome, "config", "config.toml")) + config, err := ioutil.ReadFile(path.Join(f.KvcliHome, "config", "config.toml")) require.NoError(t, err) expectedConfig := fmt.Sprintf(`broadcast-mode = "block" chain-id = "%s" @@ -1335,7 +1335,7 @@ func TestSlashingGetParams(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) @@ -1355,7 +1355,7 @@ func TestValidateGenesis(t *testing.T) { t.Parallel() f := InitFixtures(t) - // start kavad server + // start kvd server proc := f.GDStart() defer proc.Stop(false) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index b4e06774..f4d3f312 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -74,17 +74,17 @@ func init() { // Fixtures is used to setup the testing environment type Fixtures struct { - BuildDir string - RootDir string - KavadBinary string - KavacliBinary string - ChainID string - RPCAddr string - Port string - KavadHome string - KavacliHome string - P2PAddr string - T *testing.T + BuildDir string + RootDir string + KvdBinary string + KvcliBinary string + ChainID string + RPCAddr string + Port string + KvdHome string + KvcliHome string + P2PAddr string + T *testing.T cdc *codec.Codec } @@ -109,23 +109,23 @@ func NewFixtures(t *testing.T) *Fixtures { cdc := app.MakeCodec() return &Fixtures{ - T: t, - BuildDir: buildDir, - RootDir: tmpDir, - KavadBinary: filepath.Join(buildDir, "kvd"), - KavacliBinary: filepath.Join(buildDir, "kvcli"), - KavadHome: filepath.Join(tmpDir, ".kvd"), - KavacliHome: filepath.Join(tmpDir, ".kvcli"), - RPCAddr: servAddr, - P2PAddr: p2pAddr, - Port: port, - cdc: cdc, + T: t, + BuildDir: buildDir, + RootDir: tmpDir, + KvdBinary: filepath.Join(buildDir, "kvd"), + KvcliBinary: filepath.Join(buildDir, "kvcli"), + KvdHome: filepath.Join(tmpDir, ".kvd"), + KvcliHome: filepath.Join(tmpDir, ".kvcli"), + RPCAddr: servAddr, + P2PAddr: p2pAddr, + Port: port, + cdc: cdc, } } // GenesisFile returns the path of the genesis file func (f Fixtures) GenesisFile() string { - return filepath.Join(f.KavadHome, "config", "genesis.json") + return filepath.Join(f.KvdHome, "config", "genesis.json") } // GenesisState returns the application's genesis state @@ -194,7 +194,7 @@ func (f *Fixtures) Cleanup(dirs ...string) { // Flags returns the flags necessary for making most CLI calls func (f *Fixtures) Flags() string { - return fmt.Sprintf("--home=%s --node=%s", f.KavacliHome, f.RPCAddr) + return fmt.Sprintf("--home=%s --node=%s", f.KvcliHome, f.RPCAddr) } //___________________________________________________________________________________ @@ -202,16 +202,16 @@ func (f *Fixtures) Flags() string { // UnsafeResetAll is kavad unsafe-reset-all func (f *Fixtures) UnsafeResetAll(flags ...string) { - cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.KavadBinary, f.KavadHome) + cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.KvdBinary, f.KvdHome) executeWrite(f.T, addFlags(cmd, flags)) - err := os.RemoveAll(filepath.Join(f.KavadHome, "config", "gentx")) + err := os.RemoveAll(filepath.Join(f.KvdHome, "config", "gentx")) require.NoError(f.T, err) } // GDInit is kavad init // NOTE: GDInit sets the ChainID for the Fixtures instance func (f *Fixtures) GDInit(moniker string, flags ...string) { - cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KavadBinary, f.KavadHome, moniker) + cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KvdBinary, f.KvdHome, moniker) _, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) var chainID string @@ -228,25 +228,25 @@ func (f *Fixtures) GDInit(moniker string, flags ...string) { // AddGenesisAccount is kavad add-genesis-account func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, flags ...string) { - cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s --keyring-backend=test", f.KavadBinary, address, coins, f.KavadHome) + cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s --keyring-backend=test", f.KvdBinary, address, coins, f.KvdHome) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } // GenTx is kavad gentx func (f *Fixtures) GenTx(name string, flags ...string) { - cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.KavadBinary, name, f.KavadHome, f.KavacliHome) + cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.KvdBinary, name, f.KvdHome, f.KvcliHome) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } // CollectGenTxs is kavad collect-gentxs func (f *Fixtures) CollectGenTxs(flags ...string) { - cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.KavadBinary, f.KavadHome) + cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.KvdBinary, f.KvdHome) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } // GDStart runs kavad start with the appropriate flags and returns a process func (f *Fixtures) GDStart(flags ...string) *tests.Process { - cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.KavadBinary, f.KavadHome, f.RPCAddr, f.P2PAddr) + cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.KvdBinary, f.KvdHome, f.RPCAddr, f.P2PAddr) proc := tests.GoExecuteTWithStdout(f.T, addFlags(cmd, flags)) tests.WaitForTMStart(f.Port) tests.WaitForNextNBlocksTM(1, f.Port) @@ -255,7 +255,7 @@ func (f *Fixtures) GDStart(flags ...string) *tests.Process { // GDTendermint returns the results of kavad tendermint [query] func (f *Fixtures) GDTendermint(query string) string { - cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.KavadBinary, query, f.KavadHome) + cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.KvdBinary, query, f.KvdHome) success, stdout, stderr := executeWriteRetStdStreams(f.T, cmd) require.Empty(f.T, stderr) require.True(f.T, success) @@ -264,45 +264,45 @@ func (f *Fixtures) GDTendermint(query string) string { // ValidateGenesis runs kavad validate-genesis func (f *Fixtures) ValidateGenesis() { - cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.KavadBinary, f.KavadHome) + cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.KvdBinary, f.KvdHome) executeWriteCheckErr(f.T, cmd) } //___________________________________________________________________________________ -// kavacli keys +// kvcli keys -// KeysDelete is kavacli keys delete +// KeysDelete is kvcli keys delete func (f *Fixtures) KeysDelete(name string, flags ...string) { - cmd := fmt.Sprintf("%s keys delete --keyring-backend=test --home=%s %s", f.KavacliBinary, - f.KavacliHome, name) + cmd := fmt.Sprintf("%s keys delete --keyring-backend=test --home=%s %s", f.KvcliBinary, + f.KvcliHome, name) executeWrite(f.T, addFlags(cmd, append(append(flags, "-y"), "-f"))) } -// KeysAdd is kavacli keys add +// KeysAdd is kvcli keys add func (f *Fixtures) KeysAdd(name string, flags ...string) { - cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s %s", f.KavacliBinary, - f.KavacliHome, name) + cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s %s", f.KvcliBinary, + f.KvcliHome, name) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } -// KeysAddRecover prepares kavacli keys add --recover +// KeysAddRecover prepares kvcli keys add --recover func (f *Fixtures) KeysAddRecover(name, mnemonic string, flags ...string) (exitSuccess bool, stdout, stderr string) { cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s", - f.KavacliBinary, f.KavacliHome, name) + f.KvcliBinary, f.KvcliHome, name) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), mnemonic) } -// KeysAddRecoverHDPath prepares kavacli keys add --recover --account --index +// KeysAddRecoverHDPath prepares kvcli keys add --recover --account --index func (f *Fixtures) KeysAddRecoverHDPath(name, mnemonic string, account uint32, index uint32, flags ...string) { cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s --account %d"+ - " --index %d", f.KavacliBinary, f.KavacliHome, name, account, index) + " --index %d", f.KvcliBinary, f.KvcliHome, name, account, index) executeWriteCheckErr(f.T, addFlags(cmd, flags), mnemonic) } -// KeysShow is kavacli keys show +// KeysShow is kvcli keys show func (f *Fixtures) KeysShow(name string, flags ...string) keys.KeyOutput { - cmd := fmt.Sprintf("%s keys show --keyring-backend=test --home=%s %s", f.KavacliBinary, - f.KavacliHome, name) + cmd := fmt.Sprintf("%s keys show --keyring-backend=test --home=%s %s", f.KvcliBinary, + f.KvcliHome, name) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var ko keys.KeyOutput err := clientkeys.UnmarshalJSON([]byte(out), &ko) @@ -319,101 +319,101 @@ func (f *Fixtures) KeyAddress(name string) sdk.AccAddress { } //___________________________________________________________________________________ -// kavacli config +// kvcli config -// CLIConfig is kavacli config +// CLIConfig is kvcli config func (f *Fixtures) CLIConfig(key, value string, flags ...string) { - cmd := fmt.Sprintf("%s config --home=%s %s %s", f.KavacliBinary, f.KavacliHome, key, value) + cmd := fmt.Sprintf("%s config --home=%s %s %s", f.KvcliBinary, f.KvcliHome, key, value) executeWriteCheckErr(f.T, addFlags(cmd, flags)) } //___________________________________________________________________________________ -// kavacli tx send/sign/broadcast +// kvcli tx send/sign/broadcast -// Status is kavacli status +// Status is kvcli status func (f *Fixtures) Status(flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s status %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s status %s", f.KvcliBinary, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxSend is kavacli tx send +// TxSend is kvcli tx send func (f *Fixtures) TxSend(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.KavacliBinary, from, + cmd := fmt.Sprintf("%s tx send --keyring-backend=test %s %s %s %v", f.KvcliBinary, from, to, amount, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxSign is kavacli tx sign +// TxSign is kvcli tx sign func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx sign %v --keyring-backend=test --from=%s %v", f.KavacliBinary, + cmd := fmt.Sprintf("%s tx sign %v --keyring-backend=test --from=%s %v", f.KvcliBinary, f.Flags(), signer, fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxBroadcast is kavacli tx broadcast +// TxBroadcast is kvcli tx broadcast func (f *Fixtures) TxBroadcast(fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx broadcast %v %v", f.KavacliBinary, f.Flags(), fileName) + cmd := fmt.Sprintf("%s tx broadcast %v %v", f.KvcliBinary, f.Flags(), fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxEncode is kavacli tx encode +// TxEncode is kvcli tx encode func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx encode %v %v", f.KavacliBinary, f.Flags(), fileName) + cmd := fmt.Sprintf("%s tx encode %v %v", f.KvcliBinary, f.Flags(), fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxMultisign is kavacli tx multisign +// TxMultisign is kvcli tx multisign func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KavacliBinary, f.Flags(), + cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KvcliBinary, f.Flags(), fileName, name, strings.Join(signaturesFiles, " "), ) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags)) } //___________________________________________________________________________________ -// kavacli tx staking +// kvcli tx staking -// TxStakingCreateValidator is kavacli tx staking create-validator +// TxStakingCreateValidator is kvcli tx staking create-validator func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) { cmd := fmt.Sprintf("%s tx staking create-validator %v --keyring-backend=test --from=%s"+ - " --pubkey=%s", f.KavacliBinary, f.Flags(), from, consPubKey) + " --pubkey=%s", f.KvcliBinary, f.Flags(), from, consPubKey) cmd += fmt.Sprintf(" --amount=%v --moniker=%v --commission-rate=%v", amount, from, "0.05") cmd += fmt.Sprintf(" --commission-max-rate=%v --commission-max-change-rate=%v", "0.20", "0.10") cmd += fmt.Sprintf(" --min-self-delegation=%v", "1") return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxStakingUnbond is kavacli tx staking unbond +// TxStakingUnbond is kvcli tx staking unbond func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool { cmd := fmt.Sprintf("%s tx staking unbond --keyring-backend=test %s %v --from=%s %v", - f.KavacliBinary, validator, shares, from, f.Flags()) + f.KvcliBinary, validator, shares, from, f.Flags()) return executeWrite(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } //___________________________________________________________________________________ -// kavacli tx gov +// kvcli tx gov -// TxGovSubmitProposal is kavacli tx gov submit-proposal +// TxGovSubmitProposal is kvcli tx gov submit-proposal func (f *Fixtures) TxGovSubmitProposal(from, typ, title, description string, deposit sdk.Coin, flags ...string) (bool, string, string) { cmd := fmt.Sprintf("%s tx gov submit-proposal %v --keyring-backend=test --from=%s --type=%s", - f.KavacliBinary, f.Flags(), from, typ) + f.KvcliBinary, f.Flags(), from, typ) cmd += fmt.Sprintf(" --title=%s --description=%s --deposit=%s", title, description, deposit) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxGovDeposit is kavacli tx gov deposit +// TxGovDeposit is kvcli tx gov deposit func (f *Fixtures) TxGovDeposit(proposalID int, from string, amount sdk.Coin, flags ...string) (bool, string, string) { cmd := fmt.Sprintf("%s tx gov deposit %d %s --keyring-backend=test --from=%s %v", - f.KavacliBinary, proposalID, amount, from, f.Flags()) + f.KvcliBinary, proposalID, amount, from, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } -// TxGovVote is kavacli tx gov vote +// TxGovVote is kvcli tx gov vote func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string, flags ...string) (bool, string, string) { cmd := fmt.Sprintf("%s tx gov vote %d %s --keyring-backend=test --from=%s %v", - f.KavacliBinary, proposalID, option, from, f.Flags()) + f.KvcliBinary, proposalID, option, from, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } @@ -425,7 +425,7 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal( cmd := fmt.Sprintf( "%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v", - f.KavacliBinary, proposalPath, from, f.Flags(), + f.KvcliBinary, proposalPath, from, f.Flags(), ) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) @@ -439,18 +439,18 @@ func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal( cmd := fmt.Sprintf( "%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v", - f.KavacliBinary, proposalPath, from, f.Flags(), + f.KvcliBinary, proposalPath, from, f.Flags(), ) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) } //___________________________________________________________________________________ -// kavacli query account +// kvcli query account -// QueryAccount is kavacli query account +// QueryAccount is kvcli query account func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.BaseAccount { - cmd := fmt.Sprintf("%s query account %s %v", f.KavacliBinary, address, f.Flags()) + cmd := fmt.Sprintf("%s query account %s %v", f.KvcliBinary, address, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var initRes map[string]json.RawMessage err := json.Unmarshal([]byte(out), &initRes) @@ -465,11 +465,11 @@ func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.Ba } //___________________________________________________________________________________ -// kavacli query txs +// kvcli query txs -// QueryTxs is kavacli query txs +// QueryTxs is kvcli query txs func (f *Fixtures) QueryTxs(page, limit int, events ...string) *sdk.SearchTxsResult { - cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags()) + cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KvcliBinary, page, limit, queryEvents(events), f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var result sdk.SearchTxsResult @@ -480,17 +480,17 @@ func (f *Fixtures) QueryTxs(page, limit int, events ...string) *sdk.SearchTxsRes // QueryTxsInvalid query txs with wrong parameters and compare expected error func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, events ...string) { - cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags()) + cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KvcliBinary, page, limit, queryEvents(events), f.Flags()) _, err := tests.ExecuteT(f.T, cmd, "") require.EqualError(f.T, expectedErr, err) } //___________________________________________________________________________________ -// kavacli query staking +// kvcli query staking -// QueryStakingValidator is kavacli query staking validator +// QueryStakingValidator is kvcli query staking validator func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string) staking.Validator { - cmd := fmt.Sprintf("%s query staking validator %s %v", f.KavacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking validator %s %v", f.KvcliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var validator staking.Validator @@ -499,9 +499,9 @@ func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string return validator } -// QueryStakingUnbondingDelegationsFrom is kavacli query staking unbonding-delegations-from +// QueryStakingUnbondingDelegationsFrom is kvcli query staking unbonding-delegations-from func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []staking.UnbondingDelegation { - cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.KavacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.KvcliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var ubds []staking.UnbondingDelegation @@ -510,9 +510,9 @@ func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, return ubds } -// QueryStakingDelegationsTo is kavacli query staking delegations-to +// QueryStakingDelegationsTo is kvcli query staking delegations-to func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...string) []staking.Delegation { - cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.KavacliBinary, valAddr, f.Flags()) + cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.KvcliBinary, valAddr, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var delegations []staking.Delegation @@ -521,9 +521,9 @@ func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...st return delegations } -// QueryStakingPool is kavacli query staking pool +// QueryStakingPool is kvcli query staking pool func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool { - cmd := fmt.Sprintf("%s query staking pool %v", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query staking pool %v", f.KvcliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var pool staking.Pool @@ -532,9 +532,9 @@ func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool { return pool } -// QueryStakingParameters is kavacli query staking parameters +// QueryStakingParameters is kvcli query staking parameters func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params { - cmd := fmt.Sprintf("%s query staking params %v", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query staking params %v", f.KvcliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var params staking.Params @@ -544,11 +544,11 @@ func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params { } //___________________________________________________________________________________ -// kavacli query gov +// kvcli query gov -// QueryGovParamDeposit is kavacli query gov param deposit +// QueryGovParamDeposit is kvcli query gov param deposit func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams { - cmd := fmt.Sprintf("%s query gov param deposit %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param deposit %s", f.KvcliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var depositParam gov.DepositParams @@ -557,9 +557,9 @@ func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams { return depositParam } -// QueryGovParamVoting is kavacli query gov param voting +// QueryGovParamVoting is kvcli query gov param voting func (f *Fixtures) QueryGovParamVoting() gov.VotingParams { - cmd := fmt.Sprintf("%s query gov param voting %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param voting %s", f.KvcliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var votingParam gov.VotingParams @@ -568,9 +568,9 @@ func (f *Fixtures) QueryGovParamVoting() gov.VotingParams { return votingParam } -// QueryGovParamTallying is kavacli query gov param tallying +// QueryGovParamTallying is kvcli query gov param tallying func (f *Fixtures) QueryGovParamTallying() gov.TallyParams { - cmd := fmt.Sprintf("%s query gov param tallying %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov param tallying %s", f.KvcliBinary, f.Flags()) out, _ := tests.ExecuteT(f.T, cmd, "") var tallyingParam gov.TallyParams @@ -579,9 +579,9 @@ func (f *Fixtures) QueryGovParamTallying() gov.TallyParams { return tallyingParam } -// QueryGovProposals is kavacli query gov proposals +// QueryGovProposals is kvcli query gov proposals func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals { - cmd := fmt.Sprintf("%s query gov proposals %v", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query gov proposals %v", f.KvcliBinary, f.Flags()) stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "") if strings.Contains(stderr, "no matching proposals found") { return gov.Proposals{} @@ -594,9 +594,9 @@ func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals { return out } -// QueryGovProposal is kavacli query gov proposal +// QueryGovProposal is kvcli query gov proposal func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposal { - cmd := fmt.Sprintf("%s query gov proposal %d %v", f.KavacliBinary, proposalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov proposal %d %v", f.KvcliBinary, proposalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var proposal gov.Proposal @@ -605,9 +605,9 @@ func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposa return proposal } -// QueryGovVote is kavacli query gov vote +// QueryGovVote is kvcli query gov vote func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...string) gov.Vote { - cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.KavacliBinary, proposalID, voter, f.Flags()) + cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.KvcliBinary, proposalID, voter, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var vote gov.Vote @@ -616,9 +616,9 @@ func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...s return vote } -// QueryGovVotes is kavacli query gov votes +// QueryGovVotes is kvcli query gov votes func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote { - cmd := fmt.Sprintf("%s query gov votes %d %v", f.KavacliBinary, proposalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov votes %d %v", f.KvcliBinary, proposalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var votes []gov.Vote @@ -627,9 +627,9 @@ func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote { return votes } -// QueryGovDeposit is kavacli query gov deposit +// QueryGovDeposit is kvcli query gov deposit func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, flags ...string) gov.Deposit { - cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.KavacliBinary, proposalID, depositor, f.Flags()) + cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.KvcliBinary, proposalID, depositor, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var deposit gov.Deposit @@ -638,9 +638,9 @@ func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, fla return deposit } -// QueryGovDeposits is kavacli query gov deposits +// QueryGovDeposits is kvcli query gov deposits func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposit { - cmd := fmt.Sprintf("%s query gov deposits %d %v", f.KavacliBinary, propsalID, f.Flags()) + cmd := fmt.Sprintf("%s query gov deposits %d %v", f.KvcliBinary, propsalID, f.Flags()) out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "") var deposits []gov.Deposit @@ -654,7 +654,7 @@ func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposi // QuerySigningInfo returns the signing info for a validator func (f *Fixtures) QuerySigningInfo(val string) slashing.ValidatorSigningInfo { - cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.KavacliBinary, val, f.Flags()) + cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.KvcliBinary, val, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) @@ -664,9 +664,9 @@ func (f *Fixtures) QuerySigningInfo(val string) slashing.ValidatorSigningInfo { return sinfo } -// QuerySlashingParams is kavacli query slashing params +// QuerySlashingParams is kvcli query slashing params func (f *Fixtures) QuerySlashingParams() slashing.Params { - cmd := fmt.Sprintf("%s query slashing params %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query slashing params %s", f.KvcliBinary, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) @@ -681,7 +681,7 @@ func (f *Fixtures) QuerySlashingParams() slashing.Params { // QueryRewards returns the rewards of a delegator func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distribution.QueryDelegatorTotalRewardsResponse { - cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.KavacliBinary, delAddr, f.Flags()) + cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.KvcliBinary, delAddr, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) @@ -696,7 +696,7 @@ func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distrib // QueryTotalSupply returns the total supply of coins func (f *Fixtures) QueryTotalSupply(flags ...string) (totalSupply sdk.Coins) { - cmd := fmt.Sprintf("%s query bank total %s", f.KavacliBinary, f.Flags()) + cmd := fmt.Sprintf("%s query supply total %s", f.KvcliBinary, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) @@ -707,7 +707,7 @@ func (f *Fixtures) QueryTotalSupply(flags ...string) (totalSupply sdk.Coins) { // QueryTotalSupplyOf returns the total supply of a given coin denom func (f *Fixtures) QueryTotalSupplyOf(denom string, flags ...string) sdk.Int { - cmd := fmt.Sprintf("%s query bank total %s %s", f.KavacliBinary, denom, f.Flags()) + cmd := fmt.Sprintf("%s query supply total %s %s", f.KvcliBinary, denom, f.Flags()) res, errStr := tests.ExecuteT(f.T, cmd, "") require.Empty(f.T, errStr) From 353c2e9b745379a46edfc962f924623511c3e017 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 28 Apr 2020 10:27:12 -0400 Subject: [PATCH 4/7] update cli_test.go --- cli_test/cli_test.go | 249 ++++++++++++++++++--------------------- cli_test/test_helpers.go | 10 +- 2 files changed, 122 insertions(+), 137 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 469e265e..5f8d5d72 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -14,7 +14,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" tmtypes "github.com/tendermint/tendermint/types" @@ -24,20 +23,22 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/mint" - - "github.com/kava-labs/kava/app" ) -func TestKavaCLIKeysAddMultisig(t *testing.T) { +func TestKvCLIKeysAddMultisig(t *testing.T) { t.Parallel() f := InitFixtures(t) // key names order does not matter f.KeysAdd("msig1", "--multisig-threshold=2", fmt.Sprintf("--multisig=%s,%s", keyBar, keyBaz)) + ke1Address1 := f.KeysShow("msig1").Address + f.KeysDelete("msig1") + f.KeysAdd("msig2", "--multisig-threshold=2", fmt.Sprintf("--multisig=%s,%s", keyBaz, keyBar)) - require.Equal(t, f.KeysShow("msig1").Address, f.KeysShow("msig2").Address) + require.Equal(t, ke1Address1, f.KeysShow("msig2").Address) + f.KeysDelete("msig2") f.KeysAdd("msig3", "--multisig-threshold=2", fmt.Sprintf("--multisig=%s,%s", keyBar, keyBaz), @@ -51,7 +52,7 @@ func TestKavaCLIKeysAddMultisig(t *testing.T) { f.Cleanup() } -func TestKavaCLIKeysAddRecover(t *testing.T) { +func TestKvCLIKeysAddRecover(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -95,7 +96,7 @@ func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) { f.Cleanup() } -func TestKavaCLIMinimumFees(t *testing.T) { +func TestKvCLIMinimumFees(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -133,7 +134,7 @@ func TestKavaCLIMinimumFees(t *testing.T) { f.Cleanup() } -func TestKavaCLIGasPrices(t *testing.T) { +func TestKvCLIGasPrices(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -167,7 +168,7 @@ func TestKavaCLIGasPrices(t *testing.T) { f.Cleanup() } -func TestKavaCLIFeesDeduction(t *testing.T) { +func TestKvCLIFeesDeduction(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -220,7 +221,7 @@ func TestKavaCLIFeesDeduction(t *testing.T) { f.Cleanup() } -func TestKavaCLISend(t *testing.T) { +func TestKvCLISend(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -236,8 +237,15 @@ func TestKavaCLISend(t *testing.T) { startTokens := sdk.TokensFromConsensusPower(50) require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) - // Send some tokens from one account to the other sendTokens := sdk.TokensFromConsensusPower(10) + + // It does not allow to send in offline mode + success, _, stdErr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y", "--offline") + require.Contains(t, stdErr, "no RPC client is defined in offline mode") + require.False(f.T, success) + tests.WaitForNextNBlocksTM(1, f.Port) + + // Send some tokens from one account to the other f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") tests.WaitForNextNBlocksTM(1, f.Port) @@ -248,7 +256,7 @@ func TestKavaCLISend(t *testing.T) { require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom)) // Test --dry-run - success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run") + success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run") require.True(t, success) // Test --generate-only @@ -289,42 +297,7 @@ func TestKavaCLISend(t *testing.T) { f.Cleanup() } -// Note: this was removed from kava due to update in sdk PR#4062 but is now working -func TestKavaCLIConfirmTx(t *testing.T) { - t.Parallel() - f := InitFixtures(t) - - // start kvd server - proc := f.GDStart() - defer proc.Stop(false) - - // Save key addresses for later use - fooAddr := f.KeyAddress(keyFoo) - barAddr := f.KeyAddress(keyBar) - - fooAcc := f.QueryAccount(fooAddr) - startTokens := sdk.TokensFromConsensusPower(50) - require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) - - // send some tokens from one account to the other - sendTokens := sdk.TokensFromConsensusPower(10) - f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") - tests.WaitForNextNBlocksTM(1, f.Port) - - // ensure account balances match expected - barAcc := f.QueryAccount(barAddr) - require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom)) - - // send some tokens from one account to the other (cancelling confirmation) - f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-n") - tests.WaitForNextNBlocksTM(1, f.Port) - - // ensure account balances match expected - barAcc = f.QueryAccount(barAddr) - require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom)) -} - -func TestKavaCLIGasAuto(t *testing.T) { +func TestKvCLIGasAuto(t *testing.T) { // https://github.com/cosmos/cosmos-sdk/pull/5179 t.Skip() t.Parallel() @@ -372,9 +345,8 @@ func TestKavaCLIGasAuto(t *testing.T) { success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=auto", "-y") require.NotEmpty(t, stderr) require.True(t, success) - cdc := app.MakeCodec() sendResp := sdk.TxResponse{} - err := cdc.UnmarshalJSON([]byte(stdout), &sendResp) + err := f.cdc.UnmarshalJSON([]byte(stdout), &sendResp) require.Nil(t, err) require.True(t, sendResp.GasWanted >= sendResp.GasUsed) tests.WaitForNextNBlocksTM(1, f.Port) @@ -386,7 +358,7 @@ func TestKavaCLIGasAuto(t *testing.T) { f.Cleanup() } -func TestKavaCLICreateValidator(t *testing.T) { +func TestKvCLICreateValidator(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -397,9 +369,7 @@ func TestKavaCLICreateValidator(t *testing.T) { barAddr := f.KeyAddress(keyBar) barVal := sdk.ValAddress(barAddr) - consPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeValPub, ed25519.GenPrivKey().PubKey()) - require.NoError(t, err) - require.NotEmpty(t, consPubKey) + consPubKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, ed25519.GenPrivKey().PubKey()) sendTokens := sdk.TokensFromConsensusPower(10) f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") @@ -410,9 +380,9 @@ func TestKavaCLICreateValidator(t *testing.T) { // Generate a create validator transaction and ensure correctness success, stdout, stderr := f.TxStakingCreateValidator(barAddr.String(), consPubKey, sdk.NewInt64Coin(denom, 2), "--generate-only") - require.True(f.T, success) require.Empty(f.T, stderr) + msg := f.unmarshalStdTx(f.T, stdout) require.NotZero(t, msg.Fee.Gas) require.Equal(t, len(msg.Msgs), 1) @@ -420,7 +390,7 @@ func TestKavaCLICreateValidator(t *testing.T) { // Test --dry-run newValTokens := sdk.TokensFromConsensusPower(2) - success, _, _ = f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewCoin(denom, newValTokens), "--dry-run") + success, _, _ = f.TxStakingCreateValidator(barAddr.String(), consPubKey, sdk.NewCoin(denom, newValTokens), "--dry-run") require.True(t, success) // Create the validator @@ -461,26 +431,25 @@ func TestKavaCLICreateValidator(t *testing.T) { f.Cleanup() } -func TestKavaCLIQueryRewards(t *testing.T) { +func TestKvCLIQueryRewards(t *testing.T) { t.Parallel() f := InitFixtures(t) - cdc := app.MakeCodec() genesisState := f.GenesisState() - inflationMin := sdk.MustNewDecFromStr("10000.0") + inflationMin := sdk.MustNewDecFromStr("1.0") var mintData mint.GenesisState - cdc.UnmarshalJSON(genesisState[mint.ModuleName], &mintData) + f.cdc.UnmarshalJSON(genesisState[mint.ModuleName], &mintData) mintData.Minter.Inflation = inflationMin mintData.Params.InflationMin = inflationMin - mintData.Params.InflationMax = sdk.MustNewDecFromStr("15000.0") - mintDataBz, err := cdc.MarshalJSON(mintData) + mintData.Params.InflationMax = sdk.MustNewDecFromStr("1.0") + mintDataBz, err := f.cdc.MarshalJSON(mintData) require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz genFile := filepath.Join(f.KvdHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) - genDoc.AppState, err = cdc.MarshalJSON(genesisState) + genDoc.AppState, err = f.cdc.MarshalJSON(genesisState) require.NoError(t, genDoc.SaveAs(genFile)) // start kvd server @@ -494,7 +463,7 @@ func TestKavaCLIQueryRewards(t *testing.T) { f.Cleanup() } -func TestKavaCLIQuerySupply(t *testing.T) { +func TestKvCLIQuerySupply(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -511,7 +480,7 @@ func TestKavaCLIQuerySupply(t *testing.T) { f.Cleanup() } -func TestKavaCLISubmitProposal(t *testing.T) { +func TestKvCLISubmitProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -551,8 +520,8 @@ func TestKavaCLISubmitProposal(t *testing.T) { f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "-y") tests.WaitForNextNBlocksTM(1, f.Port) - // Ensure transaction tags can be queried - searchResult := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr)) + // Ensure transaction events can be queried + searchResult := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, searchResult.Txs, 1) // Ensure deposit was deducted @@ -595,8 +564,8 @@ func TestKavaCLISubmitProposal(t *testing.T) { deposit = f.QueryGovDeposit(1, fooAddr) require.Equal(t, proposalTokens.Add(depositTokens), deposit.Amount.AmountOf(denom)) - // Ensure tags are set on the transaction - searchResult = f.QueryTxs(1, 50, "message.action:deposit", fmt.Sprintf("message.sender:%s", fooAddr)) + // Ensure events are set on the transaction + searchResult = f.QueryTxs(1, 50, "message.action=deposit", fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, searchResult.Txs, 1) // Ensure account has expected amount of funds @@ -632,8 +601,8 @@ func TestKavaCLISubmitProposal(t *testing.T) { require.Equal(t, uint64(1), votes[0].ProposalID) require.Equal(t, gov.OptionYes, votes[0].Option) - // Ensure tags are applied to voting transaction properly - searchResult = f.QueryTxs(1, 50, "message.action:vote", fmt.Sprintf("message.sender:%s", fooAddr)) + // Ensure events are applied to voting transaction properly + searchResult = f.QueryTxs(1, 50, "message.action=vote", fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, searchResult.Txs, 1) // Ensure no proposals in deposit period @@ -649,13 +618,14 @@ func TestKavaCLISubmitProposal(t *testing.T) { tests.WaitForNextNBlocksTM(1, f.Port) // Test limit on proposals query - proposalsQuery = f.QueryGovProposals("--limit=1") - require.Equal(t, uint64(2), proposalsQuery[0].ProposalID) + proposalsQuery = f.QueryGovProposals("--limit=2") + require.Len(t, proposalsQuery, 2) + require.Equal(t, uint64(1), proposalsQuery[0].ProposalID) f.Cleanup() } -func TestKavaCLISubmitParamChangeProposal(t *testing.T) { +func TestKvCLISubmitParamChangeProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -679,12 +649,7 @@ func TestKavaCLISubmitParamChangeProposal(t *testing.T) { "value": 105 } ], - "deposit": [ - { - "denom": "stake", - "amount": "%s" - } - ] + "deposit": "%sstake" } `, proposalTokens.String()) @@ -694,8 +659,8 @@ func TestKavaCLISubmitParamChangeProposal(t *testing.T) { f.TxGovSubmitParamChangeProposal(keyFoo, proposalFile.Name(), sdk.NewCoin(denom, proposalTokens), "-y") tests.WaitForNextNBlocksTM(1, f.Port) - // ensure transaction tags can be queried - txsPage := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr)) + // ensure transaction events can be queried + txsPage := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage.Txs, 1) // ensure deposit was deducted @@ -719,27 +684,26 @@ func TestKavaCLISubmitParamChangeProposal(t *testing.T) { f.Cleanup() } -func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) { +func TestKvCLISubmitCommunityPoolSpendProposal(t *testing.T) { t.Parallel() f := InitFixtures(t) // create some inflation - cdc := app.MakeCodec() genesisState := f.GenesisState() - inflationMin := sdk.MustNewDecFromStr("10000.0") + inflationMin := sdk.MustNewDecFromStr("1.0") var mintData mint.GenesisState - cdc.UnmarshalJSON(genesisState[mint.ModuleName], &mintData) + f.cdc.UnmarshalJSON(genesisState[mint.ModuleName], &mintData) mintData.Minter.Inflation = inflationMin mintData.Params.InflationMin = inflationMin - mintData.Params.InflationMax = sdk.MustNewDecFromStr("15000.0") - mintDataBz, err := cdc.MarshalJSON(mintData) + mintData.Params.InflationMax = sdk.MustNewDecFromStr("1.0") + mintDataBz, err := f.cdc.MarshalJSON(mintData) require.NoError(t, err) genesisState[mint.ModuleName] = mintDataBz genFile := filepath.Join(f.KvdHome, "config", "genesis.json") genDoc, err := tmtypes.GenesisDocFromFile(genFile) require.NoError(t, err) - genDoc.AppState, err = cdc.MarshalJSON(genesisState) + genDoc.AppState, err = f.cdc.MarshalJSON(genesisState) require.NoError(t, genDoc.SaveAs(genFile)) proc := f.GDStart() @@ -758,28 +722,18 @@ func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) { "title": "Community Pool Spend", "description": "Spend from community pool", "recipient": "%s", - "amount": [ - { - "denom": "%s", - "amount": "1" - } - ], - "deposit": [ - { - "denom": "%s", - "amount": "%s" - } - ] + "amount": "1%s", + "deposit": "%s%s" } -`, fooAddr, sdk.DefaultBondDenom, sdk.DefaultBondDenom, proposalTokens.String()) +`, fooAddr, sdk.DefaultBondDenom, proposalTokens.String(), sdk.DefaultBondDenom) proposalFile := WriteToNewTempFile(t, proposal) // create the param change proposal f.TxGovSubmitCommunityPoolSpendProposal(keyFoo, proposalFile.Name(), sdk.NewCoin(denom, proposalTokens), "-y") tests.WaitForNextNBlocksTM(1, f.Port) - // ensure transaction tags can be queried - txsPage := f.QueryTxs(1, 50, "message.action:submit_proposal", fmt.Sprintf("message.sender:%s", fooAddr)) + // ensure transaction events can be queried + txsPage := f.QueryTxs(1, 50, "message.action=submit_proposal", fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage.Txs, 1) // ensure deposit was deducted @@ -803,7 +757,11 @@ func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) { f.Cleanup() } -func TestKavaCLIQueryTxPagination(t *testing.T) { +func TestKvCLIQueryTxPagination(t *testing.T) { + // Skip until https://github.com/tendermint/tendermint/issues/4432 has been + // resolved and included in a release. + t.SkipNow() + t.Parallel() f := InitFixtures(t) @@ -824,36 +782,40 @@ func TestKavaCLIQueryTxPagination(t *testing.T) { } // perPage = 15, 2 pages - txsPage1 := f.QueryTxs(1, 15, fmt.Sprintf("message.sender:%s", fooAddr)) + txsPage1 := f.QueryTxs(1, 15, fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage1.Txs, 15) require.Equal(t, txsPage1.Count, 15) - txsPage2 := f.QueryTxs(2, 15, fmt.Sprintf("message.sender:%s", fooAddr)) + txsPage2 := f.QueryTxs(2, 15, fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage2.Txs, 15) require.NotEqual(t, txsPage1.Txs, txsPage2.Txs) // perPage = 16, 2 pages - txsPage1 = f.QueryTxs(1, 16, fmt.Sprintf("message.sender:%s", fooAddr)) + txsPage1 = f.QueryTxs(1, 16, fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage1.Txs, 16) - txsPage2 = f.QueryTxs(2, 16, fmt.Sprintf("message.sender:%s", fooAddr)) + txsPage2 = f.QueryTxs(2, 16, fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPage2.Txs, 14) require.NotEqual(t, txsPage1.Txs, txsPage2.Txs) // perPage = 50 - txsPageFull := f.QueryTxs(1, 50, fmt.Sprintf("message.sender:%s", fooAddr)) + txsPageFull := f.QueryTxs(1, 50, fmt.Sprintf("message.sender=%s", fooAddr)) require.Len(t, txsPageFull.Txs, 30) - require.Equal(t, txsPageFull.Txs, append(txsPage1.Txs, txsPage2.Txs...)) + + expected := txsPageFull.Txs + got := append(txsPage1.Txs, txsPage2.Txs...) + + require.Equal(t, expected, got) // perPage = 0 - f.QueryTxsInvalid(errors.New("ERROR: page must greater than 0"), 0, 50, fmt.Sprintf("message.sender:%s", fooAddr)) + f.QueryTxsInvalid(errors.New("ERROR: page must greater than 0"), 0, 50, fmt.Sprintf("message.sender=%s", fooAddr)) // limit = 0 - f.QueryTxsInvalid(errors.New("ERROR: limit must greater than 0"), 1, 0, fmt.Sprintf("message.sender:%s", fooAddr)) + f.QueryTxsInvalid(errors.New("ERROR: limit must greater than 0"), 1, 0, fmt.Sprintf("message.sender=%s", fooAddr)) // Cleanup testing directories f.Cleanup() } -func TestKavaCLIValidateSignatures(t *testing.T) { +func TestKvCLIValidateSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -874,9 +836,8 @@ func TestKavaCLIValidateSignatures(t *testing.T) { defer os.Remove(unsignedTxFile.Name()) // validate we can successfully sign - success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name()) + success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name()) require.True(t, success) - require.Empty(t, stderr) stdTx := f.unmarshalStdTx(t, stdout) require.Equal(t, len(stdTx.Msgs), 1) require.Equal(t, 1, len(stdTx.GetSignatures())) @@ -903,7 +864,7 @@ func TestKavaCLIValidateSignatures(t *testing.T) { f.Cleanup() } -func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { +func TestKvCLISendGenerateSignAndBroadcast(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -951,6 +912,17 @@ func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", fooAddr.String()), stdout) // Test sign + + // Does not work in offline mode + success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name(), "--offline") + require.Contains(t, stderr, "required flag(s) \"account-number\", \"sequence\" not set") + require.False(t, success) + + // But works offline if we set account number and sequence + success, _, _ = f.TxSign(keyFoo, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1") + require.True(t, success) + + // Sign transaction success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name()) require.True(t, success) msg = f.unmarshalStdTx(t, stdout) @@ -974,6 +946,13 @@ func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) // Test broadcast + + // Does not work in offline mode + success, _, stderr = f.TxBroadcast(signedTxFile.Name(), "--offline") + require.Contains(t, stderr, "cannot broadcast tx during offline mode") + require.False(t, success) + tests.WaitForNextNBlocksTM(1, f.Port) + success, stdout, _ = f.TxBroadcast(signedTxFile.Name()) require.True(t, success) tests.WaitForNextNBlocksTM(1, f.Port) @@ -987,7 +966,7 @@ func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) { f.Cleanup() } -func TestKavaCLIMultisignInsufficientCosigners(t *testing.T) { +func TestKvCLIMultisignInsufficientCosigners(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -1040,7 +1019,7 @@ func TestKavaCLIMultisignInsufficientCosigners(t *testing.T) { f.Cleanup() } -func TestKavaCLIEncode(t *testing.T) { +func TestKvCLIEncode(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -1048,8 +1027,6 @@ func TestKavaCLIEncode(t *testing.T) { proc := f.GDStart() defer proc.Stop(false) - cdc := app.MakeCodec() - // Build a testing transaction and write it to disk barAddr := f.KeyAddress(keyBar) keyAddr := f.KeyAddress(keyFoo) @@ -1074,11 +1051,11 @@ func TestKavaCLIEncode(t *testing.T) { // Check that the transaction decodes as epxceted var decodedTx auth.StdTx - require.Nil(t, cdc.UnmarshalBinaryLengthPrefixed(decodedBytes, &decodedTx)) + require.Nil(t, f.cdc.UnmarshalBinaryBare(decodedBytes, &decodedTx)) require.Equal(t, "deadbeef", decodedTx.Memo) } -func TestKavaCLIMultisignSortSignatures(t *testing.T) { +func TestKvCLIMultisignSortSignatures(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -1143,7 +1120,7 @@ func TestKavaCLIMultisignSortSignatures(t *testing.T) { f.Cleanup() } -func TestKavaCLIMultisign(t *testing.T) { +func TestKvCLIMultisign(t *testing.T) { t.Parallel() f := InitFixtures(t) @@ -1189,6 +1166,14 @@ func TestKavaCLIMultisign(t *testing.T) { defer os.Remove(barSignatureFile.Name()) // Multisign + + // Does not work in offline mode + success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{ + fooSignatureFile.Name(), barSignatureFile.Name()}, "--offline") + require.Contains(t, "couldn't verify signature", stdout) + require.False(t, success) + + // Success multisign success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{ fooSignatureFile.Name(), barSignatureFile.Name()}) require.True(t, success) @@ -1209,7 +1194,7 @@ func TestKavaCLIMultisign(t *testing.T) { f.Cleanup() } -func TestKavaCLIConfig(t *testing.T) { +func TestKvCLIConfig(t *testing.T) { t.Parallel() f := InitFixtures(t) node := fmt.Sprintf("%s:%s", f.RPCAddr, f.Port) @@ -1222,12 +1207,14 @@ func TestKavaCLIConfig(t *testing.T) { f.CLIConfig("chain-id", f.ChainID) f.CLIConfig("trace", "false") f.CLIConfig("indent", "true") + f.CLIConfig("keyring-backend", "test") config, err := ioutil.ReadFile(path.Join(f.KvcliHome, "config", "config.toml")) require.NoError(t, err) expectedConfig := fmt.Sprintf(`broadcast-mode = "block" chain-id = "%s" indent = true +keyring-backend = "test" node = "%s" output = "text" trace = false @@ -1238,7 +1225,7 @@ trust-node = true f.Cleanup() } -func TestKavadCollectGentxs(t *testing.T) { +func TestKvdCollectGentxs(t *testing.T) { t.Parallel() var customMaxBytes, customMaxGas int64 = 99999999, 1234567 f := NewFixtures(t) @@ -1258,7 +1245,7 @@ func TestKavadCollectGentxs(t *testing.T) { f.CLIConfig("output", "json") // Run init - f.GDInit(keyFoo) + f.KvInit(keyFoo) // Customise genesis.json @@ -1286,7 +1273,7 @@ func TestKavadCollectGentxs(t *testing.T) { f.Cleanup(gentxDir) } -func TestKavadAddGenesisAccount(t *testing.T) { +func TestKvdAddGenesisAccount(t *testing.T) { t.Parallel() f := NewFixtures(t) @@ -1305,7 +1292,7 @@ func TestKavadAddGenesisAccount(t *testing.T) { f.CLIConfig("output", "json") // Run init - f.GDInit(keyFoo) + f.KvInit(keyFoo) // Add account to genesis.json bazCoins := sdk.Coins{ @@ -1317,9 +1304,7 @@ func TestKavadAddGenesisAccount(t *testing.T) { f.AddGenesisAccount(f.KeyAddress(keyBar), bazCoins) genesisState := f.GenesisState() - cdc := app.MakeCodec() - - authGenState := auth.GetGenesisStateFromAppState(cdc, genesisState) + authGenState := auth.GetGenesisStateFromAppState(f.cdc, genesisState) accounts := authGenState.Accounts require.Equal(t, accounts[0].GetAddress(), f.KeyAddress(keyFoo)) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index f4d3f312..aa0f1756 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -162,8 +162,8 @@ func InitFixtures(t *testing.T) (f *Fixtures) { // ensure that CLI output is in JSON format f.CLIConfig("output", "json") - // NOTE: GDInit sets the ChainID - f.GDInit(keyFoo) + // NOTE: KvInit sets the ChainID + f.KvInit(keyFoo) f.CLIConfig("chain-id", f.ChainID) f.CLIConfig("broadcast-mode", "block") @@ -208,9 +208,9 @@ func (f *Fixtures) UnsafeResetAll(flags ...string) { require.NoError(f.T, err) } -// GDInit is kavad init -// NOTE: GDInit sets the ChainID for the Fixtures instance -func (f *Fixtures) GDInit(moniker string, flags ...string) { +// KvInit is kavad init +// NOTE: KvInit sets the ChainID for the Fixtures instance +func (f *Fixtures) KvInit(moniker string, flags ...string) { cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KvdBinary, f.KvdHome, moniker) _, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass) From 5ccd4e219f97dcde25ade310167a16e404fd7613 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 28 Apr 2020 14:04:30 -0400 Subject: [PATCH 5/7] fix some tests --- Makefile | 2 +- cli_test/cli_test.go | 29 ++--------------------------- cli_test/test_helpers.go | 2 ++ cmd/kvd/add_account.go | 2 ++ 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 7becb364..72de40af 100644 --- a/Makefile +++ b/Makefile @@ -135,7 +135,7 @@ test: test-rest: rest_test/./run_all_tests_from_make.sh -test-cli: +test-cli: build @go test ./cli_test -tags cli_test -v -p 4 # Kick start lots of sims on an AWS cluster. diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 5f8d5d72..2f843ee3 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -239,13 +239,6 @@ func TestKvCLISend(t *testing.T) { sendTokens := sdk.TokensFromConsensusPower(10) - // It does not allow to send in offline mode - success, _, stdErr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y", "--offline") - require.Contains(t, stdErr, "no RPC client is defined in offline mode") - require.False(f.T, success) - tests.WaitForNextNBlocksTM(1, f.Port) - - // Send some tokens from one account to the other f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y") tests.WaitForNextNBlocksTM(1, f.Port) @@ -256,7 +249,7 @@ func TestKvCLISend(t *testing.T) { require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom)) // Test --dry-run - success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run") + success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run") require.True(t, success) // Test --generate-only @@ -912,17 +905,6 @@ func TestKvCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", fooAddr.String()), stdout) // Test sign - - // Does not work in offline mode - success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name(), "--offline") - require.Contains(t, stderr, "required flag(s) \"account-number\", \"sequence\" not set") - require.False(t, success) - - // But works offline if we set account number and sequence - success, _, _ = f.TxSign(keyFoo, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1") - require.True(t, success) - - // Sign transaction success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name()) require.True(t, success) msg = f.unmarshalStdTx(t, stdout) @@ -946,13 +928,6 @@ func TestKvCLISendGenerateSignAndBroadcast(t *testing.T) { require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom)) // Test broadcast - - // Does not work in offline mode - success, _, stderr = f.TxBroadcast(signedTxFile.Name(), "--offline") - require.Contains(t, stderr, "cannot broadcast tx during offline mode") - require.False(t, success) - tests.WaitForNextNBlocksTM(1, f.Port) - success, stdout, _ = f.TxBroadcast(signedTxFile.Name()) require.True(t, success) tests.WaitForNextNBlocksTM(1, f.Port) @@ -1051,7 +1026,7 @@ func TestKvCLIEncode(t *testing.T) { // Check that the transaction decodes as epxceted var decodedTx auth.StdTx - require.Nil(t, f.cdc.UnmarshalBinaryBare(decodedBytes, &decodedTx)) + require.Nil(t, f.cdc.UnmarshalBinaryLengthPrefixed(decodedBytes, &decodedTx)) require.Equal(t, "deadbeef", decodedTx.Memo) } diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index aa0f1756..f7c1b43f 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -147,6 +147,8 @@ func InitFixtures(t *testing.T) (f *Fixtures) { // reset test state f.UnsafeResetAll() + f.CLIConfig("keyring-backend", "test") + // ensure keystore has foo and bar keys f.KeysDelete(keyFoo) f.KeysDelete(keyBar) diff --git a/cmd/kvd/add_account.go b/cmd/kvd/add_account.go index 95ae9b0e..36644d58 100644 --- a/cmd/kvd/add_account.go +++ b/cmd/kvd/add_account.go @@ -12,6 +12,7 @@ import ( validatorvesting "github.com/kava-labs/kava/x/validator-vesting" "github.com/tendermint/tendermint/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" @@ -169,6 +170,7 @@ func AddGenesisAccountCmd( } cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory") + cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") cmd.Flags().String(flagClientHome, defaultClientHome, "client's home directory") cmd.Flags().String(flagVestingAmt, "", "amount of coins for vesting accounts") cmd.Flags().Uint64(flagVestingStart, 0, "schedule start time (unix epoch) for vesting accounts") From aa9e943609552547c5b3ed20b338f3c37e1c932a Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 30 Apr 2020 09:13:23 -0400 Subject: [PATCH 6/7] fix CLI tests --- cli_test/cli_test.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index 2f843ee3..40e9acc2 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -642,9 +642,14 @@ func TestKvCLISubmitParamChangeProposal(t *testing.T) { "value": 105 } ], - "deposit": "%sstake" + "deposit": [ + { + "denom": "%s", + "amount": "%s" + } + ] } -`, proposalTokens.String()) +`, sdk.DefaultBondDenom, proposalTokens.String()) proposalFile := WriteToNewTempFile(t, proposal) @@ -715,10 +720,20 @@ func TestKvCLISubmitCommunityPoolSpendProposal(t *testing.T) { "title": "Community Pool Spend", "description": "Spend from community pool", "recipient": "%s", - "amount": "1%s", - "deposit": "%s%s" + "amount": [ + { + "denom": "%s", + "amount": "1" + } + ], + "deposit": [ + { + "denom": "%s", + "amount": "%s" + } + ] } -`, fooAddr, sdk.DefaultBondDenom, proposalTokens.String(), sdk.DefaultBondDenom) +`, fooAddr, sdk.DefaultBondDenom, sdk.DefaultBondDenom, proposalTokens.String()) proposalFile := WriteToNewTempFile(t, proposal) // create the param change proposal From 462dad4e937438df515b16a985a5f19807e18770 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Thu, 30 Apr 2020 13:16:30 -0400 Subject: [PATCH 7/7] address comments from review --- Makefile | 3 +++ cli_test/README.md | 14 -------------- 2 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 cli_test/README.md diff --git a/Makefile b/Makefile index 72de40af..b8c50802 100644 --- a/Makefile +++ b/Makefile @@ -135,6 +135,9 @@ test: test-rest: rest_test/./run_all_tests_from_make.sh +# Run cli integration tests +# `-p 4` to use 4 cores, `-tags cli_test` to tell go not to ignore the cli package +# These tests use the `kvd` or `kvcli` binaries in the build dir, or in `$BUILDDIR` if that env var is set. test-cli: build @go test ./cli_test -tags cli_test -v -p 4 diff --git a/cli_test/README.md b/cli_test/README.md deleted file mode 100644 index a9152712..00000000 --- a/cli_test/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# CLI Integration tests - -Run the full suite: - -```bash -make build -go test -v -p 4 ./cli_test -tags cli_test -``` - -`-v` for verbose, `-p 4` to use 4 cores, `-tags cli_test` a build tag (specified in `cli_test.go`) to tell go not to ignore the package - -> NOTE: While the full suite runs in parallel, some of the tests can take up to a minute to complete - -> NOTE: The tests will use the `kvd` or `kvcli` binaries in the build dir. Or in `$BUILDDIR` if that env var is set.