Skip to content

Commit

Permalink
fix: submission of broken invariants (#3346)
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell authored Sep 18, 2024
1 parent b09f2b6 commit 420ac1e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix submission of broken invariants
([\#3346](https://github.com/cosmos/gaia/pull/3346))
20 changes: 10 additions & 10 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,6 @@ func NewAppKeeper(
// their scoped modules in `NewApp` with `ScopeToModule`
appKeepers.CapabilityKeeper.Seal()

appKeepers.CrisisKeeper = crisiskeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[crisistypes.StoreKey]),
invCheckPeriod,
appKeepers.BankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.AccountKeeper.AddressCodec(),
)

// Add normal keepers
appKeepers.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec,
Expand All @@ -231,6 +221,16 @@ func NewAppKeeper(
logger,
)

appKeepers.CrisisKeeper = crisiskeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[crisistypes.StoreKey]),
invCheckPeriod,
appKeepers.BankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.AccountKeeper.AddressCodec(),
)

appKeepers.AuthzKeeper = authzkeeper.NewKeeper(
runtime.NewKVStoreService(appKeepers.keys[authzkeeper.StoreKey]),
appCodec,
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/interchain_security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
crysistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/cosmos/gaia/v20/ante"
Expand All @@ -38,6 +39,29 @@ func TestCCVTestSuite(t *testing.T) {
suite.Run(t, ccvSuite)
}

// TestVerifyInvariant checks the integration of the crisis module by
// sending a message to verify an invariant
func TestVerifyInvariant(t *testing.T) {
ccvSuite.SetT(t)
ccvSuite.SetupTest()

delAddr := ccvSuite.GetProviderChain().SenderAccount.GetAddress()
msg := crysistypes.MsgVerifyInvariant{
Sender: delAddr.String(),
InvariantModuleName: "gov",
InvariantRoute: "module-account",
}

var err error
var resp *crysistypes.MsgVerifyInvariantResponse
provCtx := ccvSuite.GetProviderChain().GetContext()
require.NotPanics(t, func() {
resp, err = app.CrisisKeeper.VerifyInvariant(provCtx, &msg)
})
require.NoError(t, err, "verify invariant returned an error")
require.NotNil(t, resp, "verify invariant returned an invalid response")
}

func TestICSEpochs(t *testing.T) {
// a bit hacky but cannot be called
// in SetupTest() since it requires `t`
Expand Down

0 comments on commit 420ac1e

Please sign in to comment.