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

test(server/v2/cometbft): Add abci unit tests #21020

Merged
merged 38 commits into from
Sep 9, 2024
Merged

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Jul 22, 2024

Description

Closes: #20484

Author 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...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive suite of unit tests for the ABCI functionalities of the CometBFT consensus engine, covering initialization, block finalization, transaction checking, proposal handling, and vote extensions.
    • Added a mock implementation for controlled read access to the RootStore, enhancing testing and version management capabilities.
    • Implemented a mock storage system for testing interactions with a versioned database.
  • Bug Fixes

    • Enhanced the robustness of consensus logic through thorough testing, ensuring correct behavior in various edge cases.
  • Chores

    • Updated module dependencies for improved structure and functionality, including the addition of a new testing framework.

Copy link
Contributor

coderabbitai bot commented Jul 22, 2024

Walkthrough

Walkthrough

The changes include the addition of unit tests for the CometBFT framework, specifically targeting the ABCI functionality. New mock implementations for storage, reader, and mempool interfaces are introduced to facilitate testing. Updates are also made to the dependency management in the go.mod files, enhancing the structure and testing capabilities of the CometBFT components for comprehensive functionality coverage.

Changes

Files Change Summary
server/v2/cometbft/abci_test.go Introduced unit tests for ABCI functionality, covering consensus mechanisms, transaction handling, and state management. Implemented helper functions for streamlined testing.
server/v2/cometbft/go.mod Added module replacements and a new dependency for cosmossdk.io/server/v2/stf. Updated and removed the requirement for github.com/stretchr/testify.
simapp/v2/go.mod Updated the dependency version for cosmossdk.io/server/v2/stf to a specific version.
server/v2/cometbft/internal/mock/mock_reader.go Defined a mock read-only interface for accessing data from a RootStore. Introduced ReaderMap and MockReader for structured read operations.
server/v2/cometbft/internal/mock/mock_store.go Implemented a mock storage system for testing, simulating database operations with version control and commit management features.
server/v2/cometbft/internal/mock/mock_mempool.go Created a mock mempool interface for testing, allowing for the simulation of transaction handling without a real mempool implementation.

Assessment against linked issues

Objective Addressed Explanation
server/v2/cometbft needs unit tests with mocks (20484)

Possibly related PRs

  • fix(stf/branch/memiter): Fix Iter validity #21556: The changes in this PR involve modifications to iterator methods in the changeset struct, which may relate to the testing framework introduced in the main PR, as both involve aspects of state management and iteration within the CometBFT framework.
  • refactor(core): re-add handlers #21575: This PR enhances the message handling system in the appmodulev2 package, which could be relevant to the testing of transaction handling in the main PR, as both involve the processing of messages and transactions within the consensus engine.

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 testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hieuvubk hieuvubk changed the title Hieu/comet mock test(server/v2/cometbft): Add abci unit tests Jul 22, 2024
Copy link
Member

Choose a reason for hiding this comment

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

imho we shouldn't expose those APIs. We wouldn't want anyone to use this (even if we say it is for test only).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that hard, need someway to access to state inside 😅

@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 appmanager labels Aug 6, 2024
@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Sep 9, 2024
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.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 667c1e2 and 5578d48.

Files selected for processing (2)
  • server/v2/cometbft/go.mod (6 hunks)
  • simapp/v2/go.mod (1 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/v2/go.mod
Files skipped from review as they are similar to previous changes (1)
  • server/v2/cometbft/go.mod

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.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5578d48 and f5325d9.

Files selected for processing (1)
  • server/v2/cometbft/abci_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/v2/cometbft/abci_test.go

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Nice work!!

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.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f5325d9 and 96d6f5b.

Files selected for processing (1)
  • server/v2/cometbft/abci_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/v2/cometbft/abci_test.go

@julienrbrt julienrbrt added this pull request to the merge queue Sep 9, 2024
Merged via the queue into main with commit ac53e33 Sep 9, 2024
71 of 72 checks passed
@julienrbrt julienrbrt deleted the hieu/comet_mock branch September 9, 2024 10:38
mergify bot pushed a commit that referenced this pull request Sep 9, 2024
Co-authored-by: Julien Robert <julien@rbrt.fr>
(cherry picked from commit ac53e33)

# Conflicts:
#	server/v2/cometbft/go.mod
#	server/v2/stf/mock/tx.go
#	simapp/v2/go.mod
julienrbrt added a commit that referenced this pull request Sep 9, 2024
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:server/v2 cometbft C:server/v2 stf C:server/v2 Issues related to server/v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server/v2/cometbft needs unit tests with mocks
4 participants