diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index 74cf8cb8..8d09f927 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -750,7 +750,7 @@ func (suite *AnteTestSuite) TestInfiniteGasMeterDecorator() { suite.ctx = suite.ctx.WithBlockHeight(1) // Context GasMeter Limit not set - suite.Require().Equal(uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") + suite.Require().Equal(uint64(0xffffffffffffffff), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") newCtx, err := antehandler(suite.ctx, tx, false) suite.Require().Nil(err, "InfiniteGasMeterDecorator returned error") diff --git a/testutil/network/network.go b/testutil/network/network.go index 3b3c2fdd..3592d197 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -55,16 +55,17 @@ var lock = new(sync.Mutex) // AppConstructor defines a function which accepts a network configuration and // creates an ABCI Application to provide to Tendermint. -type AppConstructor = func(val Validator) servertypes.Application +type AppConstructor = func(val Validator, chainId string) servertypes.Application func NewSimApp(encodingCfg app.EncodingConfig) AppConstructor { - return func(val Validator) servertypes.Application { + return func(val Validator, chainId string) servertypes.Application { return app.NewInitApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, encodingCfg, simtestutil.EmptyAppOptions{}, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + baseapp.SetChainID(chainId), ) } } diff --git a/testutil/network/util.go b/testutil/network/util.go index c390ed7c..ff509752 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -40,7 +40,7 @@ func startInProcess(cfg Config, val *Validator) error { return err } - app := cfg.AppConstructor(*val) + app := cfg.AppConstructor(*val, cfg.ChainID) genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg) tmNode, err := node.NewNode( diff --git a/x/evidence/client/cli/cli_test.go b/x/evidence/client/cli/cli_test.go index b2b75eb6..a5f50f3d 100644 --- a/x/evidence/client/cli/cli_test.go +++ b/x/evidence/client/cli/cli_test.go @@ -36,13 +36,14 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 - cfg.AppConstructor = func(val network.Validator) servertypes.Application { + cfg.AppConstructor = func(val network.Validator, chainId string) servertypes.Application { return app.NewInitApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, simapp.MakeEncodingConfig(), simapp.EmptyAppOptions{}, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + baseapp.SetChainID(chainId), ) } diff --git a/x/evidence/types/evidence_test.go b/x/evidence/types/evidence_test.go index ddb7175d..3b5e9d22 100644 --- a/x/evidence/types/evidence_test.go +++ b/x/evidence/types/evidence_test.go @@ -30,7 +30,7 @@ func TestEquivocation_Valid(t *testing.T) { require.Equal(t, e.Type(), types.TypeEquivocation) require.Equal(t, e.Route(), types.RouteEquivocation) require.Equal(t, e.Hash().String(), "1E10F9267BEA3A9A4AB5302C2C510CC1AFD7C54E232DA5B2E3360DFAFACF7A76") - require.Equal(t, e.String(), "consensus_address: cosmosvalcons1vehk7h6lta047h6lta047h6lta047h6l8m4r53\nheight: 100\npower: 1000000\ntime: \"2006-01-02T15:04:05Z\"\n") + require.Equal(t, e.String(), "height: 100\ntime: 2006-01-02T15:04:05Z\npower: 1000000\nconsensus_address: cosmosvalcons1vehk7h6lta047h6lta047h6lta047h6l8m4r53\n") require.NoError(t, e.ValidateBasic()) require.Equal(t, int64(0), e.GetTotalPower()) diff --git a/x/gov/client/cli/cli_test.go b/x/gov/client/cli/cli_test.go index 0317803b..8918b372 100644 --- a/x/gov/client/cli/cli_test.go +++ b/x/gov/client/cli/cli_test.go @@ -43,13 +43,14 @@ func (s *IntegrationTestSuite) SetupSuite() { genesis[types.ModuleName] = govGenRaw cfg.GenesisState = genesis - cfg.AppConstructor = func(val network.Validator) servertypes.Application { + cfg.AppConstructor = func(val network.Validator, chainId string) servertypes.Application { return app.NewInitApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, simapp.MakeEncodingConfig(), simapp.EmptyAppOptions{}, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + baseapp.SetChainID(chainId), ) } diff --git a/x/staking/client/cli/cli_test.go b/x/staking/client/cli/cli_test.go index ac105bd8..f54f3e69 100644 --- a/x/staking/client/cli/cli_test.go +++ b/x/staking/client/cli/cli_test.go @@ -45,13 +45,14 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 - cfg.AppConstructor = func(val network.Validator) servertypes.Application { + cfg.AppConstructor = func(val network.Validator, chainId string) servertypes.Application { return app.NewInitApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, - app.MakeEncodingConfig(), + simapp.MakeEncodingConfig(), simapp.EmptyAppOptions{}, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + baseapp.SetChainID(chainId), ) } diff --git a/x/staking/genesis.go b/x/staking/genesis.go index b2c346de..e8c325d0 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -26,10 +26,7 @@ func WriteValidators(ctx sdk.Context, k keeper.Keeper) (vals []tmtypes.GenesisVa return true } - moniker, err := k.GetMonikerByAddress(ctx, sdk.AccAddress(validator.ValKey)) - if err != nil { - return false - } + moniker := k.GetMonikerByAddress(ctx, sdk.AccAddress(validator.ValKey)) vals = append(vals, tmtypes.GenesisValidator{ Address: sdk.ConsAddress(tmPk.Address()).Bytes(), PubKey: tmPk, diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index cdc54b1e..2f92ea75 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -35,8 +35,7 @@ func TestNewHandler_MsgClaimValidator_HappyPath(t *testing.T) { app := simapp.Setup(false) ctx := app.NewContext(false, tmproto.Header{}) - _, err = app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(valAddr1)) - require.Error(t, err) + app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(valAddr1)) // First we give user permissions networkActor := govtypes.NewNetworkActor( @@ -75,8 +74,7 @@ func TestNewHandler_MsgClaimValidator_HappyPath(t *testing.T) { require.Equal(t, records[0].Key, "moniker") require.Equal(t, records[0].Value, "aMoniker") - moniker, err := app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(valAddr1)) - require.NoError(t, err) + moniker := app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(valAddr1)) require.Equal(t, moniker, "aMoniker") } diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index d585c5b1..b477d080 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -75,11 +75,7 @@ func (q Querier) Validators(ctx context.Context, request *types.ValidatorsReques return false, err } - moniker, err := q.keeper.GetMonikerByAddress(c, sdk.AccAddress(val.ValKey)) - if err != nil { - return false, err - } - + moniker := q.keeper.GetMonikerByAddress(c, sdk.AccAddress(val.ValKey)) validator := types.QueryValidator{ Address: sdk.AccAddress(val.ValKey).String(), Valkey: val.ValKey.String(), diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index 29f576b3..b28253d3 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -61,7 +61,6 @@ func TestQuerier_Validators(t *testing.T) { } querier := stakingkeeper.NewQuerier(app.CustomStakingKeeper) - resp, err := querier.Validators(types.WrapSDKContext(ctx), &stakingtypes.ValidatorsRequest{ // no restriction to query all }) @@ -69,6 +68,6 @@ func TestQuerier_Validators(t *testing.T) { require.Len(t, resp.Validators, 100) require.Len(t, resp.Actors, 1000) - require.Equal(t, resp.Pagination.Total, uint64(1000)) + require.Equal(t, resp.Pagination.Total, uint64(1001)) require.NotNil(t, resp.Pagination.NextKey) } diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 1f8da7bd..aa8437be 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -215,13 +215,10 @@ func (k Keeper) GetIdRecordsByAddress(ctx sdk.Context, creator sdk.AccAddress) [ return k.govkeeper.GetIdRecordsByAddress(ctx, creator) } -func (k Keeper) GetMonikerByAddress(ctx sdk.Context, addr sdk.AccAddress) (string, error) { +func (k Keeper) GetMonikerByAddress(ctx sdk.Context, addr sdk.AccAddress) string { records, err := k.govkeeper.GetIdRecordsByAddressAndKeys(ctx, addr, []string{"moniker"}) if err != nil { - return "", err + return "" } - if len(records) != 1 { - return "", fmt.Errorf("failed fetching the field moniker from identity registrar for address=%s", addr.String()) - } - return records[0].Value, nil + return records[0].Value } diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index fd63271c..7a8d8adc 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -72,12 +72,11 @@ func TestKeeper_GetMonikerByAddress(t *testing.T) { require.NoError(t, err) // get moniker by address - moniker, err := app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(validator.ValKey)) - require.NoError(t, err) + moniker := app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress(validator.ValKey)) require.Equal(t, moniker, "node0") - moniker, err = app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress("non existing")) - require.Error(t, err) + moniker = app.CustomStakingKeeper.GetMonikerByAddress(ctx, sdk.AccAddress("non existing")) + require.Equal(t, moniker, "") } func TestKeeper_GetValidatorSet(t *testing.T) { @@ -92,7 +91,7 @@ func TestKeeper_GetValidatorSet(t *testing.T) { app.CustomStakingKeeper.AddValidator(ctx, validator2) validatorSet := app.CustomStakingKeeper.GetValidatorSet(ctx) - require.Equal(t, 2, len(validatorSet)) + require.Equal(t, 3, len(validatorSet)) // Iterate validators passed := 0 @@ -100,7 +99,7 @@ func TestKeeper_GetValidatorSet(t *testing.T) { passed++ return false }) - require.Equal(t, 2, passed) + require.Equal(t, 3, passed) // Iterate validators with stop passed = 0 diff --git a/x/tokens/client/cli/cli_test.go b/x/tokens/client/cli/cli_test.go index d313fc3d..21d4f36d 100644 --- a/x/tokens/client/cli/cli_test.go +++ b/x/tokens/client/cli/cli_test.go @@ -43,13 +43,14 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 - cfg.AppConstructor = func(val network.Validator) servertypes.Application { + cfg.AppConstructor = func(val network.Validator, chainId string) servertypes.Application { return app.NewInitApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, simapp.MakeEncodingConfig(), simapp.EmptyAppOptions{}, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), + baseapp.SetChainID(chainId), ) }