test: poa cover staking hook error propagation in MsgServer remove#142
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThese changes refactor test infrastructure for the POA keeper by extracting a test-local authority constant, removing a redundant helper function, and refactoring test cases to supply per-test-case mock setup callbacks for staking and bank keepers. Hook error handling and log assertions are added to remove validator tests. ChangesPOA Keeper Test Infrastructure Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.1)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
test: poa cover staking hook error propagation in MsgServer remove
Motivation 💡
The shared
poaKeeperTestSetupfixture inx/poa/keeper/keeper_test.goconfiguredMockStakingHookswith.AnyTimes()matchers that always returnednil.TestMsgServer_AddValidatorandTestMsgServer_RemoveValidatorreused this fixture, so their "should pass" cases never exercised theBeforeValidatorModifiedorBeforeValidatorSlashederror paths at the MsgServer layer. If a future change silently dropped hook errors during validator removal, the existing suite would not catch it.Changes 🛠
poaKeeperTestSetupfixture fromkeeper_test.go.poaAuthorityconstant intocommon_test.gofor reuse across tests.TestMsgServer_AddValidatorandTestMsgServer_RemoveValidatorto declare per-casestakingMocks/bankMocksclosures and build the keeper viasetupPoaKeeper, so each case owns its own expectations.BeforeValidatorModifiedreturning an error -> log contains"failed to call before validator modified hook",RemoveValidatorstill succeeds.BeforeValidatorSlashedreturning an error -> log contains"failed to call before validator slashed hook",RemoveValidatorstill succeeds.cosmossdk.io/logJSON logger into abytes.Bufferand asserted substring presence withrequire.Contains.Considerations 🤔
keeper.ExecuteRemoveValidator: hook errors are logged viak.Logger(ctx).Error(...)and execution continues. If the policy changes to propagate hook errors, both new cases must be updated.Summary by CodeRabbit