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): gas estimation tests [SLT-275] #3204

Merged
merged 6 commits into from
Sep 27, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Sep 27, 2024

Description
Introduces a separate set of tests meant for accurate average gas estimation.

Summary by CodeRabbit

  • New Features

    • Introduced a gas benchmarking test suite for the FastBridgeV2 contract, focusing on both source and destination chain functions.
    • Added a new test contract for gas benchmarking, enhancing performance evaluation.
  • Bug Fixes

    • Adjusted the gas report generation method to provide more accurate estimates by focusing on specific benchmark tests.
  • Refactor

    • Streamlined several test contracts by removing unnecessary functions and constants, improving the testing structure and efficiency.
  • Tests

    • Expanded the test coverage for relaying tokens and ETH, ensuring proper balance updates and transaction assertions.

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

Walkthrough

The pull request introduces significant updates to the Solidity testing framework, particularly for the FastBridgeV2 contract. It modifies the GitHub Actions workflow for gas reporting, introduces new test contracts for benchmarking gas usage, and refactors existing test contracts to streamline functionality. The changes focus on enhancing the accuracy of gas cost estimations and improving the structure of the testing codebase.

Changes

File Path Change Summary
.github/workflows/solidity.yml Modified the GitHub Actions workflow to change the command for running tests and generating gas reports, focusing on a specific benchmark test instead of excluding failing tests.
packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol Introduced FastBridgeV2DstBaseTest with methods for setup, deployment, and token minting, along with relay functions.
packages/contracts-rfq/test/FastBridgeV2.Dst.t.sol Refactored FastBridgeV2DstTest to inherit from FastBridgeV2DstBaseTest, removing several methods and constants to streamline the contract.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.t.sol Added a gas benchmarking contract for destination chain functions, including test functions for evaluating gas costs associated with relaying tokens and ETH.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol Introduced FastBridgeV2GasBenchmarkSrcProtocolFeesTest, overriding functions to set up protocol fee configurations and transaction parameters.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol Created a comprehensive gas benchmarking test suite for source chain functions, including setup, transaction fixture creation, and multiple test functions for gas costs and functionality.
packages/contracts-rfq/test/FastBridgeV2.Src.Base.t.sol Introduced FastBridgeV2SrcBaseTest with constants, setup methods, and helper functions for bridging operations, enhancing the testing capabilities of the FastBridgeV2 contract.
packages/contracts-rfq/test/FastBridgeV2.Src.t.sol Refactored FastBridgeV2SrcTest to inherit from FastBridgeV2SrcBaseTest, removing several constants and functions, indicating a shift in the testing approach for bridging functionalities.

Possibly related PRs

Suggested labels

M-ci, size/m, M-contracts, needs-go-generate-services/rfq

Suggested reviewers

  • traian0x
  • abtestingalpha

Poem

🐇 In the meadow where bunnies play,
New tests hop in, brightening the day!
Gas reports dance, with numbers so neat,
FastBridge flows, a testing feat!
With each little change, we leap and bound,
In the world of Solidity, joy is found! 🌼


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

Changes to gas cost

Generated at commit: dc091ceecf618707e72228d3c18ce6dfbbb1d2b7, compared to commit: 257e57c702c97ec6314390930609725e023848c2

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 bridge
bridgeStatuses
claim(bytes)
claim(bytes,address)
protocolFees
relay(bytes)
relay(bytes,address)
-10,935 ✅
+571 ❌
-9,794 ✅
-8,320 ✅
-699 ✅
-9,613 ✅
-20,402 ✅
-12.18%
+98.11%
-15.97%
-13.54%
-37.91%
-11.95%
-22.26%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
FastBridgeV2 2,348,531 (0) bridge
bridgeStatuses
claim(bytes)
claim(bytes,address)
dispute
grantRole
protocolFees
prove(bytes,bytes32)
prove(bytes32,bytes32,address)
refund
relay(bytes)
relay(bytes,address)
setProtocolFeeRate
63,840 (0)
582 (0)
43,982 (-2,500)
46,853 (+3,047)
31,654 (0)
101,383 (+74,599)
645 (0)
56,896 (+420)
54,315 (+204)
46,057 (+2,941)
64,902 (+36,567)
65,341 (-25,000)
47,399 (+23,396)
0.00%
0.00%
-5.38%
+6.96%
0.00%
+278.52%
0.00%
+0.74%
+0.38%
+6.82%
+129.05%
-27.67%
+97.47%
78,818 (-10,935)
1,153 (+571)
51,516 (-9,794)
53,137 (-8,320)
31,663 (+4)
114,680 (+7,216)
1,145 (-699)
56,924 (-32)
54,326 (+32)
49,763 (-13)
70,797 (-9,613)
71,236 (-20,402)
47,399 (+845)
-12.18%
+98.11%
-15.97%
-13.54%
+0.01%
+6.71%
-37.91%
-0.06%
+0.06%
-0.03%
-11.95%
-22.26%
+1.82%
74,673 (-27,669)
582 (0)
51,525 (-9,794)
53,146 (-17,850)
31,666 (+12)
118,483 (+12)
645 (-2,000)
56,926 (+6)
54,327 (+12)
49,772 (+1,656)
70,797 (-16,164)
71,236 (-19,105)
47,399 (0)
-27.04%
0.00%
-15.97%
-25.14%
+0.04%
+0.01%
-75.61%
+0.01%
+0.02%
+3.44%
-18.59%
-21.15%
0.00%
102,607 (-19,895)
2,582 (+2,000)
59,033 (-17,088)
59,404 (-17,720)
31,666 (0)
118,483 (0)
2,645 (0)
57,040 (0)
54,327 (0)
53,451 (0)
76,693 (-31,867)
77,132 (-17,100)
47,399 (0)
-16.24%
+343.64%
-22.45%
-22.98%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
-29.35%
-18.15%
0.00%
132 (-4,583)
224 (-2,926)
4 (-1,020)
4 (-1,039)
4 (-10)
144 (-359)
256 (-3,506)
36 (-2,048)
36 (+20)
8 (-1,034)
2 (-7)
2 (-1)
16 (-32)

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 129cde2
Status: ✅  Deploy successful!
Preview URL: https://11498d1f.sanguine-fe.pages.dev
Branch Preview URL: https://fix-gas-estimation-tests.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.94584%. Comparing base (f0b13bc) to head (129cde2).
Report is 10 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                  @@
##              master       #3204          +/-   ##
====================================================
+ Coverage   40.97804%   90.94584%   +49.96780%     
====================================================
  Files            459          60         -399     
  Lines          25643        1237       -24406     
  Branches         343         148         -195     
====================================================
- Hits           10508        1125        -9383     
+ Misses         14383         109       -14274     
+ Partials         752           3         -749     
Flag Coverage Δ
cctp-relayer ?
core ?
ethergo ?
git-changes-action ?
omnirpc ?
opbot ?
packages 90.56974% <ø> (ø)
screener-api ?
scribe ?
solidity 92.69406% <ø> (-2.01267%) ⬇️
tools ?

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

🧹 Outside diff range and nitpick comments (9)
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (1)

25-35: LGTM: Transaction copies and nonce assignment look good.

The creation of separate copies for bridged and proven transactions with unique nonces is a good practice for isolated testing.

Consider adding brief comments explaining the significance of each nonce value (0, 1, 2, 3) in relation to the transaction types. This would enhance code readability and maintainability.

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

38-45: Adjust function declaration formatting for consistency

The formatting of the relayWithAddress function declaration deviates from standard Solidity style guidelines. Specifically, placing the public visibility modifier on a separate line and the opening brace { on a new line reduces readability.

Consider reformatting the function declaration for better clarity:

 function relayWithAddress(
     address caller,
     address relayer,
     uint256 msgValue,
     IFastBridge.BridgeTransaction memory bridgeTx
-)
-    public
-{
+) public {
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.t.sol (1)

7-8: Enhance clarity of documentation comments

Consider rephrasing the comments for better clarity and grammar:

/// @notice Estimates the gas cost of FastBridgeV2 destination chain functions.
/// @dev Minimal state checks are performed; ensure full coverage in other tests.
packages/contracts-rfq/test/FastBridgeV2.Src.t.sol (6)

Line range hint 22-25: Consider correcting the mislabeled parameter in the BridgeProofDisputed event definition.

In the function expectBridgeProofDisputed, there's a comment indicating that the BridgeProofDisputed event has a mislabeled address parameter (relayer), which is actually the guard. To improve clarity and maintainability, consider updating the event definition to correctly label the parameter or adding documentation to clarify this discrepancy.


Line range hint 41-49: Address the TODO to unskip test_bridge_userSpecificNonce function.

The test function test_bridge_userSpecificNonce is currently skipped using vm.skip(true); // TODO: unskip when implemented. Implement the necessary functionality and unskip this test to ensure comprehensive test coverage.

Would you like assistance in implementing this test or resolving any issues preventing it from running?


Line range hint 166-171: Ensure caller is not the zero address in test_prove_revert_callerNotRelayer.

In the function test_prove_revert_callerNotRelayer, consider adding an assumption to ensure that caller is not the zero address to prevent unintended behavior during testing.

Apply this change:

 function test_prove_revert_callerNotRelayer(address caller) public {
     vm.assume(caller != relayerA && caller != relayerB);
+    vm.assume(caller != address(0));
     bridge({caller: userA, msgValue: 0, params: tokenParams});
     expectUnauthorized(caller, fastBridge.RELAYER_ROLE());
     prove({caller: caller, bridgeTx: tokenTx, destTxHash: hex"01"});
 }

Line range hint 223-230: Ensure caller is not the zero address in test_claim_token_permissionless.

In the function test_claim_token_permissionless, consider adding an assumption to ensure that caller is not the zero address.

Apply this change:

 function test_claim_token_permissionless(address caller) public {
     vm.assume(caller != relayerA);
+    vm.assume(caller != address(0));
     bytes32 txId = getTxId(tokenTx);
     bridge({caller: userA, msgValue: 0, params: tokenParams});
     prove({caller: relayerA, bridgeTx: tokenTx, destTxHash: hex"01"});
     skip(CLAIM_DELAY + 1);
     expectBridgeDepositClaimed({bridgeTx: tokenTx, txId: txId, relayer: relayerA, to: relayerA});
     claim({caller: caller, bridgeTx: tokenTx});
     assertEq(fastBridge.bridgeStatuses(txId), FastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
     checkTokenBalancesAfterClaim(relayerA);
 }

Line range hint 299-309: Ensure caller is not the zero address in test_refund_token_permissionless.

In the function test_refund_token_permissionless, consider adding an assumption to ensure that caller is not the zero address.

Apply this change:

 function test_refund_token_permissionless(address caller) public {
     vm.assume(caller != refunder);
+    vm.assume(caller != address(0));
     bytes32 txId = getTxId(tokenTx);
     bridge({caller: userA, msgValue: 0, params: tokenParams});
     skip(DEADLINE + PERMISSIONLESS_REFUND_DELAY + 1);
     expectBridgeDepositRefunded({bridgeParams: tokenParams, txId: txId});
     refund({caller: caller, bridgeTx: tokenTx});
     assertEq(fastBridge.bridgeStatuses(txId), FastBridgeV2.BridgeStatus.REFUNDED);
     assertEq(fastBridge.protocolFees(address(srcToken)), INITIAL_PROTOCOL_FEES_TOKEN);
     assertEq(srcToken.balanceOf(userA), LEFTOVER_BALANCE + tokenParams.originAmount);
     assertEq(srcToken.balanceOf(address(fastBridge)), INITIAL_PROTOCOL_FEES_TOKEN);
 }

Line range hint 360-370: Ensure caller is not the zero address in test_refund_eth_permissionless.

In the function test_refund_eth_permissionless, consider adding an assumption to ensure that caller is not the zero address.

Apply this change:

 function test_refund_eth_permissionless(address caller) public {
     vm.assume(caller != refunder);
+    vm.assume(caller != address(0));
     bytes32 txId = getTxId(ethTx);
     bridge({caller: userA, msgValue: 0, params: tokenParams});
     bridge({caller: userA, msgValue: ethParams.originAmount, params: ethParams});
     skip(DEADLINE + PERMISSIONLESS_REFUND_DELAY + 1);
     expectBridgeDepositRefunded({bridgeParams: ethParams, txId: txId});
     refund({caller: caller, bridgeTx: ethTx});
     assertEq(fastBridge.bridgeStatuses(txId), FastBridgeV2.BridgeStatus.REFUNDED);
     assertEq(fastBridge.protocolFees(ETH_ADDRESS), INITIAL_PROTOCOL_FEES_ETH);
     assertEq(address(userA).balance, LEFTOVER_BALANCE + ethParams.originAmount);
     assertEq(address(fastBridge).balance, INITIAL_PROTOCOL_FEES_ETH);
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between edf99d3 and 129cde2.

📒 Files selected for processing (8)
  • .github/workflows/solidity.yml (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Dst.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Src.Base.t.sol (1 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Src.t.sol (1 hunks)
🔇 Additional comments (16)
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol (3)

1-7: LGTM: Contract declaration and import look good.

The contract is properly set up with the correct license, Solidity version, and import statement. The naming convention clearly indicates the purpose of this test contract.


14-23: LGTM: createFixtures function sets up test data correctly.

The function properly overrides the base implementation and sets up specific test values for both token and ETH transactions. The values are consistent across different transaction types and use appropriate units.


8-12: LGTM: configureFastBridge function is well-implemented.

The function correctly overrides the base implementation and sets up the test environment with a 1% protocol fee rate.

However, please verify if granting the GOVERNOR_ROLE to the contract itself is necessary for these tests. If it is, consider adding a comment explaining why this is needed.

✅ Verification successful

LGTM: configureFastBridge function is well-implemented.

The function correctly overrides the base implementation and sets up the test environment with a 1% protocol fee rate. Granting the GOVERNOR_ROLE to address(this) appears intentional for these specific tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if GOVERNOR_ROLE is used in other test files
rg --type solidity "GOVERNOR_ROLE" packages/contracts-rfq/test

Length of output: 95


Script:

#!/bin/bash
# Description: Check if GOVERNOR_ROLE is used in other Solidity test files
rg "GOVERNOR_ROLE" packages/contracts-rfq/test --glob "*.sol"

Length of output: 2363


Script:

#!/bin/bash
# Description: Find to whom GOVERNOR_ROLE is granted in test files
rg "grantRole\s*\(\s*fastBridge\.GOVERNOR_ROLE\(\)\s*,\s*(.+?)\s*\)" packages/contracts-rfq/test --glob "*.sol" -o

Length of output: 536

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

6-6: LGTM: Import statement updated correctly.

The import statement has been updated to include FastBridgeV2DstBaseTest and IFastBridge from the new base test file. This change aligns with the modification in contract inheritance and follows good practices by importing only the necessary components.


Line range hint 20-138: LGTM: Remaining test functions are focused and appropriate.

The removal of several functions and constants (e.g., LEFTOVER_BALANCE, setUp, deployFastBridge, mintTokens, relay, and relayWithAddress) suggests that these have likely been moved to the base test file FastBridgeV2DstBaseTest. This refactoring appears to improve the organization of the test suite.

The remaining functions, including expectBridgeRelayed and various test scenarios, are focused and appropriate for testing the FastBridgeV2Dst contract. They cover different aspects of token and ETH relaying, including edge cases and revert conditions.

To ensure that the removed functions are indeed present in the base test file and that no functionality has been lost, please run the following command:

✅ Verification successful

Verified: Removed functions and constants are correctly present in the base test file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that removed functions exist in the base test file

# Test: Check for the presence of removed functions in the base test file
rg -i "function (setUp|deployFastBridge|mintTokens|relay|relayWithAddress)" packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol

# Also check for the LEFTOVER_BALANCE constant
rg -i "LEFTOVER_BALANCE" packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol

Length of output: 874


9-9: Verify test functionality after inheritance change.

The contract now inherits from FastBridgeV2DstBaseTest instead of FastBridgeV2Test. This change is consistent with the updated import statement and suggests a refactoring of the test structure.

Please ensure that all tests still function correctly after this change. Run the following command to verify:

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

13-15: Verify proper initialization of user balances

Ensure that userB receives the intended balance in both Ether and tokens. Confirm that deal and dstToken.mint correctly initialize userB's balances as expected.


27-28: Ensure LEFTOVER_BALANCE is defined and initialized

The variable LEFTOVER_BALANCE is used in assertions but its declaration and initialization are not shown in this file. Verify that LEFTOVER_BALANCE is properly defined in the test context to prevent assertion failures.


38-39: Consistency in relayer balance assertions

In test_relay_token_withRelayerAddress, the balance of relayerB is asserted against LEFTOVER_BALANCE. Confirm that this behavior is intentional and that relayerB should receive the LEFTOVER_BALANCE instead of relayerA, considering relayerA is specified in the relayWithAddress call.


51-52: Confirm initialization of INITIAL_USER_BALANCE and ethParams.destAmount

The test relies on INITIAL_USER_BALANCE and ethParams.destAmount for balance assertions. Verify that these variables are correctly initialized to reflect the expected balances during the test execution.

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

86-88: Potential conflict with existing assertEq function

The assertEq function defined on lines 86 to 88 may override or conflict with an existing assertEq function from your testing framework. This could lead to confusion or unexpected behavior in your tests.

To verify if this causes any conflicts, run the following script to search for other definitions of assertEq in your codebase:

✅ Verification successful

No conflicting assertEq definitions found

Based on the verification, there are no other assertEq functions defined in the codebase that would conflict with the one in FastBridgeV2.Src.Base.t.sol.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for existing `assertEq` function definitions.

# Test: Find all occurrences of `function assertEq` in Solidity files.
# Expect: Identify if multiple `assertEq` functions exist that could conflict.

rg --type solidity --word-regex --line-number --pretty '^function assertEq'

Length of output: 521


Script:

#!/bin/bash
# Description: Search for existing `assertEq` function definitions.

# Test: Find all occurrences of `function assertEq` in Solidity files.
# Expect: Identify if multiple `assertEq` functions exist that could conflict.

rg --type solidity --word-regexp --line-number --pretty '^function assertEq'

Length of output: 111


Script:

#!/bin/bash
# Description: Search for existing `assertEq` function definitions.

# Test: Find all occurrences of `function assertEq` in Solidity (.sol) files.
# Expect: Identify if multiple `assertEq` functions exist that could conflict.

rg --glob '*.sol' --word-regexp --line-number --pretty '^function assertEq'

Length of output: 77

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

24-31: Initialization functions are well-structured

The setUp, createFixtures, mintTokens, and initExistingTxs functions are correctly implemented and effectively set up the test environment for the gas benchmarking tests.

Also applies to: 33-47, 49-55, 57-72


85-153: Test functions for token bridging operations are comprehensive

The test functions for token operations (bridge, prove, claim, dispute, and refund) are well-implemented and cover various scenarios to ensure the correct functioning of the FastBridgeV2 contract's token handling.


154-222: Test functions for ETH bridging operations are comprehensive

The test functions for ETH operations are effectively designed to benchmark gas usage and validate the behavior of the FastBridgeV2 contract when handling ETH bridging, including edge cases like disputes and refunds.

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

Line range hint 299-299: Correct the spelling of "permisionless" to "permissionless" in the function name.

The function name test_refund_token_permisionless contains a typo. It should be test_refund_token_permissionless to reflect the correct spelling.

[typo]

Apply this diff to fix the typo:

-function test_refund_token_permisionless(address caller) public {
+function test_refund_token_permissionless(address caller) public {

Line range hint 360-360: Correct the spelling of "permisionless" to "permissionless" in the function name.

The function name test_refund_eth_permisionless contains a typo. It should be test_refund_eth_permissionless to reflect the correct spelling.

[typo]

Apply this diff to fix the typo:

-function test_refund_eth_permisionless(address caller) public {
+function test_refund_eth_permissionless(address caller) public {

@ChiTimesChi ChiTimesChi merged commit 0a573d1 into master Sep 27, 2024
52 checks passed
@ChiTimesChi ChiTimesChi deleted the fix/gas-estimation-tests branch September 27, 2024 14:54
ChiTimesChi added a commit that referenced this pull request Sep 27, 2024
ChiTimesChi added a commit that referenced this pull request Oct 1, 2024
* feat: scaffold exclusivity params

* test: update to use V2 structs

* test: exclusivity on DST chain

* test: exclusivity on SRC chain

* feat: exclusivity params in bridge

* feat: update decoding in relay

* feat: check for exclusivity period in relay

* test: disable parity tests (no longer backwards compatible)

* test: expect quoteID-related event

* feat: additional event for tracking quoteID

* fix: ignore code-complexity error for now

* test: more coverage for `bridgeRelayDetails`

* refactor: remove unnecessary casts in tests

* refactor: move txId check, comments

* test: update for changes from #3204

* test: benchmark for SRC exclusivity

* test: benchmark for DST exclusivity

* fix: decode into BridgeTransactionV2
Note: technically this isn't necessary AS OF NOW, as
V2 struct new fields are ignored by the V1 decoding func.

* test: coverage for V1, V2 encoding

* test: coverage for using V1 request instead of V2

* refactor: unroll the nested v2 structure

* test: update for the unrolled struct

* refactor: make backwards-compatible view external

* chore: `foundryup` -> `forge fmt`
yes, this is slightly annoying :(

* refactor: rename event

* fix: post-merge getBridgeTransaction -> getBridgeTransactionV2

* refactor: move public `bridge()`, named vars

* test: use `quoteRelayer` as exclusivity flag

* fix: always use `quoteExclusivitySeconds` as offset in `bridge()`

* fix: don't check `exclusivityEndTime` on relays when `exclusivityRelayer` is not set

* test: add cases for negative `quoteExclusivitySeconds`

* test: enforce `0 < exclusivityEndTime <= deadline`

* feat: negative `quoteExclusivitySeconds`
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