fix all bits broken by viper API changes (#5982)

github.com/spf13/viper's recent releases introduced a semantic
change in some public API such as viper.IsSet(), which have
broken some of our flags checks. Instead of checking whether
users have changed a flag's default value we should rely on such
defaults and adjust runtime behaviour accordingly. In order to do
so, it's important that we pick sane defaults for all our flags.

The --pruning flag and configuration option now allow for a
fake custom strategy. When users elect custom, then the
pruning-{keep,snapshot}-every options are interpreted and
parsed; else they're ignored.
Zero is pruning-{keep,snapshot}-every default value. When
users choose to set a custom pruning strategy they are
signalling that they want more fine-grainted control, therefore
it's legitimate to expect them to know what they are doing and
enter valid values for both options.

Ref #5964
This commit is contained in:
Alessio Treglia
2020-04-14 17:24:27 +02:00
committed by GitHub
parent a6588a4d2d
commit e8cedf243f
12 changed files with 147 additions and 161 deletions
@@ -3,14 +3,17 @@ package common
import (
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
)
func TestQueryDelegationRewardsAddrValidation(t *testing.T) {
cdc := codec.New()
viper.Set(flags.FlagOffline, true)
ctx := context.NewCLIContext().WithCodec(cdc)
type args struct {
delAddr string