From 45b18a1045bbceac393d34d30ff4eaaa96fc972e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 21:18:30 +0200 Subject: [PATCH] refactor(server): alias AppOptions to coreserver.DynamicConfig (backport #21711) (#21722) --- server/types/app.go | 5 ++--- server/util_test.go | 4 ++++ testutil/sims/app_helpers.go | 9 +++++++++ testutils/sims/runner.go | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/server/types/app.go b/server/types/app.go index 798a4475dbbe..d08cfff0ea9b 100644 --- a/server/types/app.go +++ b/server/types/app.go @@ -8,6 +8,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/gogoproto/grpc" + "cosmossdk.io/core/server" corestore "cosmossdk.io/core/store" "cosmossdk.io/log" "cosmossdk.io/store/snapshots" @@ -26,9 +27,7 @@ type ( // literal defined on the server Context. Note, casting Get calls may not yield // the expected types and could result in type assertion errors. It is recommend // to either use the cast package or perform manual conversion for safety. - AppOptions interface { - Get(string) interface{} - } + AppOptions = server.DynamicConfig // Application defines an application interface that wraps abci.Application. // The interface defines the necessary contracts to be implemented in order diff --git a/server/util_test.go b/server/util_test.go index 11f5cbb208c9..39a9e6c35528 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -492,4 +492,8 @@ func (m mapGetter) Get(key string) interface{} { return m[key] } +func (m mapGetter) GetString(key string) string { + return m[key].(string) +} + var _ servertypes.AppOptions = mapGetter{} diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index a07d71d41b73..53a886a20797 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -306,6 +306,15 @@ func (m AppOptionsMap) Get(key string) interface{} { return v } +func (m AppOptionsMap) GetString(key string) string { + v, ok := m[key] + if !ok { + return "" + } + + return v.(string) +} + func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions { return AppOptionsMap{ flags.FlagHome: homePath, diff --git a/testutils/sims/runner.go b/testutils/sims/runner.go index d1ae04fc6f94..918770725387 100644 --- a/testutils/sims/runner.go +++ b/testutils/sims/runner.go @@ -235,6 +235,10 @@ func (f AppOptionsFn) Get(k string) any { return f(k) } +func (f AppOptionsFn) GetString(k string) string { + return f(k).(string) +} + // FauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of // an IAVLStore for faster simulation speed. func FauxMerkleModeOpt(bapp *baseapp.BaseApp) {