Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 9, 2022
1 parent 884abbf commit 6eead9b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
30 changes: 15 additions & 15 deletions testing/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func ParseClientIDFromEvents(events sdk.Events) (string, error) {
for _, ev := range events {
if ev.Type == clienttypes.EventTypeCreateClient {
for _, attr := range ev.Attributes {
if string(attr.Key) == clienttypes.AttributeKeyClientID {
return string(attr.Value), nil
if attr.Key == clienttypes.AttributeKeyClientID {
return attr.Value, nil
}
}
}
Expand All @@ -33,8 +33,8 @@ func ParseConnectionIDFromEvents(events sdk.Events) (string, error) {
if ev.Type == connectiontypes.EventTypeConnectionOpenInit ||
ev.Type == connectiontypes.EventTypeConnectionOpenTry {
for _, attr := range ev.Attributes {
if string(attr.Key) == connectiontypes.AttributeKeyConnectionID {
return string(attr.Value), nil
if attr.Key == connectiontypes.AttributeKeyConnectionID {
return attr.Value, nil
}
}
}
Expand All @@ -48,8 +48,8 @@ func ParseChannelIDFromEvents(events sdk.Events) (string, error) {
for _, ev := range events {
if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry {
for _, attr := range ev.Attributes {
if string(attr.Key) == channeltypes.AttributeKeyChannelID {
return string(attr.Value), nil
if attr.Key == channeltypes.AttributeKeyChannelID {
return attr.Value, nil
}
}
}
Expand All @@ -64,40 +64,40 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) {
if ev.Type == channeltypes.EventTypeSendPacket {
packet := channeltypes.Packet{}
for _, attr := range ev.Attributes {
switch string(attr.Key) {
switch attr.Key {
case channeltypes.AttributeKeyData: //nolint:staticcheck // DEPRECATED
packet.Data = []byte(attr.Value)

case channeltypes.AttributeKeySequence:
seq, err := strconv.ParseUint(string(attr.Value), 10, 64)
seq, err := strconv.ParseUint(attr.Value, 10, 64)
if err != nil {
return channeltypes.Packet{}, err
}

packet.Sequence = seq

case channeltypes.AttributeKeySrcPort:
packet.SourcePort = string(attr.Value)
packet.SourcePort = attr.Value

case channeltypes.AttributeKeySrcChannel:
packet.SourceChannel = string(attr.Value)
packet.SourceChannel = attr.Value

case channeltypes.AttributeKeyDstPort:
packet.DestinationPort = string(attr.Value)
packet.DestinationPort = attr.Value

case channeltypes.AttributeKeyDstChannel:
packet.DestinationChannel = string(attr.Value)
packet.DestinationChannel = attr.Value

case channeltypes.AttributeKeyTimeoutHeight:
height, err := clienttypes.ParseHeight(string(attr.Value))
height, err := clienttypes.ParseHeight(attr.Value)
if err != nil {
return channeltypes.Packet{}, err
}

packet.TimeoutHeight = height

case channeltypes.AttributeKeyTimeoutTimestamp:
timestamp, err := strconv.ParseUint(string(attr.Value), 10, 64)
timestamp, err := strconv.ParseUint(attr.Value, 10, 64)
if err != nil {
return channeltypes.Packet{}, err
}
Expand All @@ -121,7 +121,7 @@ func ParseAckFromEvents(events sdk.Events) ([]byte, error) {
for _, ev := range events {
if ev.Type == channeltypes.EventTypeWriteAck {
for _, attr := range ev.Attributes {
if string(attr.Key) == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // DEPRECATED
return []byte(attr.Value), nil
}
}
Expand Down
37 changes: 22 additions & 15 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
Expand Down Expand Up @@ -163,6 +164,7 @@ var (
authzmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
ibcfee.AppModuleBasic{},
consensus.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -273,7 +275,7 @@ func NewSimApp(
bApp.SetInterfaceRegistry(interfaceRegistry)

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

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

// set the BaseApp's parameter store
// set the BaseApp's parameter store
app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())
bApp.SetParamStore(&app.ConsensusParamsKeeper)
Expand Down Expand Up @@ -327,11 +328,15 @@ func NewSimApp(
BlockedAddresses(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
stakingKeeper := stakingkeeper.NewKeeper(

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], stakingKeeper,
appCodec, keys[minttypes.StoreKey], app.StakingKeeper,
app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

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

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()),
)

app.CrisisKeeper = crisiskeeper.NewKeeper(appCodec, keys[crisistypes.StoreKey], invCheckPeriod,
app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())

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

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper)

// IBC Keepers
Expand All @@ -375,7 +380,7 @@ func NewSimApp(
*/
govKeeper := govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.AccountKeeper, app.BankKeeper,
stakingKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.StakingKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.GovKeeper = *govKeeper.SetHooks(
Expand Down Expand Up @@ -539,11 +544,13 @@ func NewSimApp(
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
upgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),

// IBC modules
ibc.NewAppModule(app.IBCKeeper),
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
Expand All @@ -559,13 +566,13 @@ func NewSimApp(
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, authtypes.ModuleName,
banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, feegrant.ModuleName,
paramstypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName,
paramstypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName, consensusparamtypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName,
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName,
upgradetypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName,
upgradetypes.ModuleName, vestingtypes.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, ibcmock.ModuleName, group.ModuleName, consensusparamtypes.ModuleName,
)

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

app.mm.RegisterInvariants(app.CrisisKeeper)
Expand Down

0 comments on commit 6eead9b

Please sign in to comment.