fix: Don't error on startup if min-gas-price is empty (#9621)
* fix: Don't error on startup if min-gas-price is empty * remove test * Update server/start.go * Update server/start.go Co-authored-by: Aaron Craelius <aaron@regen.network> * Switch to error Co-authored-by: Aaron Craelius <aaron@regen.network>
This commit is contained in:
parent
c0e0383b35
commit
3a28c343dd
|
@ -132,7 +132,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||
* [\#8628](https://github.com/cosmos/cosmos-sdk/issues/8628) Commands no longer print outputs using `stderr` by default
|
||||
* [\#9134](https://github.com/cosmos/cosmos-sdk/pull/9134) Renamed the CLI flag `--memo` to `--note`.
|
||||
* [\#9291](https://github.com/cosmos/cosmos-sdk/pull/9291) Migration scripts prior to v0.38 have been removed from the CLI `migrate` command. The oldest supported migration is v0.39->v0.42.
|
||||
* [\#9371](https://github.com/cosmos/cosmos-sdk/pull/9371) Non-zero default fees/Server will error if there's an empty value for min-gas-price in app.toml
|
||||
|
||||
|
||||
### Improvements
|
||||
|
|
|
@ -247,7 +247,9 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
|
|||
|
||||
config := config.GetConfig(ctx.Viper)
|
||||
if err := config.ValidateBasic(); err != nil {
|
||||
return err
|
||||
ctx.Logger.Error("WARNING: The minimum-gas-prices config in app.toml is set to the empty string. " +
|
||||
"This defaults to 0 in the current version, but will error in the next version " +
|
||||
"(SDK v0.44). Please explicitly put the desired minimum-gas-prices in your app.toml.")
|
||||
}
|
||||
|
||||
app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
|
||||
|
|
|
@ -11,15 +11,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/server/config"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var cancelledInPreRun = errors.New("Cancelled in prerun")
|
||||
|
@ -406,34 +400,3 @@ func TestInterceptConfigsWithBadPermissions(t *testing.T) {
|
|||
t.Fatalf("Failed to catch permissions error, got: [%T] %v", err, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyMinGasPrices(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
err := os.Mkdir(filepath.Join(tempDir, "config"), os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
encCfg := simapp.MakeTestEncodingConfig()
|
||||
|
||||
// Run InitCmd to create necessary config files.
|
||||
clientCtx := client.Context{}.WithHomeDir(tempDir).WithJSONCodec(encCfg.Marshaler)
|
||||
serverCtx := server.NewDefaultContext()
|
||||
ctx := context.WithValue(context.Background(), server.ServerContextKey, serverCtx)
|
||||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
||||
cmd := genutilcli.InitCmd(simapp.ModuleBasics, tempDir)
|
||||
cmd.SetArgs([]string{"appnode-test"})
|
||||
err = cmd.ExecuteContext(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Modify app.toml.
|
||||
appCfgTempFilePath := filepath.Join(tempDir, "config", "app.toml")
|
||||
appConf := config.DefaultConfig()
|
||||
appConf.BaseConfig.MinGasPrices = ""
|
||||
config.WriteConfigFile(appCfgTempFilePath, appConf)
|
||||
|
||||
// Run StartCmd.
|
||||
cmd = server.StartCmd(nil, tempDir)
|
||||
cmd.PreRunE = func(cmd *cobra.Command, _ []string) error {
|
||||
return server.InterceptConfigsPreRunHandler(cmd, "", nil)
|
||||
}
|
||||
err = cmd.ExecuteContext(ctx)
|
||||
require.Errorf(t, err, sdkerrors.ErrAppConfig.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue