test(x/gov): expand genesis InitGenesis/ExportGenesis coverage#26354
Open
isotauon wants to merge 7 commits intocosmos:mainfrom
Open
test(x/gov): expand genesis InitGenesis/ExportGenesis coverage#26354isotauon wants to merge 7 commits intocosmos:mainfrom
isotauon wants to merge 7 commits intocosmos:mainfrom
Conversation
The proposal_messages event attribute was being built by prepending a comma to each message type URL inside the loop, producing values like ",/cosmos.bank.v1beta1.MsgSend,/cosmos.staking.v1beta1.MsgDelegate" instead of the intended comma-separated list. This broke downstream consumers that split the attribute on commas. Replace the manual accumulator with strings.Join over a []string of type URLs, and add a regression test that asserts the emitted attribute has no leading comma. Closes: cosmos#26045
Add two tests for the gov keeper's genesis handling: - TestInitGenesis_PanicsWhenDistrCancelDestSetWithoutDistrKeeper exercises the guard added in cosmos#25616 that requires a non-nil distribution keeper whenever the distribution module address is configured as the proposal cancel destination. - TestInitGenesis_RoundTripProposalsAndVotes verifies that proposals in both deposit and voting period statuses, plus a vote, survive an InitGenesis -> ExportGenesis round-trip. To support constructing a fresh keeper with a nil distribution keeper in the first test, setupGovKeeper now also returns the KVStoreService it built. All in-package callers pass an extra blank identifier. Closes: cosmos#25618
Contributor
|
PR author is not in the allowed authors list. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26354 +/- ##
==========================================
- Coverage 64.87% 64.86% -0.02%
==========================================
Files 890 874 -16
Lines 58583 57601 -982
==========================================
- Hits 38008 37365 -643
+ Misses 20575 20236 -339
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes: #25618
Adds two tests to
x/gov/keeper/genesis_test.go, addressing the follow-up @aljo242 left on PR #25616:TestInitGenesis_PanicsWhenDistrCancelDestSetWithoutDistrKeeper— exercises the guard added in refactor!(gov): make distribution keeper optional #25616 (x/gov/keeper/genesis.go:22-24) that requires a non-nil distribution keeper whenever the distribution module address is configured as the proposal cancel destination. Usesrequire.PanicsWithValueto assert the exact panic message.TestInitGenesis_RoundTripProposalsAndVotes— populates the genesis state with proposals in bothStatusDepositPeriodandStatusVotingPeriodplus a vote, callsInitGenesis, thenExportGenesis, and verifies that the constitution, starting proposal id, both proposals (with statuses preserved) and the vote round-trip correctly. The pre-existingTestImportExportQueues_ErrorInconsistentStateonly round-tripped a default genesis, which left both branches of theproposal.Statusswitch and the votes-export path uncovered.Helper change
To construct a separate keeper with a nil distribution keeper in the first test (the field is unexported and must be set via
NewKeeper),setupGovKeepernow also returns theKVStoreServiceit built. All eight in-package callers acrosskeeper_test.go,deposit_test.go,hooks_test.go,tally_test.go, andvote_test.gopass an extra blank identifier.No production code is changed; this is test-only, so no CHANGELOG entry is added.