Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

test: mock node rpc service #45

Merged
merged 7 commits into from
Jan 9, 2024
Merged

test: mock node rpc service #45

merged 7 commits into from
Jan 9, 2024

Conversation

tuxcanfly
Copy link
Collaborator

@tuxcanfly tuxcanfly commented Jan 9, 2024

Overview

This PR adds unit test coverage.

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

  • New Features
    • Introduced a mock implementation for the blob API and node RPC service.
    • Added a new command-line application to run test daemons with graceful shutdown capabilities.

Copy link

coderabbitai bot commented Jan 9, 2024

Walkthrough

The project has undergone a significant update to enhance its testing capabilities. The changes include the establishment of context and new package imports, the creation and removal of test setups, and the expansion of test cases in the celestia_test.go file. Additionally, the introduction of a mock implementation for both the blob API and the node RPC service is seen in mock.go. A new command-line application, test-da, has been added for testing the daemon with signal handling and error logging.

Changes

File Path Change Summary
celestia/celestia_test.go Added context import, new package imports, setup/teardown functions, and expanded test cases.
celestia/mock.go Introduced mock implementations for the blob API and node RPC service.
cmd/test-da/main.go Created new main.go for test-da command with Cobra setup, signal handling, and execution flow.

Poem

🐇 Oh hop and code, through fields we rove,
🌟 Where tests and mocks, in harmony move.
🚀 To the daemons we bid, "Be stout and brave,"
📜 For in the green terminal, they shall behave.

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 Jan 9, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (5069c00) 0.00% compared to head (a12df66) 71.52%.

Files Patch % Lines
celestia/mock.go 79.06% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main      #45       +/-   ##
==========================================
+ Coverage   0.00%   71.52%   +71.52%     
==========================================
  Files          1        2        +1     
  Lines        101      144       +43     
==========================================
+ Hits           0      103      +103     
+ Misses       101       28       -73     
- Partials       0       13       +13     

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

@tuxcanfly tuxcanfly marked this pull request as ready for review January 9, 2024 07:29
Copy link

@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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5069c00 and e41a5b2.
Files selected for processing (3)
  • celestia/celestia_test.go (1 hunks)
  • celestia/mock.go (1 hunks)
  • cmd/test-da/main.go (1 hunks)
Additional comments: 6
cmd/test-da/main.go (2)
  • 18-36: The Cobra command setup looks correct and follows standard practices for defining a CLI application with Cobra. The use of cobra.NoArgs ensures that the command does not accept any positional arguments, which is appropriate for this command's behavior.

The signal handling logic is also implemented correctly, capturing os.Interrupt and syscall.SIGTERM to allow for a graceful shutdown of the application.

  • 44-48: The error handling in the main function is appropriate. It checks if the run function returns an error and logs it before exiting with a non-zero status code. This is a good practice as it provides clear feedback when the application encounters an error.
celestia/mock.go (2)
  • 14-22: The Submit method in the MockBlobAPI struct correctly increments the height and returns it. This simulates the behavior of a real blob API that would return a new height after submitting blobs.

  • 61-70: The MockService struct and its Close method are implemented correctly. The Close method ensures that resources are released when the mock service is no longer needed, which is good practice for avoiding resource leaks during testing.

celestia/celestia_test.go (2)
  • 17-31: The setup function is well-structured, creating a new mock service and asserting that no errors occur during the setup process. It also decodes a namespace and asserts the client's equality, which is a good practice to ensure the setup is correct before running tests.

  • 34-38: The teardown function correctly closes the client and the mock service. This is important for releasing resources after tests are completed.

celestia/mock.go Show resolved Hide resolved
celestia/mock.go Show resolved Hide resolved
celestia/mock.go Outdated Show resolved Hide resolved
celestia/celestia_test.go Outdated Show resolved Hide resolved
Manav-Aggarwal
Manav-Aggarwal previously approved these changes Jan 9, 2024
Copy link

@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 e41a5b2 and 38cab4b.
Files selected for processing (1)
  • celestia/celestia_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • celestia/celestia_test.go

Copy link

@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 38cab4b and a12df66.
Files selected for processing (2)
  • celestia/celestia_test.go (1 hunks)
  • celestia/mock.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • celestia/celestia_test.go
  • celestia/mock.go

@gupadhyaya gupadhyaya self-requested a review January 9, 2024 14:51
@gupadhyaya gupadhyaya merged commit ad7e4cb into main Jan 9, 2024
16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants