Skip to content

Commit

Permalink
Fix namespaces to com-pile
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Sep 16, 2024
1 parent 69863a1 commit cc155e7
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/cosmos/ibc-go/v9/internal/logging"
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
Expand Down Expand Up @@ -84,8 +83,9 @@ func (k Keeper) registerInterchainAccount(ctx context.Context, connectionID, por
return "", err
}

k.EventService.EventManager(ctx).Events()
k.Logger.Debug("emitting interchain account registration events", logging.SdkEventsToLogArguments(events))
// TODO: .Events() is no longer a thing on the SDK
events := sdkCtx.EventManager().Events()
k.Logger.Debug("emitting interchain account registration events", events)

// NOTE: The sdk msg handler creates a new EventManager, so events must be correctly propagated back to the current context
sdkCtx.EventManager().EmitEvents(events)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
"cosmossdk.io/core/appmodule"
"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types"
genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types"
Expand All @@ -13,6 +14,10 @@ import (
func (suite *KeeperTestSuite) TestInitGenesis() {
ports := []string{"port1", "port2", "port3"}

env := appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
}

testCases := []struct {
name string
malleate func()
Expand All @@ -30,7 +35,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
},
}

interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), ibctesting.FirstConnectionID, TestPortID)
interchainAccAddr := icatypes.GenerateAddress(suite.chainB.GetContext(), env, ibctesting.FirstConnectionID, TestPortID)
genesisState := genesistypes.ControllerGenesisState{
ActiveChannels: []genesistypes.ActiveChannel{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/core/appmodule"
govtypes "cosmossdk.io/x/gov/types"
"github.com/cosmos/cosmos-sdk/runtime"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -110,6 +111,11 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) TestNewKeeper() {
env := appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
}

testCases := []struct {
name string
instantiateFn func()
Expand All @@ -118,7 +124,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"success", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -131,7 +137,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: empty authority", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand Down
12 changes: 9 additions & 3 deletions modules/apps/27-interchain-accounts/host/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"cosmossdk.io/core/appmodule"
testifysuite "github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -134,6 +135,11 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (suite *KeeperTestSuite) TestNewKeeper() {
env := appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
}

testCases := []struct {
name string
instantiateFn func()
Expand All @@ -142,7 +148,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"success", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -157,7 +163,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: interchain accounts module account does not exist", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -172,7 +178,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: empty mock staking keeper", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (k Keeper) revertForwardedPacket(ctx context.Context, forwardedPacket chann
// given that the packet is being reversed, we check the DestinationChannel and DestinationPort
// of the forwardedPacket to see if a hop was added to the trace during the receive step
if token.Denom.HasPrefix(forwardedPacket.DestinationPort, forwardedPacket.DestinationChannel) {
if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil {
if err := k.bankKeeper.BurnCoins(ctx, k.authKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin)); err != nil {
return err
}
} else {
Expand Down
17 changes: 13 additions & 4 deletions modules/apps/transfer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/core/appmodule"
"cosmossdk.io/math"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -58,7 +59,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"success", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
},
suite.chainA.GetSimApp().GetSubspace(types.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -72,7 +76,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: transfer module account does not exist", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
},
suite.chainA.GetSimApp().GetSubspace(types.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -86,7 +93,10 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: empty authority", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
},
suite.chainA.GetSimApp().GetSubspace(types.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand Down Expand Up @@ -284,7 +294,6 @@ func (suite *KeeperTestSuite) TestGetAllDenomEscrows() {

storeKey := suite.chainA.GetSimApp().GetKey(types.ModuleName)
store = ctx.KVStore(storeKey)
cdc = suite.chainA.App.AppCodec()

tc.malleate()

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (k Keeper) sendTransfer(
}

if err := k.bankKeeper.BurnCoins(
ctx, types.ModuleName, sdk.NewCoins(coin),
ctx, k.authKeeper.GetModuleAddress(types.ModuleName), sdk.NewCoins(coin),
); err != nil {
// NOTE: should not happen as the module account was
// retrieved on the step above and it has enough balance
Expand Down
9 changes: 5 additions & 4 deletions modules/apps/transfer/simulation/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package simulation
import (
"math/rand"

"cosmossdk.io/core/address"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/simulation"

"github.com/cosmos/ibc-go/v9/modules/apps/transfer/types"
Expand All @@ -30,13 +31,13 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg {
}

// SimulateMsgUpdateParams returns a MsgUpdateParams
func SimulateMsgUpdateParams(_ *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
var gov sdk.AccAddress = address.Module("gov")
func SimulateMsgUpdateParams(_ *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) {
var gov sdk.AccAddress = authtypes.NewModuleAddress("gov")
params := types.DefaultParams()
params.SendEnabled = false

return &types.MsgUpdateParams{
Signer: gov.String(),
Params: params,
}
}, nil
}
3 changes: 2 additions & 1 deletion modules/apps/transfer/simulation/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func TestProposalMsgs(t *testing.T) {
require.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey())
require.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight())

msg := w0.MsgSimulatorFn()(r, ctx, accounts)
msg, err := w0.MsgSimulatorFn()(ctx, r, accounts, nil)
require.NoError(t, err)
msgUpdateParams, ok := msg.(*types.MsgUpdateParams)
require.True(t, ok)

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type AccountKeeper interface {
type BankKeeper interface {
SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
BurnCoins(ctx context.Context, moduleName []byte, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
BlockedAddr(addr sdk.AccAddress) bool
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func BeginBlocker(ctx context.Context, k *keeper.Keeper) {
if err == nil && hi.Height == plan.Height-1 {
upgradedConsState := &ibctm.ConsensusState{
Timestamp: hi.Time,
NextValidatorsHash: ctx.NextValidatorsHash, //TODO: need to pass the consensus modules blocked on https://github.com/cosmos/cosmos-sdk/pull/21480
NextValidatorsHash: hi.NextValidatorsHash, //TODO: need to pass the consensus modules blocked on https://github.com/cosmos/cosmos-sdk/pull/21480
}
bz := types.MustMarshalConsensusState(k.Codec(), upgradedConsState)

Expand Down
10 changes: 8 additions & 2 deletions modules/core/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/core/appmodule"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"

"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -50,6 +51,11 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
newIBCKeeperFn func()
)

env := appmodule.Environment{
Logger: suite.chainA.GetSimApp().Logger(),
KVStoreService: runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)),
}

testCases := []struct {
name string
malleate func()
Expand All @@ -74,7 +80,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
newIBCKeeperFn = func() {
ibckeeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName),
upgradeKeeper,
scopedKeeper,
Expand All @@ -93,7 +99,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
newIBCKeeperFn = func() {
ibckeeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(ibcexported.StoreKey)),
env,
suite.chainA.GetSimApp().GetSubspace(ibcexported.ModuleName),
upgradeKeeper,
scopedKeeper,
Expand Down
Loading

0 comments on commit cc155e7

Please sign in to comment.