-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEC-2201] Ensure that we use the client context with AutoCLI (#966)
* [DEC-2201] Ensure that we use the client context with AutoCLI Note that the basis of this code is from https://github.com/dydxprotocol/cosmos-sdk/blob/b48250d4e0efacbd40f3e0b980c1e1004d29e351/simapp/simd/cmd/root.go#L103 which is linked from the Cosmos 0.50 upgrade guide.
- Loading branch information
Showing
5 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package cmd_test | ||
|
||
import ( | ||
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" | ||
"github.com/dydxprotocol/v4-chain/protocol/app" | ||
"github.com/dydxprotocol/v4-chain/protocol/app/config" | ||
"github.com/dydxprotocol/v4-chain/protocol/cmd/dydxprotocold/cmd" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestNewRootCmd_UsesClientConfig(t *testing.T) { | ||
tempDir := t.TempDir() | ||
|
||
config.SetupConfig() | ||
|
||
// Set the client config to point to a fake chain id since this is a required option | ||
{ | ||
option := cmd.GetOptionWithCustomStartCmd() | ||
rootCmd := cmd.NewRootCmd(option, tempDir) | ||
|
||
cmd.AddTendermintSubcommands(rootCmd) | ||
cmd.AddInitCmdPostRunE(rootCmd) | ||
rootCmd.SetArgs([]string{"config", "set", "client", "chain-id", "fakeChainId"}) | ||
require.NoError(t, svrcmd.Execute(rootCmd, app.AppDaemonName, tempDir)) | ||
} | ||
|
||
// Set the client config to point to a fake address | ||
{ | ||
option := cmd.GetOptionWithCustomStartCmd() | ||
rootCmd := cmd.NewRootCmd(option, tempDir) | ||
|
||
cmd.AddTendermintSubcommands(rootCmd) | ||
cmd.AddInitCmdPostRunE(rootCmd) | ||
rootCmd.SetArgs([]string{"config", "set", "client", "node", "fakeTestAddress"}) | ||
require.NoError(t, svrcmd.Execute(rootCmd, app.AppDaemonName, tempDir)) | ||
} | ||
|
||
// Run a query command (that will fail) to ensure that we are reading the client config | ||
option := cmd.GetOptionWithCustomStartCmd() | ||
rootCmd := cmd.NewRootCmd(option, tempDir) | ||
|
||
cmd.AddTendermintSubcommands(rootCmd) | ||
cmd.AddInitCmdPostRunE(rootCmd) | ||
rootCmd.SetArgs([]string{"query", "auth", "params"}) | ||
require.ErrorContains(t, svrcmd.Execute(rootCmd, app.AppDaemonName, tempDir), "fakeTestAddress") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters