Skip to content

Commit 6eead9b

Browse files
committed
updates
1 parent 884abbf commit 6eead9b

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

testing/events.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func ParseClientIDFromEvents(events sdk.Events) (string, error) {
1717
for _, ev := range events {
1818
if ev.Type == clienttypes.EventTypeCreateClient {
1919
for _, attr := range ev.Attributes {
20-
if string(attr.Key) == clienttypes.AttributeKeyClientID {
21-
return string(attr.Value), nil
20+
if attr.Key == clienttypes.AttributeKeyClientID {
21+
return attr.Value, nil
2222
}
2323
}
2424
}
@@ -33,8 +33,8 @@ func ParseConnectionIDFromEvents(events sdk.Events) (string, error) {
3333
if ev.Type == connectiontypes.EventTypeConnectionOpenInit ||
3434
ev.Type == connectiontypes.EventTypeConnectionOpenTry {
3535
for _, attr := range ev.Attributes {
36-
if string(attr.Key) == connectiontypes.AttributeKeyConnectionID {
37-
return string(attr.Value), nil
36+
if attr.Key == connectiontypes.AttributeKeyConnectionID {
37+
return attr.Value, nil
3838
}
3939
}
4040
}
@@ -48,8 +48,8 @@ func ParseChannelIDFromEvents(events sdk.Events) (string, error) {
4848
for _, ev := range events {
4949
if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry {
5050
for _, attr := range ev.Attributes {
51-
if string(attr.Key) == channeltypes.AttributeKeyChannelID {
52-
return string(attr.Value), nil
51+
if attr.Key == channeltypes.AttributeKeyChannelID {
52+
return attr.Value, nil
5353
}
5454
}
5555
}
@@ -64,40 +64,40 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) {
6464
if ev.Type == channeltypes.EventTypeSendPacket {
6565
packet := channeltypes.Packet{}
6666
for _, attr := range ev.Attributes {
67-
switch string(attr.Key) {
67+
switch attr.Key {
6868
case channeltypes.AttributeKeyData: //nolint:staticcheck // DEPRECATED
6969
packet.Data = []byte(attr.Value)
7070

7171
case channeltypes.AttributeKeySequence:
72-
seq, err := strconv.ParseUint(string(attr.Value), 10, 64)
72+
seq, err := strconv.ParseUint(attr.Value, 10, 64)
7373
if err != nil {
7474
return channeltypes.Packet{}, err
7575
}
7676

7777
packet.Sequence = seq
7878

7979
case channeltypes.AttributeKeySrcPort:
80-
packet.SourcePort = string(attr.Value)
80+
packet.SourcePort = attr.Value
8181

8282
case channeltypes.AttributeKeySrcChannel:
83-
packet.SourceChannel = string(attr.Value)
83+
packet.SourceChannel = attr.Value
8484

8585
case channeltypes.AttributeKeyDstPort:
86-
packet.DestinationPort = string(attr.Value)
86+
packet.DestinationPort = attr.Value
8787

8888
case channeltypes.AttributeKeyDstChannel:
89-
packet.DestinationChannel = string(attr.Value)
89+
packet.DestinationChannel = attr.Value
9090

9191
case channeltypes.AttributeKeyTimeoutHeight:
92-
height, err := clienttypes.ParseHeight(string(attr.Value))
92+
height, err := clienttypes.ParseHeight(attr.Value)
9393
if err != nil {
9494
return channeltypes.Packet{}, err
9595
}
9696

9797
packet.TimeoutHeight = height
9898

9999
case channeltypes.AttributeKeyTimeoutTimestamp:
100-
timestamp, err := strconv.ParseUint(string(attr.Value), 10, 64)
100+
timestamp, err := strconv.ParseUint(attr.Value, 10, 64)
101101
if err != nil {
102102
return channeltypes.Packet{}, err
103103
}
@@ -121,7 +121,7 @@ func ParseAckFromEvents(events sdk.Events) ([]byte, error) {
121121
for _, ev := range events {
122122
if ev.Type == channeltypes.EventTypeWriteAck {
123123
for _, attr := range ev.Attributes {
124-
if string(attr.Key) == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
124+
if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
125125
return []byte(attr.Value), nil
126126
}
127127
}

testing/simapp/app.go

+22-15
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/cosmos/cosmos-sdk/x/capability"
4040
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
4141
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
42+
"github.com/cosmos/cosmos-sdk/x/consensus"
4243
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
4344
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
4445
"github.com/cosmos/cosmos-sdk/x/crisis"
@@ -163,6 +164,7 @@ var (
163164
authzmodule.AppModuleBasic{},
164165
vesting.AppModuleBasic{},
165166
ibcfee.AppModuleBasic{},
167+
consensus.AppModuleBasic{},
166168
)
167169

168170
// module account permissions
@@ -273,7 +275,7 @@ func NewSimApp(
273275
bApp.SetInterfaceRegistry(interfaceRegistry)
274276

275277
keys := sdk.NewKVStoreKeys(
276-
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
278+
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
277279
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
278280
govtypes.StoreKey, group.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
279281
evidencetypes.StoreKey, ibctransfertypes.StoreKey, icacontrollertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey,
@@ -295,7 +297,6 @@ func NewSimApp(
295297

296298
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
297299

298-
// set the BaseApp's parameter store
299300
// set the BaseApp's parameter store
300301
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
301302
bApp.SetParamStore(&app.ConsensusParamsKeeper)
@@ -327,11 +328,15 @@ func NewSimApp(
327328
BlockedAddresses(),
328329
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
329330
)
330-
stakingKeeper := stakingkeeper.NewKeeper(
331+
332+
// register the staking hooks
333+
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
334+
app.StakingKeeper = stakingkeeper.NewKeeper(
331335
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
332336
)
337+
333338
app.MintKeeper = mintkeeper.NewKeeper(
334-
appCodec, keys[minttypes.StoreKey], stakingKeeper,
339+
appCodec, keys[minttypes.StoreKey], app.StakingKeeper,
335340
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
336341
)
337342

@@ -341,18 +346,18 @@ func NewSimApp(
341346
appCodec, legacyAmino, keys[slashingtypes.StoreKey], app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
342347
)
343348

349+
// register the staking hooks
350+
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
351+
app.StakingKeeper.SetHooks(
352+
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
353+
)
354+
344355
app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, keys[crisistypes.StoreKey], invCheckPeriod,
345356
app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
346357

347358
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
348359
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
349360

350-
// register the staking hooks
351-
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
352-
app.StakingKeeper = stakingkeeper.NewKeeper(
353-
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
354-
)
355-
356361
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper)
357362

358363
// IBC Keepers
@@ -375,7 +380,7 @@ func NewSimApp(
375380
*/
376381
govKeeper := govkeeper.NewKeeper(
377382
appCodec, keys[govtypes.StoreKey], app.AccountKeeper, app.BankKeeper,
378-
stakingKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
383+
app.StakingKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
379384
)
380385

381386
app.GovKeeper = *govKeeper.SetHooks(
@@ -539,11 +544,13 @@ func NewSimApp(
539544
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
540545
upgrade.NewAppModule(app.UpgradeKeeper),
541546
evidence.NewAppModule(app.EvidenceKeeper),
542-
ibc.NewAppModule(app.IBCKeeper),
543547
params.NewAppModule(app.ParamsKeeper),
544548
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
549+
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
550+
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
545551

546552
// IBC modules
553+
ibc.NewAppModule(app.IBCKeeper),
547554
transfer.NewAppModule(app.TransferKeeper),
548555
ibcfee.NewAppModule(app.IBCFeeKeeper),
549556
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
@@ -559,13 +566,13 @@ func NewSimApp(
559566
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
560567
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, authtypes.ModuleName,
561568
banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName,
562-
paramstypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName,
569+
paramstypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName, consensusparamtypes.ModuleName,
563570
)
564571
app.mm.SetOrderEndBlockers(
565572
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName,
566573
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
567574
minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName,
568-
upgradetypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName,
575+
upgradetypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName, consensusparamtypes.ModuleName,
569576
)
570577

571578
// NOTE: The genutils module must occur after staking so that pools are
@@ -578,7 +585,7 @@ func NewSimApp(
578585
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
579586
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, ibctransfertypes.ModuleName,
580587
icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName,
581-
vestingtypes.ModuleName, group.ModuleName,
588+
vestingtypes.ModuleName, group.ModuleName, consensusparamtypes.ModuleName,
582589
)
583590

584591
app.mm.RegisterInvariants(app.CrisisKeeper)

0 commit comments

Comments
 (0)