Skip to content

Commit

Permalink
fix ibc scoped keeper for testutil
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Oct 2, 2024
1 parent 2a47525 commit 7339325
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
10 changes: 4 additions & 6 deletions testutil/keeper/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (i initializer) Staking(
func (i initializer) IBC(
paramKeeper paramskeeper.Keeper,
stakingKeeper *stakingkeeper.Keeper,
capabilityKeeper capabilitykeeper.Keeper,
scopedKeeper capabilitykeeper.ScopedKeeper,
upgradeKeeper *upgradekeeper.Keeper,
) *ibckeeper.Keeper {
storeKey := storetypes.NewKVStoreKey(ibcexported.StoreKey)
Expand All @@ -223,7 +223,7 @@ func (i initializer) IBC(
paramKeeper.Subspace(ibcexported.ModuleName),
stakingKeeper,
upgradeKeeper,
capabilityKeeper.ScopeToModule(ibcexported.ModuleName),
scopedKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
}
Expand Down Expand Up @@ -339,6 +339,7 @@ func (i initializer) Reward(
func (i initializer) Monitoringc(
ibcKeeper ibckeeper.Keeper,
capabilityKeeper capabilitykeeper.Keeper,
portKeeper portkeeper.Keeper,
launchKeeper launchkeeper.Keeper,
rewardKeeper rewardkeeper.Keeper,
connectionMock []Connection,
Expand All @@ -362,8 +363,6 @@ func (i initializer) Monitoringc(
channelKeeper = NewChannelMock(channelMock)
}

scopedKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
scopeModule := capabilityKeeper.ScopeToModule(monitoringctypes.ModuleName)

k := monitoringckeeper.NewKeeper(
Expand Down Expand Up @@ -396,6 +395,7 @@ func (i initializer) Monitoringp(
stakingKeeper *stakingkeeper.Keeper,
ibcKeeper ibckeeper.Keeper,
capabilityKeeper capabilitykeeper.Keeper,
portKeeper portkeeper.Keeper,
connectionMock []Connection,
channelMock []Channel,
) monitoringpkeeper.Keeper {
Expand All @@ -417,8 +417,6 @@ func (i initializer) Monitoringp(
channelKeeper = NewChannelMock(channelMock)
}

scopedKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
scopeModule := capabilityKeeper.ScopeToModule(monitoringctypes.ModuleName)

k := monitoringpkeeper.NewKeeper(
Expand Down
12 changes: 10 additions & 2 deletions testutil/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
portkeeper "github.com/cosmos/ibc-go/v8/modules/core/05-port/keeper"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
claimkeeper "github.com/ignite/modules/x/claim/keeper"
claimtypes "github.com/ignite/modules/x/claim/types"
Expand Down Expand Up @@ -112,12 +114,14 @@ func NewTestSetup(t testing.TB, options ...SetupOption) (sdk.Context, TestKeeper

paramKeeper := initializer.Param()
capabilityKeeper := initializer.Capability()
scopedKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
authKeeper := initializer.Auth(paramKeeper)
bankKeeper := initializer.Bank(paramKeeper, authKeeper)
stakingKeeper := initializer.Staking(authKeeper, bankKeeper, paramKeeper)
distrKeeper := initializer.Distribution(authKeeper, bankKeeper, stakingKeeper)
upgradeKeeper := initializer.Upgrade()
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, *capabilityKeeper, upgradeKeeper)
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, scopedKeeper, upgradeKeeper)
fundraisingKeeper := initializer.Fundraising(authKeeper, bankKeeper, distrKeeper)
profileKeeper := initializer.Profile()
launchKeeper := initializer.Launch(profileKeeper, distrKeeper)
Expand All @@ -128,6 +132,7 @@ func NewTestSetup(t testing.TB, options ...SetupOption) (sdk.Context, TestKeeper
monitoringConsumerKeeper := initializer.Monitoringc(
*ibcKeeper,
*capabilityKeeper,
portKeeper,
launchKeeper,
rewardKeeper,
[]Connection{},
Expand Down Expand Up @@ -220,12 +225,14 @@ func NewTestSetupWithIBCMocks(

paramKeeper := initializer.Param()
capabilityKeeper := initializer.Capability()
scopedKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
authKeeper := initializer.Auth(paramKeeper)
bankKeeper := initializer.Bank(paramKeeper, authKeeper)
stakingKeeper := initializer.Staking(authKeeper, bankKeeper, paramKeeper)
distrKeeper := initializer.Distribution(authKeeper, bankKeeper, stakingKeeper)
upgradeKeeper := initializer.Upgrade()
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, *capabilityKeeper, upgradeKeeper)
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, scopedKeeper, upgradeKeeper)
fundraisingKeeper := initializer.Fundraising(authKeeper, bankKeeper, distrKeeper)
profileKeeper := initializer.Profile()
launchKeeper := initializer.Launch(profileKeeper, distrKeeper)
Expand All @@ -236,6 +243,7 @@ func NewTestSetupWithIBCMocks(
monitoringConsumerKeeper := initializer.Monitoringc(
*ibcKeeper,
*capabilityKeeper,
portKeeper,
launchKeeper,
rewardKeeper,
connectionMock,
Expand Down
7 changes: 6 additions & 1 deletion testutil/keeper/monitoring_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
portkeeper "github.com/cosmos/ibc-go/v8/modules/core/05-port/keeper"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
fundraisingtypes "github.com/ignite/modules/x/fundraising/types"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -39,16 +41,19 @@ func NewTestSetupWithIBCMocksMonitoringp(

paramKeeper := initializer.Param()
capabilityKeeper := initializer.Capability()
scopedKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
authKeeper := initializer.Auth(paramKeeper)
bankKeeper := initializer.Bank(paramKeeper, authKeeper)
stakingKeeper := initializer.Staking(authKeeper, bankKeeper, paramKeeper)
distrKeeper := initializer.Distribution(authKeeper, bankKeeper, stakingKeeper)
upgradeKeeper := initializer.Upgrade()
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, *capabilityKeeper, upgradeKeeper)
ibcKeeper := initializer.IBC(paramKeeper, stakingKeeper, scopedKeeper, upgradeKeeper)
monitoringProviderKeeper := initializer.Monitoringp(
stakingKeeper,
*ibcKeeper,
*capabilityKeeper,
portKeeper,
connectionMock,
channelMock,
)
Expand Down

0 comments on commit 7339325

Please sign in to comment.