-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools/confix): upgrade confix to migrate client.toml files (#18455)
- Loading branch information
Showing
9 changed files
with
153 additions
and
55 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
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 |
---|---|---|
@@ -1,38 +1,40 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"gotest.tools/v3/assert" | ||
|
||
"cosmossdk.io/tools/confix/cmd" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" | ||
) | ||
|
||
func TestMigradeCmd(t *testing.T) { | ||
func TestMigrateCmd(t *testing.T) { | ||
clientCtx, cleanup := initClientContext(t) | ||
defer cleanup() | ||
|
||
_, err := clitestutil.ExecTestCLICmd(client.Context{}, cmd.MigrateCommand(), []string{"v0.0"}) | ||
assert.ErrorContains(t, err, "must provide a path to the app.toml file") | ||
|
||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.0"}) | ||
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.0","app"}) | ||
assert.ErrorContains(t, err, "unknown version") | ||
|
||
// clientCtx does not create app.toml, so this should fail | ||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.45"}) | ||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.45","app"}) | ||
assert.ErrorContains(t, err, "no such file or directory") | ||
|
||
// try to migrate from client.toml it should fail without --skip-validate | ||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", fmt.Sprintf("%s/config/client.toml", clientCtx.HomeDir)}) | ||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", filepath.Join(clientCtx.HomeDir, "config", "client.toml"), "app"}) | ||
assert.ErrorContains(t, err, "failed to migrate config") | ||
|
||
// try to migrate from client.toml - it should work and give us a big diff | ||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", fmt.Sprintf("%s/config/client.toml", clientCtx.HomeDir), "--skip-validate", "--verbose"}) | ||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.46", filepath.Join(clientCtx.HomeDir, "config", "client.toml"), "--skip-validate", "--verbose"}) | ||
assert.NilError(t, err) | ||
assert.Assert(t, strings.Contains(out.String(), "add app-db-backend key")) | ||
|
||
|
||
// this should work | ||
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd.MigrateCommand(), []string{"v0.51", filepath.Join(clientCtx.HomeDir, "config", "client.toml"),"client", "--verbose"}) | ||
assert.NilError(t, err) | ||
assert.Assert(t, strings.Contains(out.String(), "add keyring-default-keyname key")) | ||
} |
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,17 @@ | ||
# This is a TOML config file. | ||
# For more information, see https://github.com/toml-lang/toml | ||
|
||
############################################################################### | ||
### Client Configuration ### | ||
############################################################################### | ||
|
||
# The network chain ID | ||
chain-id = "demo" | ||
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) | ||
keyring-backend = "os" | ||
# CLI output format (text|json) | ||
output = "text" | ||
# <host>:<port> to Tendermint RPC interface for this chain | ||
node = "tcp://localhost:26657" | ||
# Transaction broadcasting mode (sync|async|block) | ||
broadcast-mode = "sync" |
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,17 @@ | ||
# This is a TOML config file. | ||
# For more information, see https://github.com/toml-lang/toml | ||
|
||
############################################################################### | ||
### Client Configuration ### | ||
############################################################################### | ||
|
||
# The network chain ID | ||
chain-id = "demo" | ||
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) | ||
keyring-backend = "os" | ||
# CLI output format (text|json) | ||
output = "text" | ||
# <host>:<port> to Tendermint RPC interface for this chain | ||
node = "tcp://localhost:26657" | ||
# Transaction broadcasting mode (sync|async|block) | ||
broadcast-mode = "sync" |
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,19 @@ | ||
# This is a TOML config file. | ||
# For more information, see https://github.com/toml-lang/toml | ||
|
||
############################################################################### | ||
### Client Configuration ### | ||
############################################################################### | ||
|
||
# The network chain ID | ||
chain-id = "demo" | ||
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) | ||
keyring-backend = "test" | ||
# Default key name, if set, defines the default key to use for signing transaction when the --from flag is not specified | ||
keyring-default-keyname = "" | ||
# CLI output format (text|json) | ||
output = "text" | ||
# <host>:<port> to CometBFT RPC interface for this chain | ||
node = "tcp://localhost:26657" | ||
# Transaction broadcasting mode (sync|async) | ||
broadcast-mode = "sync" |
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