fix(simapp): home flag is not respected (#18994)
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
b2c26cdc4c
commit
3e05255956
+2
-1
@@ -91,7 +91,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
* (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test.
|
||||
* (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT
|
||||
* (abci): [#19200](https://github.com/cosmos/cosmos-sdk/pull/19200) Ensure that sdk side ve math matches cometbft
|
||||
|
||||
* (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `x/genutil` now handles the application export. `server.AddCommands` does not take an `AppExporter` but instead `genutilcli.Commands` does.
|
||||
|
||||
+9
-1
@@ -359,6 +359,14 @@ func GetClientContextFromCmd(cmd *cobra.Command) Context {
|
||||
// SetCmdClientContext sets a command's Context value to the provided argument.
|
||||
// If the context has not been set, set the given context as the default.
|
||||
func SetCmdClientContext(cmd *cobra.Command, clientCtx Context) error {
|
||||
cmd.SetContext(context.WithValue(cmd.Context(), ClientContextKey, &clientCtx))
|
||||
var cmdCtx context.Context
|
||||
|
||||
if cmd.Context() == nil {
|
||||
cmdCtx = context.Background()
|
||||
} else {
|
||||
cmdCtx = cmd.Context()
|
||||
}
|
||||
|
||||
cmd.SetContext(context.WithValue(cmdCtx, ClientContextKey, &clientCtx))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)}
|
||||
|
||||
@@ -15,4 +15,4 @@ $SIMD_BIN init test --chain-id demo
|
||||
$SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test
|
||||
$SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test
|
||||
$SIMD_BIN genesis gentx alice 1000000stake --chain-id demo
|
||||
$SIMD_BIN genesis collect-gentxs
|
||||
$SIMD_BIN genesis collect-gentxs
|
||||
|
||||
+7
-5
@@ -215,13 +215,15 @@ func GetServerContextFromCmd(cmd *cobra.Command) *Context {
|
||||
// SetCmdServerContext sets a command's Context value to the provided argument.
|
||||
// If the context has not been set, set the given context as the default.
|
||||
func SetCmdServerContext(cmd *cobra.Command, serverCtx *Context) error {
|
||||
v := cmd.Context().Value(ServerContextKey)
|
||||
if v == nil {
|
||||
v = serverCtx
|
||||
var cmdCtx context.Context
|
||||
|
||||
if cmd.Context() == nil {
|
||||
cmdCtx = context.Background()
|
||||
} else {
|
||||
cmdCtx = cmd.Context()
|
||||
}
|
||||
|
||||
serverCtxPtr := v.(*Context)
|
||||
*serverCtxPtr = *serverCtx
|
||||
cmd.SetContext(context.WithValue(cmdCtx, ServerContextKey, serverCtx))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(cmd)
|
||||
|
||||
// Test that config.toml is created
|
||||
configTomlPath := path.Join(tempDir, "config", "config.toml")
|
||||
s, err := os.Stat(configTomlPath)
|
||||
@@ -142,6 +144,8 @@ func TestInterceptConfigsPreRunHandlerReadsConfigToml(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(cmd)
|
||||
|
||||
if testDbBackend != serverCtx.Config.DBBackend {
|
||||
t.Error("backend was not set from config.toml")
|
||||
}
|
||||
@@ -180,6 +184,8 @@ func TestInterceptConfigsPreRunHandlerReadsAppToml(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(cmd)
|
||||
|
||||
if testHaltTime != serverCtx.Viper.GetInt("halt-time") {
|
||||
t.Error("Halt time was not set from app.toml")
|
||||
}
|
||||
@@ -208,6 +214,8 @@ func TestInterceptConfigsPreRunHandlerReadsFlags(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(cmd)
|
||||
|
||||
if testAddr != serverCtx.Config.RPC.ListenAddress {
|
||||
t.Error("RPCListenAddress was not set from command flags")
|
||||
}
|
||||
@@ -244,6 +252,8 @@ func TestInterceptConfigsPreRunHandlerReadsEnvVars(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(cmd)
|
||||
|
||||
if testAddr != serverCtx.Config.RPC.ListenAddress {
|
||||
t.Errorf("RPCListenAddress was not set from env. var. %q", envVarName)
|
||||
}
|
||||
@@ -351,6 +361,8 @@ func TestInterceptConfigsPreRunHandlerPrecedenceFlag(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(testCommon.cmd)
|
||||
|
||||
if TestAddrExpected != serverCtx.Config.RPC.ListenAddress {
|
||||
t.Fatalf("RPCListenAddress was not set from flag %q", testCommon.flagName)
|
||||
}
|
||||
@@ -367,6 +379,8 @@ func TestInterceptConfigsPreRunHandlerPrecedenceEnvVar(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(testCommon.cmd)
|
||||
|
||||
if TestAddrExpected != serverCtx.Config.RPC.ListenAddress {
|
||||
t.Errorf("RPCListenAddress was not set from env. var. %q", testCommon.envVarName)
|
||||
}
|
||||
@@ -383,6 +397,8 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigFile(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(testCommon.cmd)
|
||||
|
||||
if TestAddrExpected != serverCtx.Config.RPC.ListenAddress {
|
||||
t.Errorf("RPCListenAddress was not read from file %q", testCommon.configTomlPath)
|
||||
}
|
||||
@@ -399,6 +415,8 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigDefault(t *testing.T) {
|
||||
t.Fatalf("function failed with [%T] %v", err, err)
|
||||
}
|
||||
|
||||
serverCtx = server.GetServerContextFromCmd(testCommon.cmd)
|
||||
|
||||
if serverCtx.Config.RPC.ListenAddress != "tcp://127.0.0.1:26657" {
|
||||
t.Error("RPCListenAddress is not using default")
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func NewRootCmd() *cobra.Command {
|
||||
cmd.SetOut(cmd.OutOrStdout())
|
||||
cmd.SetErr(cmd.ErrOrStderr())
|
||||
|
||||
clientCtx = clientCtx.WithCmdContext(cmd.Context())
|
||||
clientCtx = clientCtx.WithCmdContext(cmd.Context()).WithViper("")
|
||||
clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user