From d0ce80ecb57146e552fe86db66ffc300d35e93b3 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Wed, 23 Oct 2024 13:43:59 -0400 Subject: [PATCH] chore(simdv2): allow overriding the --home flag There were two calls to viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome); these calls invalidated any provided --home command line arguments. When testing multiple simapp instances in the same process, it is necessary to provide separate home directories. Changing the calls from .Set to .SetDefault retains the previous behavior of using DefaultNodeHome when no --home flag is provided, but it still respects --home when the flag is indeed provided. --- simapp/v2/simdv2/cmd/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index 4d669f91749b..7eb4c9662dfc 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -37,7 +37,7 @@ import ( ) func newApp[T transaction.Tx](logger log.Logger, viper *viper.Viper) serverv2.AppI[T] { - viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome) + viper.SetDefault(serverv2.FlagHome, simapp.DefaultNodeHome) return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper)) } @@ -165,7 +165,7 @@ func appExport[T transaction.Tx]( // overwrite the FlagInvCheckPeriod viper.Set(server.FlagInvCheckPeriod, 1) - viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome) + viper.SetDefault(serverv2.FlagHome, simapp.DefaultNodeHome) var simApp *simapp.SimApp[T] if height != -1 {