From 5f62bd6deec39f11d26f21eb856a48804c0ee0c4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:47:16 +0200 Subject: [PATCH] fix: use correct config key for db_backend (backport #17406) (#17412) Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++++ server/util.go | 2 +- server/util_test.go | 14 +++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d129102b8e72..09f7394af4c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/genutil) [#17296](https://github.com/cosmos/cosmos-sdk/pull/17296) Add `MigrateHandler` to allow reuse migrate genesis related function. * In v0.46, v0.47 this function is additive to the `genesis migrate` command. However in v0.50+, adding custom migrations to the `genesis migrate` command is directly possible. +## Bug Fixes + +* (server) [#17181](https://github.com/cosmos/cosmos-sdk/pull/17181) Fix `db_backend` lookup fallback from `config.toml`. + ## [v0.46.14](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.14) - 2023-07-17 ### Features diff --git a/server/util.go b/server/util.go index cac4bd9df194..b8d06b4d741f 100644 --- a/server/util.go +++ b/server/util.go @@ -371,7 +371,7 @@ func GetAppDBBackend(opts types.AppOptions) dbm.BackendType { rv = sdk.DBBackend } if len(rv) == 0 { - rv = cast.ToString(opts.Get("db-backend")) + rv = cast.ToString(opts.Get("db_backend")) } if len(rv) != 0 { return dbm.BackendType(rv) diff --git a/server/util_test.go b/server/util_test.go index 630a2795dc3f..4f89b73f9faa 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -470,10 +470,10 @@ func TestGetAppDBBackend(t *testing.T) { }, { - name: "only db-backend set", + name: "only db_backend set", dbBack: "", - opts: mapGetter{"db-backend": "db-backend value 1"}, - exp: dbm.BackendType("db-backend value 1"), + opts: mapGetter{"db_backend": "db_backend value 1"}, + exp: dbm.BackendType("db_backend value 1"), }, { name: "only DBBackend set", @@ -491,7 +491,7 @@ func TestGetAppDBBackend(t *testing.T) { { name: "app-db-backend and db-backend set", dbBack: "", - opts: mapGetter{"db-backend": "db-backend value 4", "app-db-backend": "app-db-backend value 5"}, + opts: mapGetter{"db_backend": "db_backend value 4", "app-db-backend": "app-db-backend value 5"}, exp: dbm.BackendType("app-db-backend value 5"), }, { @@ -501,16 +501,16 @@ func TestGetAppDBBackend(t *testing.T) { exp: dbm.BackendType("app-db-backend value 7"), }, { - name: "db-backend and DBBackend set", + name: "db_backend and DBBackend set", dbBack: "DBBackend value 8", - opts: mapGetter{"db-backend": "db-backend value 9"}, + opts: mapGetter{"db_backend": "db_backend value 9"}, exp: dbm.BackendType("DBBackend value 8"), }, { name: "all of app-db-backend db-backend DBBackend set", dbBack: "DBBackend value 10", - opts: mapGetter{"db-backend": "db-backend value 11", "app-db-backend": "app-db-backend value 12"}, + opts: mapGetter{"db_backend": "db_backend value 11", "app-db-backend": "app-db-backend value 12"}, exp: dbm.BackendType("app-db-backend value 12"), }, }