-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(systemtest): Fix prune
& gov
test
#22190
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request enhance the testing of governance proposals in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
tests/systemtests/snapshots_test.go (1)
92-92
: LGTM! Consider adding a comment for clarity.The update to use
--store.keep-recent=1
for app version 2 is correct and aligns with the PR objectives. This change maintains the test's functionality while adapting to the new command structure.Consider adding a brief comment explaining the difference in command structure between v1 and v2, for better maintainability:
if isV2() { // App v2 uses a nested flag structure for store commands command = []string{"store", "prune", "--store.keep-recent=1"} } else { // App v1 uses a simpler command structure command = []string{"prune", "everything"} }
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (1)
- tests/systemtests/snapshots_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/snapshots_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
Could you fix the other issue maybe too? @hieuvubk :) |
tests/systemtests/system.go
Outdated
genesisBz, err = sjson.SetRawBytes(genesisBz, "app_state.gov.params.voting_period", []byte(fmt.Sprintf(`"%s"`, "8s"))) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to set regular voting period: %s", err)) | ||
} | ||
// update expedited voting period to avoid validation error | ||
genesisBz, err = sjson.SetRawBytes(genesisBz, "app_state.gov.params.expedited_voting_period", []byte(fmt.Sprintf(`"%s"`, "7s"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hieuvubk Can you move this too to gov_test.go? This was added due to voting_period change earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
tests/systemtests/gov_test.go (2)
378-379
: LGTM! Consider adding a constant for the voting period.The addition of a short voting period enhances the test efficiency. It allows for faster execution while still covering the full lifecycle of a proposal's deposits.
Consider defining a constant for the voting period (8 seconds) at the package level for better maintainability:
const testVotingPeriod = 8 * time.Second // Then use it in the test: sut.ModifyGenesisJSON(t, SetGovVotingPeriod(t, testVotingPeriod))
Line range hint
380-424
: LGTM! Consider adding comments for test stages.The test comprehensively covers the deposit lifecycle, including initial deposit verification and post-voting period clearing. The use of gjson for parsing JSON responses is consistent with other tests in the file.
To improve readability, consider adding comments to clearly delineate the stages of the test:
// Submit a new proposal proposalArgs := []string{ // ... (existing code) } // ... (existing code) // Query initial deposit resp := cli.CustomQuery("q", "gov", "deposit", "1", valAddr) // ... (existing code) // Wait for voting period to end time.Sleep(time.Second * 8) // Query deposits after voting period resp = cli.CustomQuery("q", "gov", "deposits", "1") // ... (existing code)
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (2)
- tests/systemtests/gov_test.go (1 hunks)
- tests/systemtests/system.go (0 hunks)
💤 Files with no reviewable changes (1)
- tests/systemtests/system.go
🧰 Additional context used
📓 Path-based instructions (1)
tests/systemtests/gov_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
🔇 Additional comments (1)
tests/systemtests/gov_test.go (1)
Line range hint
1-424
: Overall improvements to governance testingThe changes in this file enhance the testing of the governance module, particularly in the
TestQueryDeposit
function. The addition of a short voting period and the verification of deposit clearing after the voting period ends contribute to more comprehensive test coverage.These modifications align well with the PR objectives and maintain consistency with the existing code style and testing practices. The improved tests will help ensure the robustness of the governance functionality.
Prune
testprune
& gov
test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
tests/systemtests/gov_test.go (2)
378-384
: LGTM! Consider clarifying the comment.The addition of short voting periods for testing purposes is a good approach to speed up test execution. The implementation correctly sets the expedited voting period shorter than the regular voting period.
Consider clarifying the comment on line 379 to explain why the expedited voting period needs to be updated. For example:
- // update expedited voting period to avoid validation error + // update expedited voting period to be shorter than the regular voting period, avoiding a validation error
Line range hint
376-431
: LGTM! Consider adding a tolerance to the waiting period.The changes to
TestQueryDeposit
effectively test the deposit lifecycle with a shortened voting period. The test structure is well-organized and covers important aspects of governance proposal deposits.To improve test robustness, consider adding a small tolerance to the waiting period. Instead of a fixed sleep, you could use a loop with a timeout:
maxWaitTime := time.Second * 10 startTime := time.Now() for { resp = cli.CustomQuery("q", "gov", "deposits", "1") deposits = gjson.Get(resp, "deposits").Array() if len(deposits) == 0 || time.Since(startTime) > maxWaitTime { break } time.Sleep(time.Millisecond * 500) } require.Equal(t, len(deposits), 0, "Deposits should be cleared after voting period")This approach would make the test more resilient to potential timing issues while still maintaining a maximum execution time.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (3)
- tests/systemtests/genesis_io.go (1 hunks)
- tests/systemtests/gov_test.go (1 hunks)
- tests/systemtests/system.go (0 hunks)
💤 Files with no reviewable changes (1)
- tests/systemtests/system.go
🧰 Additional context used
📓 Path-based instructions (2)
tests/systemtests/genesis_io.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"tests/systemtests/gov_test.go (3)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*
: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"
🔇 Additional comments (1)
tests/systemtests/genesis_io.go (1)
36-43
: LGTM! Well-structured and consistent with existing code.The new
SetGovExpeditedVotingPeriod
function is well-implemented and follows good practices:
- It uses
t.Helper()
to mark it as a test helper function.- Error handling is appropriate for test code with
require.NoError
.- The function is concise and maintains consistency with the existing
SetGovVotingPeriod
function.- It provides good test coverage for the new expedited voting period feature.
The implementation adheres to the Uber Golang style guide and test code guidelines.
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
Description
Closes: #XXXX
Update flag
keep-recent
=>store.keep-recent
for appv2. Will fix main & v0.52Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
Bug Fixes
Tests