Skip to content

Commit

Permalink
Merge branch 'main' into carlos/4859-unbounded-field-lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Rodriguez authored Oct 31, 2023
2 parents 6a0eda4 + 50ac22e commit 98f61e5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 122 deletions.
21 changes: 0 additions & 21 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,6 @@ func NewAppModule(controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkee
}
}

// InitModule will initialize the interchain accounts module. It should only be
// called once and as an alternative to InitGenesis.
func (am AppModule) InitModule(ctx sdk.Context, controllerParams controllertypes.Params, hostParams hosttypes.Params) {
if am.controllerKeeper != nil {
controllerkeeper.InitGenesis(ctx, *am.controllerKeeper, genesistypes.ControllerGenesisState{
Params: controllerParams,
})
}

if am.hostKeeper != nil {
if err := hostParams.Validate(); err != nil {
panic(fmt.Errorf("could not set ica host params at initialization: %v", err))
}

hostkeeper.InitGenesis(ctx, *am.hostKeeper, genesistypes.HostGenesisState{
Params: hostParams,
Port: types.HostPortID,
})
}
}

// RegisterServices registers module services
func (am AppModule) RegisterServices(cfg module.Configurator) {
if am.controllerKeeper != nil {
Expand Down
101 changes: 0 additions & 101 deletions modules/apps/27-interchain-accounts/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@ package ica_test
import (
"testing"

dbm "github.com/cosmos/cosmos-db"
testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/baseapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"

ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
hosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/cosmos/ibc-go/v8/testing/simapp"
)

type InterchainAccountsTestSuite struct {
Expand All @@ -32,93 +21,3 @@ func TestICATestSuite(t *testing.T) {
func (suite *InterchainAccountsTestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)
}

func (suite *InterchainAccountsTestSuite) TestInitModule() {
// setup and basic testing
chainID := "testchain"
app := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID))
appModule, ok := app.ModuleManager.Modules[types.ModuleName].(ica.AppModule)
suite.Require().True(ok)

ctx := app.GetBaseApp().NewContext(true)

// ensure params are not set
suite.Require().Panics(func() {
app.ICAControllerKeeper.GetParams(ctx)
})
suite.Require().Panics(func() {
app.ICAHostKeeper.GetParams(ctx)
})

controllerParams := controllertypes.DefaultParams()
controllerParams.ControllerEnabled = true

hostParams := hosttypes.DefaultParams()
expAllowMessages := []string{"sdk.Msg"}
hostParams.HostEnabled = true
hostParams.AllowMessages = expAllowMessages
suite.Require().False(app.IBCKeeper.PortKeeper.IsBound(ctx, types.HostPortID))

testCases := []struct {
name string
malleate func()
expControllerPass bool
expHostPass bool
}{
{
"both controller and host set", func() {
var ok bool
appModule, ok = app.ModuleManager.Modules[types.ModuleName].(ica.AppModule)
suite.Require().True(ok)
}, true, true,
},
{
"neither controller or host is set", func() {
appModule = ica.NewAppModule(nil, nil)
}, false, false,
},
{
"only controller is set", func() {
appModule = ica.NewAppModule(&app.ICAControllerKeeper, nil)
}, true, false,
},
{
"only host is set", func() {
appModule = ica.NewAppModule(nil, &app.ICAHostKeeper)
}, false, true,
},
}

for _, tc := range testCases {
tc := tc

suite.Run(tc.name, func() {
suite.SetupTest() // reset

// reset app state
chainID := "testchain"
app = simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID))

ctx := app.GetBaseApp().NewContext(true)

tc.malleate()

suite.Require().NotPanics(func() {
appModule.InitModule(ctx, controllerParams, hostParams)
})

if tc.expControllerPass {
controllerParams = app.ICAControllerKeeper.GetParams(ctx)
suite.Require().True(controllerParams.ControllerEnabled)
}

if tc.expHostPass {
hostParams = app.ICAHostKeeper.GetParams(ctx)
suite.Require().True(hostParams.HostEnabled)
suite.Require().Equal(expAllowMessages, hostParams.AllowMessages)

suite.Require().True(app.IBCKeeper.PortKeeper.IsBound(ctx, types.HostPortID))
}
})
}
}

0 comments on commit 98f61e5

Please sign in to comment.