CLI/Tests: Remove Fixtures (#6799)
* remove fixtures * setup tests * update x/mint * cli: update x/staking commands * tests: convert x/staking CLI tests * tests: fix x/auth CLI tests * cli updates * fix buiild * fix build * Update x/gov/client/cli/cli_test.go Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * remove GenerateOrBroadcastTx * move TestCLIQueryConn Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
This commit is contained in:
co-authored by
Amaury Martiny
Federico Kunze
parent
6e7ce48b31
commit
0ccc48d2a3
+19
-6
@@ -2,20 +2,20 @@ package client_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -100,3 +100,16 @@ value:
|
||||
x: "10"
|
||||
`, string(buf.Bytes()))
|
||||
}
|
||||
|
||||
func TestCLIQueryConn(t *testing.T) {
|
||||
cfg := network.DefaultConfig()
|
||||
cfg.NumValidators = 1
|
||||
|
||||
n := network.New(t, cfg)
|
||||
defer n.Cleanup()
|
||||
|
||||
testClient := testdata.NewTestServiceClient(n.Validators[0].ClientCtx)
|
||||
res, err := testClient.Echo(context.Background(), &testdata.EchoRequest{Message: "hello"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "hello", res.Message)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package tx
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@@ -78,47 +75,6 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
|
||||
return f
|
||||
}
|
||||
|
||||
// TODO: Remove in favor of NewFactoryCLI
|
||||
func NewFactoryFromDeprecated(input io.Reader) Factory {
|
||||
kb, err := keyring.New(
|
||||
sdk.KeyringServiceName(),
|
||||
viper.GetString(flags.FlagKeyringBackend),
|
||||
viper.GetString(flags.FlagHome),
|
||||
input,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
signModeStr := viper.GetString(flags.FlagSignMode)
|
||||
signMode := signing.SignMode_SIGN_MODE_UNSPECIFIED
|
||||
switch signModeStr {
|
||||
case signModeDirect:
|
||||
signMode = signing.SignMode_SIGN_MODE_DIRECT
|
||||
case signModeAminoJSON:
|
||||
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
|
||||
}
|
||||
|
||||
gasSetting, _ := flags.ParseGasSetting(viper.GetString(flags.FlagGas))
|
||||
|
||||
f := Factory{
|
||||
keybase: kb,
|
||||
chainID: viper.GetString(flags.FlagChainID),
|
||||
accountNumber: viper.GetUint64(flags.FlagAccountNumber),
|
||||
sequence: viper.GetUint64(flags.FlagSequence),
|
||||
gas: gasSetting.Gas,
|
||||
simulateAndExecute: gasSetting.Simulate,
|
||||
gasAdjustment: viper.GetFloat64(flags.FlagGasAdjustment),
|
||||
memo: viper.GetString(flags.FlagMemo),
|
||||
signMode: signMode,
|
||||
}
|
||||
|
||||
f = f.WithFees(viper.GetString(flags.FlagFees))
|
||||
f = f.WithGasPrices(viper.GetString(flags.FlagGasPrices))
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func (f Factory) AccountNumber() uint64 { return f.accountNumber }
|
||||
func (f Factory) Sequence() uint64 { return f.sequence }
|
||||
func (f Factory) Gas() uint64 { return f.gas }
|
||||
|
||||
@@ -29,15 +29,6 @@ func GenerateOrBroadcastTxCLI(clientCtx client.Context, flagSet *pflag.FlagSet,
|
||||
return GenerateOrBroadcastTxWithFactory(clientCtx, txf, msgs...)
|
||||
}
|
||||
|
||||
// GenerateOrBroadcastTx will either generate and print and unsigned transaction
|
||||
// or sign it and broadcast it returning an error upon failure.
|
||||
//
|
||||
// TODO: Remove in favor of GenerateOrBroadcastTxCLI
|
||||
func GenerateOrBroadcastTx(clientCtx client.Context, msgs ...sdk.Msg) error {
|
||||
txf := NewFactoryFromDeprecated(clientCtx.Input).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)
|
||||
return GenerateOrBroadcastTxWithFactory(clientCtx, txf, msgs...)
|
||||
}
|
||||
|
||||
// GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction
|
||||
// or sign it and broadcast it returning an error upon failure.
|
||||
func GenerateOrBroadcastTxWithFactory(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
|
||||
|
||||
Reference in New Issue
Block a user