Skip to content

Commit

Permalink
If mars is an IBC-module
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev authored Sep 27, 2021
1 parent e1c6a6b commit f4c1386
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions docs/migration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,76 @@ func MarsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
}
```

If `mars` is an IBC-enabled module, add the following code, instead:

```go
package keeper

import (
"testing"

"github.com/cosmonaut/test/x/mars/keeper"
"github.com/cosmonaut/test/x/mars/types"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
ibckeeper "github.com/cosmos/ibc-go/modules/core/keeper"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
)

func MarsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
logger := log.NewNopLogger()

storeKey := sdk.NewKVStoreKey(types.StoreKey)
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)

db := tmdb.NewMemDB()
stateStore := store.NewCommitMultiStore(db)
stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db)
stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil)
require.NoError(t, stateStore.LoadLatestVersion())

registry := codectypes.NewInterfaceRegistry()
appCodec := codec.NewProtoCodec(registry)
capabilityKeeper := capabilitykeeper.NewKeeper(appCodec, storeKey, memStoreKey)

amino := codec.NewLegacyAmino()
ss := typesparams.NewSubspace(appCodec,
amino,
storeKey,
memStoreKey,
"MarsSubSpace",
)
IBCKeeper := ibckeeper.NewKeeper(
appCodec,
storeKey,
ss,
nil,
nil,
capabilityKeeper.ScopeToModule("MarsIBCKeeper"),
)

k := keeper.NewKeeper(
codec.NewProtoCodec(registry),
storeKey,
memStoreKey,
IBCKeeper.ChannelKeeper,
&IBCKeeper.PortKeeper,
capabilityKeeper.ScopeToModule("MarsScopedKeeper"),
)

ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, logger)
return k, ctx
}
```

### testutil/network/network.go

```go
Expand Down

0 comments on commit f4c1386

Please sign in to comment.