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

fix(contracts-rfq): increase coverage #3453

Merged
merged 2 commits into from
Dec 11, 2024
Merged

fix(contracts-rfq): increase coverage #3453

merged 2 commits into from
Dec 11, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Dec 11, 2024

Description
A clear and concise description of the features you're adding in this pull request.

Additional context
Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • New Features
    • Added multiple new test functions to enhance the testing coverage for native token transfers in the TokenZapV1Test contract.
    • Introduced empty test functions across various contracts to ensure they do not appear in coverage reports.
  • Bug Fixes
    • Improved error handling for token transfers to ensure proper behavior under various conditions.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request involve the addition of new external functions across several Solidity test contracts to prevent them from appearing in code coverage reports. Additionally, updates to comment directives for the Solidity linter have been made to disable warnings related to empty blocks. The logic and functionality of existing methods in these contracts remain unchanged.

Changes

File Path Change Summary
packages/contracts-rfq/test/FastBridgeV2.Src.RefundV1.t.sol Added function testFastBridgeV2SrcRefundV1Test() external and updated linter directive.
packages/contracts-rfq/test/harnesses/BridgeTransactionV2Harness.sol Added function testBridgeTransactionV2Harness() external.
packages/contracts-rfq/test/harnesses/ZapDataV1Harness.sol Added function testZapDataV1Harness() external and updated linter directive.
packages/contracts-rfq/test/integration/FastBridge.MulticallTarget.t.sol Added function testFastBridgeMulticallTargetTest() external.
packages/contracts-rfq/test/integration/FastBridgeV2.MulticallTarget.t.sol Added function testFastBridgeV2MulticallTargetTest() external.
packages/contracts-rfq/test/integration/TokenZapV1.t.sol Added function testTokenZapV1IntegrationTest() external and updated linter directive.
packages/contracts-rfq/test/mocks/MockRevertingRecipient.sol Added function testMockRevertingRecipient() external and updated linter directive.
packages/contracts-rfq/test/mocks/VaultMock.sol Added function testVaultMock() external {}; existing logic remains unchanged.
packages/contracts-rfq/test/zaps/TokenZapV1.t.sol Added multiple functions for transferring native tokens and enhanced error handling.

Possibly related PRs

Suggested labels

size/m, needs-go-generate-services/rfq

Suggested reviewers

  • parodime
  • trajan0x

Poem

In the code where bunnies hop,
New functions added, never stop.
With tests to keep our coverage bright,
We code by day, and dream by night.
Empty blocks, we now embrace,
In our Solidity testing space! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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.

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

🧹 Outside diff range and nitpick comments (3)
packages/contracts-rfq/test/mocks/VaultMock.sol (1)

6-6: LGTM! Consider documenting the coverage exclusion pattern.

The addition of the empty test function and solhint directive follows the project's pattern for coverage report management. Consider adding a comment in the test documentation explaining this pattern for better maintainability.

Consider adding this pattern to your testing documentation:

## Test Coverage Management
Empty test functions are added to mock/harness contracts to prevent them from appearing in coverage reports while maintaining their testing utility.

Also applies to: 17-18

packages/contracts-rfq/test/integration/FastBridgeV2.MulticallTarget.t.sol (1)

9-12: LGTM! Consider enhancing test coverage.

While the empty test function follows the project's pattern, consider adding actual test cases in this contract to validate the bridge transaction encoding logic.

Would you like me to help generate comprehensive test cases for the bridge transaction encoding functionality?

packages/contracts-rfq/test/harnesses/ZapDataV1Harness.sol (1)

6-6: LGTM! Consider improving harness documentation.

The empty test function addition follows the project's pattern. The harness provides good coverage of ZapDataV1 library functionality.

Consider adding NatSpec documentation to describe the harness's purpose and relationship with the ZapDataV1 library:

/// @title ZapDataV1Harness
/// @notice Test harness providing direct access to ZapDataV1 library functions
/// @dev Used for testing ZapDataV1 encoding/decoding functionality

Also applies to: 11-12

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ba4eb3c and 0163669.

📒 Files selected for processing (9)
  • packages/contracts-rfq/test/FastBridgeV2.Src.RefundV1.t.sol (1 hunks)
  • packages/contracts-rfq/test/harnesses/BridgeTransactionV2Harness.sol (1 hunks)
  • packages/contracts-rfq/test/harnesses/ZapDataV1Harness.sol (1 hunks)
  • packages/contracts-rfq/test/integration/FastBridge.MulticallTarget.t.sol (1 hunks)
  • packages/contracts-rfq/test/integration/FastBridgeV2.MulticallTarget.t.sol (1 hunks)
  • packages/contracts-rfq/test/integration/TokenZapV1.t.sol (2 hunks)
  • packages/contracts-rfq/test/mocks/MockRevertingRecipient.sol (1 hunks)
  • packages/contracts-rfq/test/mocks/VaultMock.sol (2 hunks)
  • packages/contracts-rfq/test/zaps/TokenZapV1.t.sol (2 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/contracts-rfq/test/FastBridgeV2.Src.RefundV1.t.sol (2)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/contracts/FastBridgeV2.sol:100-118
Timestamp: 2024-11-12T03:37:08.148Z
Learning: When reviewing code in `packages/contracts-rfq/contracts/FastBridgeV2.sol` (Solidity), focus on changes introduced in the PR and avoid commenting on existing functions like `refund` if they are not modified by the PR, as such comments are considered out of scope.
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-11-12T03:37:02.230Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
🔇 Additional comments (8)
packages/contracts-rfq/test/mocks/MockRevertingRecipient.sol (1)

4-4: LGTM! Changes align with coverage improvement goals.

The addition of the empty test function and its documentation clearly explains the purpose of preventing the contract from appearing in coverage reports. The naming convention follows the contract name pattern consistently.

Also applies to: 10-11

packages/contracts-rfq/test/FastBridgeV2.Src.RefundV1.t.sol (1)

6-6: LGTM! Consistent with coverage improvement pattern.

The empty test function addition follows the established pattern for coverage reporting improvement. The expanded solhint directive appropriately handles test-specific linting rules.

Also applies to: 8-9

packages/contracts-rfq/test/integration/FastBridge.MulticallTarget.t.sol (1)

8-8: LGTM! Maintains consistency with coverage improvements.

The empty test function addition and its documentation align with the established pattern across other test files. The solhint directive is appropriately scoped for test contracts.

Also applies to: 10-11

packages/contracts-rfq/test/harnesses/BridgeTransactionV2Harness.sol (1)

6-9: LGTM: Empty test function added to exclude from coverage.

The empty test function with the descriptive comment is a good practice to prevent test harnesses from appearing in coverage reports.

packages/contracts-rfq/test/integration/TokenZapV1.t.sol (1)

14-14: LGTM: Updated solhint directive.

The solhint directive has been updated to include no-empty-blocks, which is consistent with the changes across test files.

packages/contracts-rfq/test/zaps/TokenZapV1.t.sol (3)

420-428: LGTM: Well-structured helper function for native token transfers.

The function follows the established pattern and correctly encodes the zap data with appropriate parameters.


430-460: LGTM: Comprehensive test coverage for native token transfers.

The test functions thoroughly cover:

  • Transfers to EOA and contract addresses
  • Handling of extra funds
  • Balance verification

589-593: LGTM: Proper error handling test for native token transfers.

The test correctly verifies that transfers to non-payable contracts revert with the appropriate error.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.88357%. Comparing base (9900167) to head (0163669).
Report is 2 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3453         +/-   ##
===================================================
+ Coverage   98.72408%   98.88357%   +0.15949%     
===================================================
  Files             11          11                 
  Lines            627         627                 
===================================================
+ Hits             619         620          +1     
+ Misses             8           7          -1     
Flag Coverage Δ
solidity 98.88357% <ø> (+0.15949%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0163669
Status: ✅  Deploy successful!
Preview URL: https://f57c86e8.sanguine-fe.pages.dev
Branch Preview URL: https://fix-fbv2-coverage.sanguine-fe.pages.dev

View logs

@ChiTimesChi ChiTimesChi merged commit c341b69 into master Dec 11, 2024
51 of 53 checks passed
@ChiTimesChi ChiTimesChi deleted the fix/FbV2-coverage branch December 11, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant