Skip to content

Commit a4fd595

Browse files
Add more tokenfactory tests
1 parent 1c75e0f commit a4fd595

File tree

11 files changed

+2419
-590
lines changed

11 files changed

+2419
-590
lines changed

app/keepers/keepers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func NewAppKeeper(
249249
appKeepers.AccountKeeper,
250250
appKeepers.BankKeeper,
251251
appKeepers.DistrKeeper,
252-
nil, // No allowed denoms restriction
252+
[]string{tokenfactorytypes.EnableSetMetadata, tokenfactorytypes.EnableCommunityPoolFeeFunding}, // enabled capabilities
253253
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
254254
)
255255

tests/integration/test_common.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ import (
3838
"github.com/cosmos/gaia/v26/x/liquid"
3939
liquidkeeper "github.com/cosmos/gaia/v26/x/liquid/keeper"
4040
liquidtypes "github.com/cosmos/gaia/v26/x/liquid/types"
41+
42+
"github.com/cosmos/tokenfactory/x/tokenfactory"
43+
tokenfactorykeeper "github.com/cosmos/tokenfactory/x/tokenfactory/keeper"
44+
tokenfactorytypes "github.com/cosmos/tokenfactory/x/tokenfactory/types"
4145
)
4246

4347
type fixture struct {
@@ -52,12 +56,13 @@ type fixture struct {
5256
distributionKeeper distributionkeeper.Keeper
5357
stakingKeeper *stakingkeeper.Keeper
5458
liquidKeeper *liquidkeeper.Keeper
59+
tokenFactoryKeeper tokenfactorykeeper.Keeper
5560
}
5661

5762
func initFixture(tb testing.TB) *fixture {
5863
tb.Helper()
5964
keys := storetypes.NewKVStoreKeys(
60-
authtypes.StoreKey, banktypes.StoreKey, distributiontypes.StoreKey, stakingtypes.StoreKey, liquidtypes.StoreKey,
65+
authtypes.StoreKey, banktypes.StoreKey, distributiontypes.StoreKey, stakingtypes.StoreKey, liquidtypes.StoreKey, tokenfactorytypes.StoreKey,
6166
)
6267
cdc := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}, staking.AppModuleBasic{}, vesting.AppModuleBasic{}).Codec
6368

@@ -74,6 +79,7 @@ func initFixture(tb testing.TB) *fixture {
7479
stakingtypes.ModuleName: {authtypes.Minter},
7580
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
7681
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
82+
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
7783
}
7884

7985
accountKeeper := authkeeper.NewAccountKeeper(
@@ -106,19 +112,32 @@ func initFixture(tb testing.TB) *fixture {
106112
liquidKeeper := liquidkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[liquidtypes.StoreKey]), accountKeeper,
107113
bankKeeper, stakingKeeper, distributionKeeper, authority.String())
108114

115+
tokenFactoryKeeper := tokenfactorykeeper.NewKeeper(
116+
cdc,
117+
keys[tokenfactorytypes.StoreKey],
118+
maccPerms,
119+
accountKeeper,
120+
bankKeeper,
121+
distributionKeeper,
122+
[]string{tokenfactorytypes.EnableSetMetadata, tokenfactorytypes.EnableCommunityPoolFeeFunding},
123+
authority.String(),
124+
)
125+
109126
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil)
110127
bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil)
111128
stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil)
112129
distributionModule := distribution.NewAppModule(cdc, distributionKeeper, accountKeeper, bankKeeper,
113130
stakingKeeper, nil)
114131
liquidModule := liquid.NewAppModule(cdc, liquidKeeper, accountKeeper, bankKeeper, stakingKeeper)
132+
tokenFactoryModule := tokenfactory.NewAppModule(tokenFactoryKeeper, accountKeeper, bankKeeper, nil)
115133

116134
integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{
117135
authtypes.ModuleName: authModule,
118136
banktypes.ModuleName: bankModule,
119137
distributiontypes.ModuleName: distributionModule,
120138
stakingtypes.ModuleName: stakingModule,
121139
liquidtypes.ModuleName: liquidModule,
140+
tokenfactorytypes.ModuleName: tokenFactoryModule,
122141
})
123142

124143
sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())
@@ -141,6 +160,14 @@ func initFixture(tb testing.TB) *fixture {
141160
// set default liquid params
142161
require.NoError(tb, liquidKeeper.SetParams(sdkCtx, liquidtypes.DefaultParams()))
143162

163+
// Register tokenfactory MsgServer and QueryServer
164+
tokenfactorytypes.RegisterMsgServer(integrationApp.MsgServiceRouter(), tokenfactorykeeper.NewMsgServerImpl(tokenFactoryKeeper))
165+
tokenfactorytypes.RegisterQueryServer(integrationApp.QueryHelper(), tokenFactoryKeeper)
166+
167+
// Set default tokenfactory params
168+
err := tokenFactoryKeeper.SetParams(sdkCtx, tokenfactorytypes.DefaultParams())
169+
require.NoError(tb, err)
170+
144171
f := fixture{
145172
app: integrationApp,
146173
sdkCtx: sdkCtx,
@@ -151,6 +178,7 @@ func initFixture(tb testing.TB) *fixture {
151178
distributionKeeper: distributionKeeper,
152179
stakingKeeper: stakingKeeper,
153180
liquidKeeper: liquidKeeper,
181+
tokenFactoryKeeper: tokenFactoryKeeper,
154182
}
155183

156184
return &f

0 commit comments

Comments
 (0)