diff --git a/.changelog/unreleased/bug-fixes/3346-fix-broken-invariants-submission.md b/.changelog/unreleased/bug-fixes/3346-fix-broken-invariants-submission.md new file mode 100644 index 00000000000..142518c034d --- /dev/null +++ b/.changelog/unreleased/bug-fixes/3346-fix-broken-invariants-submission.md @@ -0,0 +1,2 @@ +- Fix submission of broken invariants + ([\#3346](https://github.com/cosmos/gaia/pull/3346)) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a1e3310b64b..54993a96ac8 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -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, @@ -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, diff --git a/tests/integration/interchain_security_test.go b/tests/integration/interchain_security_test.go index 2c0797216d8..f835538bda1 100644 --- a/tests/integration/interchain_security_test.go +++ b/tests/integration/interchain_security_test.go @@ -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" @@ -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`