fix: use correct config key for db_backend (backport #17406) (#17410)

This commit is contained in:
mergify[bot]
2023-08-16 18:46:06 +00:00
committed by GitHub
parent 6a5adc4a81
commit 57a22c1ddd
6 changed files with 20 additions and 13 deletions
+1 -2
View File
@@ -83,8 +83,7 @@ iavl-disable-fastnode = {{ .BaseConfig.IAVLDisableFastNode }}
# AppDBBackend defines the database backend type to use for the application and snapshots DBs.
# An empty string indicates that a fallback will be used.
# First fallback is the deprecated compile-time types.DBBackend value.
# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in CometBFT's config.toml.
# The fallback is the db_backend value set in CometBFT's config.toml.
app-db-backend = "{{ .BaseConfig.AppDBBackend }}"
###############################################################################
+1 -1
View File
@@ -403,7 +403,7 @@ func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.Cancel
func GetAppDBBackend(opts types.AppOptions) dbm.BackendType {
rv := cast.ToString(opts.Get("app-db-backend"))
if len(rv) == 0 {
rv = cast.ToString(opts.Get("db-backend"))
rv = cast.ToString(opts.Get("db_backend"))
}
// Cosmos SDK has migrated to cosmos-db which does not support all the backends which tm-db supported
+11
View File
@@ -11,7 +11,9 @@ import (
"testing"
cmtcfg "github.com/cometbft/cometbft/config"
db "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client"
@@ -37,6 +39,15 @@ func preRunETestImpl(cmd *cobra.Command, args []string) error {
return errCanceledInPreRun
}
func TestGetAppDBBackend(t *testing.T) {
v := viper.New()
require.Equal(t, server.GetAppDBBackend(v), db.GoLevelDBBackend)
v.Set("db_backend", "dbtype1") // value from CometBFT config
require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype1"))
v.Set("app-db-backend", "dbtype2") // value from app.toml
require.Equal(t, server.GetAppDBBackend(v), db.BackendType("dbtype2"))
}
func TestInterceptConfigsPreRunHandlerCreatesConfigFilesWhenMissing(t *testing.T) {
tempDir := t.TempDir()
cmd := server.StartCmd(nil, "/foobar")