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(contracts-rfq): remove test contracts from coverage report #3291

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Oct 15, 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 several new test functions across multiple contracts to improve test coverage reporting.
  • Bug Fixes

    • No bug fixes were included in this release.
  • Documentation

    • Updated comments in various contracts for clarity and to suppress warnings related to empty functions.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

This pull request introduces new empty test functions across various contracts to prevent them from appearing in coverage reports. The changes affect the DeployFastBridge, FastBridgeMock, and several test contracts related to FastBridgeV2, as well as mock contracts. The existing functionality of all contracts remains unchanged, with no modifications to their core logic or methods.

Changes

File Path Change Summary
packages/contracts-rfq/script/FastBridge.s.sol Added function testDeployFastBridge() external in DeployFastBridge contract.
packages/contracts-rfq/test/FastBridgeMock.sol Added function testFastBridgeMock() external in FastBridgeMock contract.
packages/contracts-rfq/test/FastBridgeV2.*.t.sol Added various test functions in multiple contracts related to FastBridgeV2, preserving existing logic.
packages/contracts-rfq/test/MockERC20.sol Added function testMockERC20() external in MockERC20 contract.
packages/contracts-rfq/test/UniversalTokenLibHarness.sol Added function testUniversalTokenLibHarness() external in UniversalTokenLibHarness.
packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol Added function testMulticallTargetHarness() external in MulticallTargetHarness.
packages/contracts-rfq/test/mocks/*.sol Added various test functions in multiple mock contracts to prevent coverage reporting.

Possibly related PRs

Suggested labels

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

Suggested reviewers

  • traian0x
  • parodime

Poem

In the meadow where bunnies hop,
New functions added, let testing not stop!
With empty calls, our coverage stays clear,
For contracts and mocks, we hold them dear.
A leap for the code, a dance in the grass,
Hooray for the changes, let the tests amass! 🐇✨


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 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: 1

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

7-8: LGTM: Appropriate addition of test function

The new testNonPayableRecipient function serves its purpose well by preventing the contract from being excluded from coverage reports. This aligns with the PR objective.

A minor suggestion for improvement:

Consider adding the pure modifier to the function since it doesn't read from or modify the contract's state. This would make the function's behavior more explicit:

- function testNonPayableRecipient() external {}
+ function testNonPayableRecipient() external pure {}
packages/contracts-rfq/test/MockERC20.sol (1)

14-15: LGTM: Well-documented empty test function

The addition of the empty testMockERC20() function, along with its explanatory comment, effectively achieves the goal of excluding this contract from the coverage report. The function is correctly marked as external.

A minor suggestion to improve the comment:

Consider updating the comment to be more specific:

-/// @notice We include an empty "test" function so that this contract does not appear in the coverage report.
+/// @notice This empty test function prevents the contract from appearing in the coverage report.

This slight rewording makes the comment more concise and direct.

packages/contracts-rfq/test/mocks/RecipientMock.sol (2)

12-13: LGTM: Empty function added to exclude from coverage

The addition of the testRecipientMock() function effectively achieves the goal of excluding this test contract from coverage reports. The naming and visibility are appropriate.

Consider slightly modifying the comment to be more explicit:

-    /// @notice We include an empty "test" function so that this contract does not appear in the coverage report.
+    /// @notice This empty function ensures that this test contract is excluded from the coverage report.

Line range hint 1-20: Overall: Changes effectively exclude test contract from coverage

The additions successfully achieve the PR objective of removing this test contract from coverage reports without altering its functionality. This approach is clean and doesn't introduce any risks.

To further emphasize the test-only nature of this contract, consider adding a @dev tag to the contract-level documentation:

 // solhint-disable no-empty-blocks
 /// @notice Recipient mock for testing purposes. DO NOT USE IN PRODUCTION.
+/// @dev This contract is for testing only and should never be used in a production environment.
 contract RecipientMock is IFastBridgeRecipient {
packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol (1)

12-13: LGTM: Appropriate test coverage exclusion technique

The addition of the empty testExcessiveReturnValueRecipient function is a good approach to exclude this mock contract from coverage reports. The comment clearly explains its purpose.

Consider making the function public instead of external for consistency with Solidity's style guide for test functions:

-    function testExcessiveReturnValueRecipient() external {}
+    function testExcessiveReturnValueRecipient() public {}
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol (1)

6-6: LGTM, but consider more specific linter disabling.

The addition of no-empty-blocks to the linter disable comment is consistent with the new empty test function. However, consider using inline linter disabling for specific functions instead of disabling it for the entire contract to maintain better code quality where possible.

packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol (1)

12-13: LGTM: Appropriate test function added to exclude from coverage.

The added testIncorrectReturnValueRecipient function serves its purpose well by excluding this contract from coverage reports. The comment clearly explains its intention.

Consider adding a pure modifier to the function to explicitly indicate that it doesn't read from or modify the contract's state:

-    function testIncorrectReturnValueRecipient() external {}
+    function testIncorrectReturnValueRecipient() external pure {}

This change would make the function's behavior more explicit and align with Solidity best practices.

packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol (2)

8-9: LGTM: Empty test function added for coverage exclusion.

The addition of this empty test function effectively achieves the PR objective of excluding this test contract from the coverage report. The function name is consistent with the contract name, which is good practice.

Consider adding a TODO comment to remind future developers about the purpose of this empty function, as its intention might not be immediately clear without context.

You could add a TODO comment like this:

// TODO: This empty function is intentional. It exists to exclude this contract from coverage reports.
function testFastBridgeV2GasBenchmarkSrcArbitraryCallTest() external {}

Line range hint 11-20: LGTM with suggestions: Overridden createFixturesV2 function.

The overridden createFixturesV2 function correctly extends the parent implementation and sets up mock call parameters for various transaction types. This is consistent with the purpose of the test contract.

However, consider the following suggestions for improvement:

  1. Using different mock parameters for each transaction type could provide more comprehensive test coverage.
  2. Consider extracting the mock parameter generation into a separate function for better readability and reusability.

Here's a potential refactoring to address these suggestions:

function createFixturesV2() public virtual override {
    super.createFixturesV2();
    
    bridgedTokenTx.callParams = generateMockParams("BridgedToken");
    bridgedEthTx.callParams = generateMockParams("BridgedEth");
    provenTokenTx.callParams = generateMockParams("ProvenToken");
    provenEthTx.callParams = generateMockParams("ProvenEth");
    
    setTokenTestCallParams(bridgedTokenTx.callParams);
    setEthTestCallParams(bridgedEthTx.callParams);
}

function generateMockParams(string memory identifier) internal view returns (bytes memory) {
    return abi.encode(userA, keccak256(abi.encodePacked(identifier)));
}

This refactoring improves readability and allows for unique parameters for each transaction type.

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

8-9: LGTM: Empty test function serves its intended purpose.

The addition of the empty testFastBridgeV2SrcProtocolFeesTest function is an appropriate way to exclude this contract from the coverage report. This change aligns with the PR objective and doesn't modify the contract's behavior or utility.

This approach is a common and effective technique for managing test coverage reporting. It allows you to maintain the contract structure while controlling which contracts appear in coverage reports.

packages/contracts-rfq/test/UniversalTokenLibHarness.sol (1)

8-9: Empty test function added to include contract in coverage report

An empty function testUniversalTokenLibHarness has been added with a comment explaining its purpose. This change aligns with the PR objective of managing test contracts in the coverage report.

However, it's worth noting that this approach might not be the most maintainable solution in the long term. Consider exploring alternative methods for managing test coverage, such as configuration files or coverage ignore patterns, which could provide a more scalable approach.

Would you like suggestions for alternative approaches to manage test coverage without adding empty functions?

packages/contracts-rfq/script/FastBridge.s.sol (1)

10-11: Approved: Empty test function added to exclude from coverage.

The addition of the empty testDeployFastBridge function aligns with the PR objective to remove test contracts from the coverage report. This approach is acceptable for script contracts.

Consider slightly modifying the comment for clarity:

-    /// @notice We include an empty "test" function so that this contract does not appear in the coverage report.
+    /// @notice This empty "test" function prevents this script contract from appearing in the coverage report.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol (2)

15-16: LGTM: Empty test function serves its purpose.

The addition of the empty test function testFastBridgeV2GasBenchmarkDstArbitraryCallTest effectively achieves the goal of excluding this contract from the coverage report. This aligns with the PR's objective.

Consider slightly modifying the comment for clarity:

-    /// @notice We include an empty "test" function so that this contract does not appear in the coverage report.
+    /// @dev This empty test function ensures that this contract is not included in the coverage report.

This change emphasizes that it's a development-specific comment and slightly improves the wording.


Line range hint 18-31: LGTM: Setup and fixture creation look good.

The modifications to setUp and createFixturesV2 functions appropriately set up the test environment for gas benchmarking. The use of a mock recipient aligns well with the goal of measuring arbitrary call overhead.

For consistency with Solidity style guidelines, consider adding the override keyword to the createFixturesV2 function:

-    function createFixturesV2() public virtual override {
+    function createFixturesV2() public virtual override {

This change maintains consistency with the setUp function declaration.

packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (2)

Line range hint 11-15: LGTM: configureFastBridge function looks good.

The modifications to the configureFastBridge function are appropriate for testing protocol fees. It correctly calls the parent implementation, grants the necessary role, and sets a reasonable fee rate for testing.

Consider extracting the fee rate (1e4) to a constant for better readability and easier modification in future tests. For example:

uint256 private constant PROTOCOL_FEE_RATE = 1e4; // 1%

function configureFastBridge() public virtual override {
    // ... existing code ...
    fastBridge.setProtocolFeeRate(PROTOCOL_FEE_RATE);
}

Line range hint 17-38: LGTM: createFixtures function is well-structured.

The createFixtures function is appropriately modified to set up test scenarios with protocol fees. It correctly initializes transaction amounts, fee amounts, and nonces for both token and ETH transactions.

To improve clarity, consider adding a brief comment explaining the relationship between the different transaction amounts. For example:

function createFixtures() public virtual override {
    super.createFixtures();
    
    // Set up token transaction with 1% fee
    tokenTx.originFeeAmount = 0.01e6;  // 1% of 1e6
    tokenTx.originAmount = 0.99e6;     // Original amount minus fee
    tokenTx.destAmount = 0.98e6;       // Destination amount (may include additional fees)
    tokenParams.destAmount = 0.98e6;
    
    // Set up ETH transaction with 1% fee
    ethTx.originFeeAmount = 0.01 ether;  // 1% of 1 ether
    ethTx.originAmount = 0.99 ether;     // Original amount minus fee
    ethTx.destAmount = 0.98 ether;       // Destination amount (may include additional fees)
    ethParams.destAmount = 0.98 ether;
    
    // ... rest of the function ...
}

This addition would make it easier for other developers to understand the relationship between the various amounts and the applied fees.

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

47-49: Consider alternative methods to exclude from coverage reports.

The added empty function serves the purpose of preventing this contract from appearing in the coverage report. While this achieves the desired outcome, it introduces code that doesn't contribute to the contract's functionality or tests.

Have you considered alternative methods to exclude this contract from coverage reports? Some testing frameworks offer configuration options to exclude specific files or contracts without modifying the code. This approach would align better with the previous feedback about not unnecessarily modifying test utility contracts.

If no better alternatives exist, please add a more detailed comment explaining why this approach was chosen over other potential solutions.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e0ce7e7 and 0799a1d.

📒 Files selected for processing (17)
  • packages/contracts-rfq/script/FastBridge.s.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeMock.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.t.sol (1 hunks)
  • packages/contracts-rfq/test/MockERC20.sol (1 hunks)
  • packages/contracts-rfq/test/UniversalTokenLibHarness.sol (1 hunks)
  • packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol (2 hunks)
  • packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol (1 hunks)
  • packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol (1 hunks)
  • packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol (1 hunks)
  • packages/contracts-rfq/test/mocks/NonPayableRecipient.sol (1 hunks)
  • packages/contracts-rfq/test/mocks/RecipientMock.sol (1 hunks)
🧰 Additional context used
📓 Learnings (9)
packages/contracts-rfq/script/FastBridge.s.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeMock.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.ArbitraryCall.t.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (2)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: In Solidity test contracts under the `test` directory, such as `FastBridgeV2.t.sol`, contracts are not deployed, so gas consumption is not a concern.
packages/contracts-rfq/test/FastBridgeV2.Src.ProtocolFees.t.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
packages/contracts-rfq/test/FastBridgeV2.t.sol (3)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: Modifying test utility contracts in the `test` directory is unnecessary and would only pollute the code.
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.t.sol:53-56
Timestamp: 2024-10-14T13:24:45.293Z
Learning: In Solidity test contracts under the `test` directory, such as `FastBridgeV2.t.sol`, contracts are not deployed, so gas consumption is not a concern.
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/test/FastBridgeV2.Src.t.sol:919-993
Timestamp: 2024-10-14T14:48:01.520Z
Learning: In Solidity test files for FastBridgeV2 (e.g., `packages/contracts-rfq/test/FastBridgeV2.Src.t.sol`), code duplication in test functions is acceptable to maintain readability and maintainability, even if it contradicts DRY principles.
🔇 Additional comments (23)
packages/contracts-rfq/test/mocks/NonPayableRecipient.sol (2)

4-4: LGTM: Appropriate use of Solhint directive

The added Solhint directive to disable empty block warnings is appropriate, considering the new empty function being introduced. This helps maintain clean code without unnecessary warnings.


Line range hint 1-15: Summary: Changes align with PR objectives without altering contract behavior

The modifications to this contract successfully achieve the goal of including it in coverage reports without changing its core functionality. The added empty function and Solhint directive are appropriate for a test mock contract.

Some key points:

  1. The existing fastBridgeTransferReceived function remains unchanged, preserving the contract's original behavior.
  2. The comment clearly states that this is a mock contract for testing purposes and should not be used in production.
  3. These changes contribute to more accurate test coverage reporting without introducing any risks.
packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol (2)

4-4: LGTM: Solhint directive update is appropriate.

The update to the solhint directive to disable the rule against empty blocks is consistent with the addition of an empty test function. This is a good practice when intentionally including empty blocks in the code.


10-11: LGTM: New function addition aligns with PR objectives.

The addition of the testNoReturnValueRecipient function is in line with the PR objective of removing test contracts from the coverage report. The function is correctly implemented as an empty external function, and its name is descriptive and follows the contract name convention.

packages/contracts-rfq/test/MockERC20.sol (1)

6-6: LGTM: Appropriate use of solhint disable comment

The solhint disable comment is correctly placed and specifically targets the no-empty-blocks rule. This is a good practice to suppress warnings for the intentional empty function that follows.

packages/contracts-rfq/test/mocks/RecipientMock.sol (1)

6-6: LGTM: Solhint directive added to allow empty blocks

The addition of the // solhint-disable no-empty-blocks directive is appropriate here. It prevents linting errors for the intentionally empty function that follows, which is used to exclude this test contract from coverage reports.

packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol (2)

6-6: LGTM: Appropriate use of linter directive

The added solhint directive to disable the no-empty-blocks rule is appropriate here, as we're intentionally adding an empty function for test coverage purposes.


6-13: Summary: Appropriate changes for test coverage exclusion

The changes made to this file effectively exclude the ExcessiveReturnValueRecipient mock contract from coverage reports without altering its functionality. This aligns well with the PR objectives.

Key points:

  1. The added solhint directive is appropriate for the intentional use of an empty block.
  2. The new empty test function serves its purpose of excluding the contract from coverage.

These changes improve the accuracy of test coverage metrics by excluding mock contracts designed for testing purposes.

packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol (3)

8-11: LGTM. Changes align with the PR objective.

The addition of the EXCLUSIVITY_PERIOD constant and the empty test function testFastBridgeV2GasBenchmarkDstExclusivityTest serve clear purposes:

  1. The constant is used in other functions to set up the test environment.
  2. The empty test function prevents this contract from appearing in the coverage report, which aligns with the PR objective of removing test contracts from the coverage report.

These changes are appropriate and don't unnecessarily modify the test utility contract.


Line range hint 13-16: LGTM. setUp function appropriately modified for test scenario.

The setUp function has been correctly overridden to call the parent implementation and then skip time by half of the EXCLUSIVITY_PERIOD. This modification sets up a specific test scenario where half of the exclusivity period has passed, which is consistent with the purpose of this test contract.


Line range hint 18-22: LGTM. createFixturesV2 function properly sets up exclusivity test environment.

The createFixturesV2 function has been appropriately overridden to call the parent implementation and then set token and ETH test exclusivity parameters using the EXCLUSIVITY_PERIOD. These modifications are consistent with setting up the test environment for exclusivity testing, which aligns with the purpose of this test contract.

packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol (2)

6-6: LGTM: Appropriate solhint directive added.

The added solhint directive to disable the no-empty-blocks rule is appropriate, given the new empty function being introduced. This prevents unnecessary linting warnings while maintaining the intended testing functionality.


6-13: LGTM: Changes successfully exclude the contract from coverage reports.

The modifications to this file effectively achieve the PR's objective of removing test contracts from coverage reports. The added empty function and accompanying comment serve their purpose without affecting the core functionality or security of the contract. These changes will lead to more accurate test coverage reports by excluding mock contracts designed for testing purposes.

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

6-6: LGTM: Appropriate solhint directive update.

The solhint directive has been correctly updated to include 'no-empty-blocks', which is consistent with the addition of an intentionally empty test function. This is a good practice to avoid unnecessary linter warnings.

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

6-6: LGTM: Updated comment directive is appropriate.

The updated comment directive to disable checks for mixed-case function names and empty blocks is appropriate, considering the intentional addition of an empty test function. This change helps prevent unnecessary linting warnings in the test contract.

packages/contracts-rfq/test/UniversalTokenLibHarness.sol (1)

6-6: Linter directive updated to accommodate new empty function

The Solidity linter directive has been expanded to disable the no-empty-blocks check in addition to the existing ordering check. This change is appropriate given the introduction of the empty testUniversalTokenLibHarness function.

packages/contracts-rfq/script/FastBridge.s.sol (1)

Line range hint 1-35: LGTM: No impact on existing functionality.

The addition of the testDeployFastBridge function doesn't affect the existing run function or any other part of the contract. The core functionality of deploying the FastBridge contract, managing roles, and handling ownership remains intact.

packages/contracts-rfq/test/harnesses/MulticallTargetHarness.sol (2)

6-6: LGTM: Appropriate use of linter directive

The addition of the // solhint-disable no-empty-blocks directive is a good practice. It prevents unnecessary linter warnings for the intentionally empty function that follows.


15-16: LGTM: Effective implementation for coverage exclusion

The addition of the empty testMulticallTargetHarness function, along with its explanatory comment, is an effective way to exclude this contract from the coverage report. This aligns well with the PR objective of removing test contracts from coverage reporting.

packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.ArbitraryCall.t.sol (1)

7-7: LGTM: Solhint directive update is appropriate.

The modification to disable the no-empty-blocks rule is necessary to accommodate the intentionally empty test function. This change aligns with the PR's objective of removing test contracts from the coverage report.

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

6-9: LGTM: New test contract and empty test function.

The new contract FastBridgeV2GasBenchmarkSrcProtocolFeesTest and the empty test function are well-structured and follow good practices for Solidity test contracts. The empty test function effectively prevents this contract from appearing in the coverage report, which is the intended behavior for specialized test cases.

packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol (2)

6-6: LGTM: Updated linter directive is appropriate.

The addition of no-empty-blocks to the linter directive is consistent with the introduction of the empty test function. This change is acceptable in the context of test contracts.


10-11: LGTM: Empty test function serves its purpose.

The addition of the empty testFastBridgeV2DstBaseTest function is an appropriate way to exclude this test contract from the coverage report. This change aligns with the PR objective and is consistent with previous feedback about not unnecessarily modifying test utility contracts.

Comment on lines +19 to +21
/// @notice We include an empty "test" function so that this contract does not appear in the coverage report.
function testFastBridgeMock() external {}

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider alternative approaches to exclude test contracts from coverage.

The added testFastBridgeMock() function serves its purpose of preventing this contract from appearing in the coverage report. However, modifying test utility contracts in the test directory might be unnecessary and could potentially pollute the code.

Instead of adding empty functions to each test contract, consider exploring alternative methods to exclude test contracts from coverage reports:

  1. Configure your coverage tool to ignore specific directories or files.
  2. Use naming conventions or file extensions that your coverage tool can recognize and exclude.
  3. If using solidity-coverage, you can add a .solcover.js configuration file to exclude specific contracts or directories.

These approaches would achieve the same goal without modifying the test contracts themselves.

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@e0ce7e7). Learn more about missing BASE report.
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master       #3291   +/-   ##
============================================
  Coverage          ?   91.48936%           
============================================
  Files             ?          59           
  Lines             ?        1269           
  Branches          ?         158           
============================================
  Hits              ?        1161           
  Misses            ?         104           
  Partials          ?           4           
Flag Coverage Δ
packages 90.44834% <ø> (?)
solidity 95.88477% <ø> (?)

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

Changes to gas cost

Generated at commit: 10e8694cc9ec46c75b0ffbbae33b5f73d54ab88b, compared to commit: de92c1f24d8c5d08bd87ab03a203a1bdc8225000

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 claim(bytes)
claim(bytes,address)
refund
-11 ✅
-11 ✅
-11 ✅
-0.02%
-0.02%
-0.02%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
FastBridgeV2 2,992,360 (0) bridge
bridgeStatuses
claim(bytes)
claim(bytes,address)
grantRole
prove(bytes,bytes32)
refund
70,686 (0)
616 (0)
43,814 (0)
46,667 (0)
101,405 (0)
35,573 (0)
47,685 (0)
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
82,075 (-14)
1,198 (+7)
50,835 (-11)
52,438 (-11)
114,537 (+1)
35,890 (+4)
51,753 (-11)
-0.02%
+0.59%
-0.02%
-0.02%
+0.00%
+0.01%
-0.02%
82,741 (-22)
616 (0)
51,372 (-11)
52,975 (-11)
118,505 (0)
35,597 (0)
51,913 (-11)
-0.03%
0.00%
-0.02%
-0.02%
0.00%
0.00%
-0.02%
94,820 (-44)
2,616 (0)
58,894 (-22)
59,247 (-22)
118,505 (0)
36,549 (0)
56,142 (-22)
-0.05%
0.00%
-0.04%
-0.04%
0.00%
0.00%
-0.04%
260 (+20)
426 (+30)
6 (0)
6 (0)
289 (+26)
68 (+5)
12 (0)

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0799a1d
Status: ✅  Deploy successful!
Preview URL: https://49b8bb1c.sanguine-fe.pages.dev
Branch Preview URL: https://test-fast-bridge-coverage.sanguine-fe.pages.dev

View logs

@ChiTimesChi ChiTimesChi merged commit ea0154c into master Oct 15, 2024
52 checks passed
@ChiTimesChi ChiTimesChi deleted the test/fast-bridge-coverage branch October 15, 2024 13:32
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