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

Routing selection update, expanded test suite for realistic routing options #1534

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

abtestingalpha
Copy link
Collaborator

@abtestingalpha abtestingalpha commented Nov 3, 2023

null
e85be50ddb27383acdf2ea0457bac54bdf21d65b: synapse-interface preview link
1799bc4005e5a6a26a7cde570dc44d5dd09f4c3c: synapse-interface preview link
3cfe41d4db0a4a85db9b785b5ab080755fefe262: synapse-interface preview link

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for getFromChainIds, getFromTokens, getToChainIds, and getToTokens functions.
  • Refactor
    • Updated getFromChainIds, getFromTokens, getToChainIds, and getToTokens functions for improved handling of chain IDs and token symbols.
  • Chores
    • Adjusted Jest configuration for better test path management.
  • Bug Fixes
    • Ensured unique return values in getToTokens function.
    • Improved token retrieval based on route symbol in bridgeSlice.

Copy link
Contributor

coderabbitai bot commented Nov 3, 2023

Walkthrough

The changes primarily revolve around the refactoring of test cases and functions in the Synapse Interface package. The modifications include importing mock routes from a separate file, updating function behavior to handle different chain IDs and token symbols, and adjusting test cases to reflect these changes. Additionally, the Jest configuration and the bridgeSlice in the reducer have been updated.

Changes

File(s) Change Summary
.../__tests__/getFromChainIds.test.ts, .../__tests__/getFromTokens.test.ts, .../__tests__/getToChainIds.test.ts, .../__tests__/getToTokens.test.ts Refactored test cases and functions. Mock routes are now imported from a separate file. Test cases have been updated to reflect changes in function behavior and mock routes.
.../jest.config.mjs Added moduleNameMapper configuration and testPathIgnorePatterns array to Jest configuration.
.../slices/bridge/reducer.ts Updated bridgeSlice to set toTokenRouteSymbol to the route symbol of state.toToken if it exists.
.../utils/routeMaker/getToChainIds.ts, .../utils/routeMaker/getToTokens.ts Updated function behavior. getToChainIds now filters tokens before extracting chain IDs. getToTokens now wraps return value in _.uniq to ensure unique values.

Poem

🐇 Hopping through the code, with changes in our stride,
Refactoring the tests, with logic clarified.
🍂 As autumn leaves fall, we've tidied up our nest,
With unique tokens and routes, we're simply the best.
🌕 Under the November moon, we celebrate this day,
For in the world of code, we've found a better way.
So here's to all the coders, working night and day,
Your efforts are appreciated, in every single way! 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (413a921) 51.23324% compared to head (6dfd9e2) 51.23324%.
Report is 3 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##              master       #1534   +/-   ##
=============================================
  Coverage   51.23324%   51.23324%           
=============================================
  Files            362         362           
  Lines          24691       24691           
  Branches         283         283           
=============================================
  Hits           12650       12650           
  Misses         10813       10813           
  Partials        1228        1228           
Flag Coverage Δ
packages 91.00610% <ø> (ø)

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

cloudflare-workers-and-pages bot commented Nov 3, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6dfd9e2
Status: ✅  Deploy successful!
Preview URL: https://e3f6b98b.sanguine.pages.dev
Branch Preview URL: https://fe-fix-routing-selections.sanguine.pages.dev

View logs

@abtestingalpha abtestingalpha force-pushed the fe/fix-routing-selections branch from 45a7443 to 3b21d3c Compare November 3, 2023 23:48
* Fixes crvUSD issue
* More accurate test suite for realistic bridge routing pairs
@abtestingalpha abtestingalpha force-pushed the fe/fix-routing-selections branch from 3b21d3c to 6dfd9e2 Compare November 7, 2023 18:22
@abtestingalpha abtestingalpha marked this pull request as ready for review November 7, 2023 19:45
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3864694 and 6dfd9e2.
Files selected for processing (8)
  • packages/synapse-interface/tests/getFromChainIds.test.ts (6 hunks)
  • packages/synapse-interface/tests/getFromTokens.test.ts (4 hunks)
  • packages/synapse-interface/tests/getToChainIds.test.ts (7 hunks)
  • packages/synapse-interface/tests/getToTokens.test.ts (8 hunks)
  • packages/synapse-interface/jest.config.mjs (1 hunks)
  • packages/synapse-interface/slices/bridge/reducer.ts (1 hunks)
  • packages/synapse-interface/utils/routeMaker/getToChainIds.ts (1 hunks)
  • packages/synapse-interface/utils/routeMaker/getToTokens.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/jest.config.mjs
Additional comments: 48
packages/synapse-interface/slices/bridge/reducer.ts (1)
  • 287-293: The getFromTokens function is called with toTokenRouteSymbol set to state.toToken?.routeSymbol ?? null. This means that if state.toToken is null or undefined, toTokenRouteSymbol will be null. Ensure that the getFromTokens function can handle null values for toTokenRouteSymbol correctly.
packages/synapse-interface/utils/routeMaker/getToTokens.ts (1)
  • 208-214: The use of _.uniq here ensures that the returned array contains unique values, which is a good practice to avoid duplicates. However, it's important to note that _.uniq uses the SameValueZero equality comparison (which is similar to strict equality ===), so it may not work as expected with complex data types. In this case, it should work fine as the data seems to be strings.
packages/synapse-interface/__tests__/getFromChainIds.test.ts (7)
  • 1-11: The mock setup for EXISTING_BRIDGE_ROUTES is good. It allows for better control over the test environment.

  • 32-40: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

  • 48-56: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

  • 64-72: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

  • 91-94: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

  • 174-181: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

  • 192-197: Ensure that the expected output is correct and matches the updated logic of the getFromChainIds function.

packages/synapse-interface/__tests__/getFromTokens.test.ts (13)
  • 1-11: The mock setup for EXISTING_BRIDGE_ROUTES is good. It helps to isolate the unit tests from the actual data.

  • 16-22: The mock setup for flattenPausedTokens and bridgeable is also good. It helps to isolate the unit tests from the actual data.

  • 34-232: The test case 'all entries null' is comprehensive and covers a wide range of expected return values. It's good to see that the test case is updated to reflect the changes in the function's behavior.

  • 235-254: The test case 'has fromChainId' is well written and covers the scenario where only the fromChainId is provided.

  • 256-275: The test case 'has fromChainId, toChainId' is well written and covers the scenario where both fromChainId and toChainId are provided.

  • 277-298: The test case 'has fromChainId, fromToken, toChainId' is well written and covers the scenario where fromChainId, fromTokenRouteSymbol, and toChainId are provided.

  • 300-315: The test case 'has fromChainId, fromToken, toChainId, toToken' is well written and covers the scenario where all parameters are provided.

  • 317-336: The test case 'has fromChainId, fromToken' is well written and covers the scenario where fromChainId and fromTokenRouteSymbol are provided.

  • 338-353: The test case 'has fromChainId, toToken' is well written and covers the scenario where fromChainId and toTokenRouteSymbol are provided.

  • 355-421: The test case 'has toChainId' is well written and covers the scenario where only the toChainId is provided.

  • 423-449: The test case 'has toChainId, toToken' is well written and covers the scenario where toChainId and toTokenRouteSymbol are provided.

  • 451-518: The test case 'has fromToken, toToken' is well written and covers the scenario where fromTokenRouteSymbol and toTokenRouteSymbol are provided.

  • 526-547: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [520-545]

The test case 'has FromChainId and fromToken' is well written and covers the scenario where fromChainId and fromTokenRouteSymbol are provided.

packages/synapse-interface/__tests__/getToChainIds.test.ts (13)
  • 1-11: The mock for EXISTING_BRIDGE_ROUTES is correctly set up to use the mockRoutes from the fixtures. This ensures that the tests are not dependent on the actual routes but on the mock data.

  • 32-50: The test case 'has fromChainId' correctly tests the function getToChainIds with a defined fromChainId and expects the correct chain IDs in return.

  • 57-68: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [52-66]

The test case 'has fromChainId, toChainId' correctly tests the function getToChainIds with defined fromChainId and toChainId. The expected result is sorted to avoid false negatives due to order differences.

  • 73-93: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [68-80]

The test case 'has fromChainId, fromToken, toChainId' correctly tests the function getToChainIds with defined fromChainId, fromTokenRouteSymbol, and toChainId. The expected chain IDs are correctly returned.

  • 82-91: The test case 'has fromChainId, fromToken, toToken' correctly tests the function getToChainIds with defined fromChainId, fromTokenRouteSymbol, and toTokenRouteSymbol. The expected chain ID is correctly returned.

  • 98-107: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [93-105]

The test case 'has fromChainId, fromToken, toChainId, toToken' correctly tests the function getToChainIds with all parameters defined. The expected chain IDs are correctly returned.

  • 112-161: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [107-119]

The test case 'has fromChainId, fromToken' correctly tests the function getToChainIds with defined fromChainId and fromTokenRouteSymbol. The expected chain IDs are correctly returned.

  • 121-132: The test case 'has fromChainId, toToken' correctly tests the function getToChainIds with defined fromChainId and toTokenRouteSymbol. The expected chain IDs are correctly returned.

  • 134-147: The test case 'has toChainId' correctly tests the function getToChainIds with a defined toChainId. The expected result is sorted to avoid false negatives due to order differences.

  • 150-159: The test case 'has toChainId, toToken' correctly tests the function getToChainIds with defined toChainId and toTokenRouteSymbol. The expected chain ID is correctly returned.

  • 166-196: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [161-173]

The test case 'has fromToken' correctly tests the function getToChainIds with a defined fromTokenRouteSymbol. The expected chain IDs are correctly returned.

  • 175-184: The test case 'has fromToken, toToken' correctly tests the function getToChainIds with defined fromTokenRouteSymbol and toTokenRouteSymbol. The expected chain ID is correctly returned.

  • 186-195: The test case 'has toToken, m.USDC' correctly tests the function getToChainIds with a defined toTokenRouteSymbol. The expected chain ID is correctly returned.

packages/synapse-interface/__tests__/getToTokens.test.ts (13)
  • 1-10: The mock setup for EXISTING_BRIDGE_ROUTES is correct and ensures that the tests use the mock data.

  • 26-61: This test case checks the getToTokens function when only fromChainId is provided. The expected output is a sorted array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 64-82: This test case checks the getToTokens function when both fromChainId and toChainId are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 84-99: This test case checks the getToTokens function when fromChainId, fromTokenRouteSymbol, and toChainId are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 106-119: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [101-117]

This test case checks the getToTokens function when fromTokenRouteSymbol and toChainId are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 124-273: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [119-134]

This test case checks the getToTokens function when fromChainId, fromTokenRouteSymbol, toChainId, and toTokenRouteSymbol are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 137-146: This test case checks the getToTokens function when fromChainId and fromTokenRouteSymbol are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 148-272: This test case checks the getToTokens function when fromChainId and toTokenRouteSymbol are provided. The expected output is a sorted array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 276-294: This test case checks the getToTokens function when only toChainId is provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 296-306: This test case checks the getToTokens function when toChainId and toTokenRouteSymbol are provided. The expected output is an array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 308-318: This test case checks the getToTokens function when only fromTokenRouteSymbol is provided. The expected output is a sorted array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 323-391: This test case checks the getToTokens function when fromTokenRouteSymbol and toTokenRouteSymbol are provided. The expected output is a sorted array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

  • 396-597: This test case checks the getToTokens function when only toTokenRouteSymbol is provided. The expected output is a sorted array of token symbols. Ensure that the expected output matches the actual output of the function when run with the same input.

@abtestingalpha abtestingalpha merged commit 32f7496 into master Nov 7, 2023
49 checks passed
@abtestingalpha abtestingalpha deleted the fe/fix-routing-selections branch November 7, 2023 20:01
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.

2 participants