From 5ccd4e219f97dcde25ade310167a16e404fd7613 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 28 Apr 2020 14:04:30 -0400 Subject: [PATCH] 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")