Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
insumity committed Sep 5, 2024
1 parent 3bccedb commit 56a6c46
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
32 changes: 17 additions & 15 deletions app/upgrades/v20/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v20
import (
"context"
"fmt"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"

Expand All @@ -13,6 +13,7 @@ import (
codec "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
Expand Down Expand Up @@ -228,7 +229,8 @@ func MigrateICSProposal(
msgServer providertypes.MsgServer,
providerKeeper providerkeeper.Keeper,
govKeeper govkeeper.Keeper,
proposal govtypesv1.Proposal) error {
proposal govtypesv1.Proposal,
) error {
// ignore proposals that were rejected or failed
if proposal.Status != govtypesv1.StatusDepositPeriod &&
proposal.Status != govtypesv1.StatusVotingPeriod &&
Expand Down Expand Up @@ -364,27 +366,27 @@ func MigrateMsgConsumerAddition(
msgServer providertypes.MsgServer,
providerKeeper providerkeeper.Keeper,
govKeeper govkeeper.Keeper,
proposalId uint64,
proposalID uint64,
msg providertypes.MsgConsumerAddition,
indexOfMessageInProposal int,
) error {
proposal, err := govKeeper.Proposals.Get(ctx, proposalId)
proposal, err := govKeeper.Proposals.Get(ctx, proposalID)
if err != nil {
return err
}
if proposal.Status == govtypesv1.StatusPassed {
// MsgConsumerAddition that passed
for _, consumerId := range providerKeeper.GetAllActiveConsumerIds(ctx) {
chainId, err := providerKeeper.GetConsumerChainId(ctx, consumerId)
for _, consumerID := range providerKeeper.GetAllActiveConsumerIds(ctx) {
chainID, err := providerKeeper.GetConsumerChainId(ctx, consumerID)
if err != nil {
return err // this means something is wrong with the provider state
}
if chainId == msg.ChainId {
if chainID == msg.ChainId {
// this proposal was already handled in a previous block
ctx.Logger().Info(
fmt.Sprintf(
"Proposal with ID(%d) was skipped as it was already handled - consumerId(%s), chainId(%s), spawnTime(%s)",
proposal.Id, consumerId, msg.ChainId, msg.SpawnTime.String(),
"Proposal with ID(%d) was skipped as it was already handled - consumerID(%s), chainID(%s), spawnTime(%s)",
proposal.Id, consumerID, msg.ChainId, msg.SpawnTime.String(),
),
)
return nil
Expand Down Expand Up @@ -585,11 +587,11 @@ func MigrateMsgConsumerRemoval(
msgServer providertypes.MsgServer,
providerKeeper providerkeeper.Keeper,
govKeeper govkeeper.Keeper,
proposalId uint64,
proposalID uint64,
msg providertypes.MsgConsumerRemoval,
indexOfMessageInProposal int,
) error {
proposal, err := govKeeper.Proposals.Get(ctx, proposalId)
proposal, err := govKeeper.Proposals.Get(ctx, proposalID)
if err != nil {
return err
}
Expand Down Expand Up @@ -680,11 +682,11 @@ func MigrateMsgConsumerModification(
ctx sdk.Context,
providerKeeper providerkeeper.Keeper,
govKeeper govkeeper.Keeper,
proposalId uint64,
proposalID uint64,
msg providertypes.MsgConsumerModification,
indexOfMessageInProposal int,
) error {
proposal, err := govKeeper.Proposals.Get(ctx, proposalId)
proposal, err := govKeeper.Proposals.Get(ctx, proposalID)
if err != nil {
return err
}
Expand Down Expand Up @@ -769,11 +771,11 @@ func MigrateMsgConsumerModification(
func MigrateMsgChangeRewardDenoms(
ctx sdk.Context,
govKeeper govkeeper.Keeper,
proposalId uint64,
proposalID uint64,
msg providertypes.MsgChangeRewardDenoms,
indexOfMessageInProposal int,
) error {
proposal, err := govKeeper.Proposals.Get(ctx, proposalId)
proposal, err := govKeeper.Proposals.Get(ctx, proposalID)
if err != nil {
return err
}
Expand Down
31 changes: 18 additions & 13 deletions app/upgrades/v20/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ package v20_test
import (
"encoding/base64"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
"github.com/cosmos/interchain-security/v5/x/ccv/types"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"

"github.com/cosmos/gaia/v20/app/helpers"
v20 "github.com/cosmos/gaia/v20/app/upgrades/v20"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
"github.com/cosmos/interchain-security/v5/x/ccv/types"
"github.com/stretchr/testify/require"
"testing"
"time"
)

func GetTestMsgConsumerAddition() providertypes.MsgConsumerAddition {
Expand Down Expand Up @@ -77,9 +82,9 @@ func TestMigrateMsgConsumerAdditionWithNotPassedProposalAndInvalidParams(t *test
require.ErrorContains(t, err, "not found")

// (indirectly) verify that `CreateConsumer` was not called by checking that consumer id was not updated
consumerId, found := providerKeeper.GetConsumerId(ctx)
consumerID, found := providerKeeper.GetConsumerId(ctx)
require.False(t, found)
require.Equal(t, uint64(0), consumerId)
require.Equal(t, uint64(0), consumerID)
}

func TestMigrateMsgConsumerAdditionWithNotPassedProposalAndValidParams(t *testing.T) {
Expand Down Expand Up @@ -109,9 +114,9 @@ func TestMigrateMsgConsumerAdditionWithNotPassedProposalAndValidParams(t *testin
require.NoError(t, err)

// (indirectly) verify that `CreateConsumer` was called by checking that consumer id was updated
consumerId, found := providerKeeper.GetConsumerId(ctx)
consumerID, found := providerKeeper.GetConsumerId(ctx)
require.True(t, found)
require.Equal(t, uint64(1), consumerId)
require.Equal(t, uint64(1), consumerID)
consumerMetadata, err := providerKeeper.GetConsumerMetadata(ctx, "0")
require.NoError(t, err)
fmt.Println(consumerMetadata)
Expand Down Expand Up @@ -170,9 +175,9 @@ func TestMigrateMsgConsumerAdditionWithPassedProposal(t *testing.T) {
require.NoError(t, err)

// (indirectly) verify that `CreateConsumer` was called by checking that consumer id was updated
consumerId, found := providerKeeper.GetConsumerId(ctx)
consumerID, found := providerKeeper.GetConsumerId(ctx)
require.True(t, found)
require.Equal(t, uint64(1), consumerId)
require.Equal(t, uint64(1), consumerID)
consumerMetadata, err := providerKeeper.GetConsumerMetadata(ctx, "0")
require.NoError(t, err)
require.Equal(t, msgConsumerAddition.ChainId, consumerMetadata.Name)
Expand Down

0 comments on commit 56a6c46

Please sign in to comment.