Skip to content
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

Refactor TestGetNodeHeight #1545

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

AryanGodara
Copy link
Contributor

@AryanGodara AryanGodara commented Feb 13, 2024

Overview

I've refactored the testcases in TestGetNodeHeight into a struct-list format for a cleaner testing interface. And taken out the SetDalc pattern, repeated in the codes, out to a separate helper function.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • Refactor
    • Improved the setup process for integration tests by introducing a centralized method for node creation and configuration.
    • Optimized test code by consolidating repetitive setup tasks and enhancing the clarity of height retrieval tests.

Copy link
Contributor

coderabbitai bot commented Feb 13, 2024

Warning

Rate Limit Exceeded

@Manav-Aggarwal has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 10 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 9f3cb92 and a007130.

Walkthrough

This update focuses on enhancing the test infrastructure for a node system by introducing a unified approach to node creation and configuration. The main goal is to simplify the test setup and make the codebase more maintainable by reducing redundancy and consolidating common setup tasks into single, reusable functions.

Changes

File Path Change Summary
node/full_node_integration_test.go Introduced createAndConfigureNode for streamlined node setup.
node/helpers_test.go Replaced createNode with createAndConfigureNode; refactored height retrieval tests; removed redundant dalc settings.

Related issues

  • Issue Future Test Refactoring #985 from the rollkit repository could be linked to this PR. The changes in this PR, particularly the refactoring for test setup consolidation, align with the objectives of streamlining test helpers and patterns, which is mentioned as a future goal in the issue.

🐰✨
In the land of code where tests do roam,
A rabbit hopped, making a home.
With a flick and a twist, and a clever mind,
It tidied up tests, leaving clutter behind.

"To refactor, to clean," it merrily said,
As it streamlined the code, then off to bed.
🌙💤

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c9d8467) 50.23% compared to head (a007130) 52.01%.
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
+ Coverage   50.23%   52.01%   +1.77%     
==========================================
  Files          52       52              
  Lines        6762     5516    -1246     
==========================================
- Hits         3397     2869     -528     
+ Misses       3024     2321     -703     
+ Partials      341      326      -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR still includes the commit which has the start stop logic changes.
either we should mark this PR as draft and dependent on #1544 or we should remove that commit and just review the changes to TestGetNodeHeight

@AryanGodara
Copy link
Contributor Author

this PR still includes the commit which has the start stop logic changes. either we should mark this PR as draft and dependent on #1544 or we should remove that commit and just review the changes to TestGetNodeHeight

I created this branch on top of #1544 branch, to avoid rebase conflicts later on 😅 . Poor choice on my part. I'll remove that first commit, and push only relevant changes here.

@MSevey
Copy link
Contributor

MSevey commented Feb 13, 2024

this PR still includes the commit which has the start stop logic changes. either we should mark this PR as draft and dependent on #1544 or we should remove that commit and just review the changes to TestGetNodeHeight

I created this branch on top of #1544 branch, to avoid rebase conflicts later on 😅 . Poor choice on my part. I'll remove that first commit, and push only relevant changes here.

makes sense. since the changes can be pretty cleanly separated I don't suspect there to be much in terms of conflict.
Also keeping them fully separate ends up being faster even with conflicts because you naturally bottleneck to the true constraint as opposed to the imposed constraint of whichever the first change is.

looks good now!

@MSevey
Copy link
Contributor

MSevey commented Feb 13, 2024

There might be an unrelated flaky test https://github.com/rollkit/rollkit/actions/runs/7891260736/job/21536776255?pr=1545#step:4:2712

cc @Manav-Aggarwal have we seen this one yet?

EDIT:
I ran it locally in a loop and it doesn't fail, restarting the job.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 013a055 and 5da92ad.
Files selected for processing (2)
  • node/full_node_integration_test.go (3 hunks)
  • node/helpers_test.go (2 hunks)
Additional comments: 4
node/helpers_test.go (2)
  • 48-48: The function createAndConfigureNode is used here but its definition or modification is not visible within this file. Ensure its implementation correctly handles the new dalc parameter and other setup logic as intended.
  • 60-84: Refactoring test cases into a loop over different cases improves readability and maintainability. Ensure that each test case is independent and does not affect the others due to shared state or side effects.
node/full_node_integration_test.go (2)
  • 548-549: Usage of createAndConfigureNode in test setup is consistent with the objective to streamline node creation and configuration. Verify that the dalc parameter is correctly utilized within this function to configure the nodes as intended.
  • 723-730: The implementation of createAndConfigureNode is provided here. Ensure that this function correctly encapsulates the creation and configuration logic, including setting the dalc for both the FullNode and its blockManager.

@Manav-Aggarwal
Copy link
Member

https://github.com/rollkit/rollkit/actions/runs/7891260736/job/21536776255?pr=1545#step:4:2712

This was a flaky test on main that was reverted: #1521, so rebasing should fix it.

@Manav-Aggarwal Manav-Aggarwal added this pull request to the merge queue Feb 16, 2024
Merged via the queue into rollkit:main with commit 8736541 Feb 16, 2024
17 checks passed
@AryanGodara AryanGodara deleted the refactor-TestGetNodeHeight branch February 16, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants