forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a function to initialize the ICS27 module via an upgrade pr…
…oposal (cosmos#1037) ## Description closes: cosmos#1034 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes
- Loading branch information
1 parent
f994d1e
commit 147e0f1
Showing
5 changed files
with
110 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package ica_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
dbm "github.com/tendermint/tm-db" | ||
|
||
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" | ||
controllertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" | ||
hosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" | ||
"github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" | ||
ibctesting "github.com/cosmos/ibc-go/v3/testing" | ||
"github.com/cosmos/ibc-go/v3/testing/simapp" | ||
) | ||
|
||
type InterchainAccountsTestSuite struct { | ||
suite.Suite | ||
|
||
coordinator *ibctesting.Coordinator | ||
} | ||
|
||
func TestICATestSuite(t *testing.T) { | ||
suite.Run(t, new(InterchainAccountsTestSuite)) | ||
} | ||
|
||
func (suite *InterchainAccountsTestSuite) SetupTest() { | ||
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) | ||
} | ||
|
||
func (suite *InterchainAccountsTestSuite) TestInitModule() { | ||
app := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, map[int64]bool{}, simapp.DefaultNodeHome, 5, simapp.MakeTestEncodingConfig(), simapp.EmptyAppOptions{}) | ||
icamodule, ok := app.GetModuleManager().Modules[types.ModuleName].(ica.AppModule) | ||
suite.Require().True(ok) | ||
|
||
header := tmproto.Header{ | ||
ChainID: "testchain", | ||
Height: 1, | ||
Time: suite.coordinator.CurrentTime.UTC(), | ||
} | ||
|
||
ctx := app.GetBaseApp().NewContext(true, header) | ||
|
||
// 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.PortID)) | ||
|
||
icamodule.InitModule(ctx, controllerParams, hostParams) | ||
|
||
controllerParams = app.ICAControllerKeeper.GetParams(ctx) | ||
suite.Require().True(controllerParams.ControllerEnabled) | ||
|
||
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.PortID)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters