-
Notifications
You must be signed in to change notification settings - Fork 32
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
Conversation
WalkthroughThe 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 Changes
Poem
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Deploying with Cloudflare Pages
|
45a7443
to
3b21d3c
Compare
* Fixes crvUSD issue * More accurate test suite for realistic bridge routing pairs
3b21d3c
to
6dfd9e2
Compare
There was a problem hiding this 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
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 withtoTokenRouteSymbol
set tostate.toToken?.routeSymbol ?? null
. This means that ifstate.toToken
isnull
orundefined
,toTokenRouteSymbol
will benull
. Ensure that thegetFromTokens
function can handlenull
values fortoTokenRouteSymbol
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
andbridgeable
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
andtoChainId
are provided.277-298: The test case 'has fromChainId, fromToken, toChainId' is well written and covers the scenario where
fromChainId
,fromTokenRouteSymbol
, andtoChainId
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
andfromTokenRouteSymbol
are provided.338-353: The test case 'has fromChainId, toToken' is well written and covers the scenario where
fromChainId
andtoTokenRouteSymbol
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
andtoTokenRouteSymbol
are provided.451-518: The test case 'has fromToken, toToken' is well written and covers the scenario where
fromTokenRouteSymbol
andtoTokenRouteSymbol
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
andfromTokenRouteSymbol
are provided.packages/synapse-interface/__tests__/getToChainIds.test.ts (13)
1-11: The mock for
EXISTING_BRIDGE_ROUTES
is correctly set up to use themockRoutes
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 definedfromChainId
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 definedfromChainId
andtoChainId
. 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 definedfromChainId
,fromTokenRouteSymbol
, andtoChainId
. The expected chain IDs are correctly returned.
82-91: The test case 'has fromChainId, fromToken, toToken' correctly tests the function
getToChainIds
with definedfromChainId
,fromTokenRouteSymbol
, andtoTokenRouteSymbol
. 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 definedfromChainId
andfromTokenRouteSymbol
. The expected chain IDs are correctly returned.
121-132: The test case 'has fromChainId, toToken' correctly tests the function
getToChainIds
with definedfromChainId
andtoTokenRouteSymbol
. The expected chain IDs are correctly returned.134-147: The test case 'has toChainId' correctly tests the function
getToChainIds
with a definedtoChainId
. 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 definedtoChainId
andtoTokenRouteSymbol
. 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 definedfromTokenRouteSymbol
. The expected chain IDs are correctly returned.
175-184: The test case 'has fromToken, toToken' correctly tests the function
getToChainIds
with definedfromTokenRouteSymbol
andtoTokenRouteSymbol
. The expected chain ID is correctly returned.186-195: The test case 'has toToken, m.USDC' correctly tests the function
getToChainIds
with a definedtoTokenRouteSymbol
. 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 onlyfromChainId
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 bothfromChainId
andtoChainId
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 whenfromChainId
,fromTokenRouteSymbol
, andtoChainId
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 whenfromTokenRouteSymbol
andtoChainId
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 whenfromChainId
,fromTokenRouteSymbol
,toChainId
, andtoTokenRouteSymbol
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 whenfromChainId
andfromTokenRouteSymbol
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 whenfromChainId
andtoTokenRouteSymbol
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 onlytoChainId
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 whentoChainId
andtoTokenRouteSymbol
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 onlyfromTokenRouteSymbol
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 whenfromTokenRouteSymbol
andtoTokenRouteSymbol
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 onlytoTokenRouteSymbol
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.
null
e85be50ddb27383acdf2ea0457bac54bdf21d65b: synapse-interface preview link
1799bc4005e5a6a26a7cde570dc44d5dd09f4c3c: synapse-interface preview link
3cfe41d4db0a4a85db9b785b5ab080755fefe262: synapse-interface preview link
Summary by CodeRabbit
getFromChainIds
,getFromTokens
,getToChainIds
, andgetToTokens
functions.getFromChainIds
,getFromTokens
,getToChainIds
, andgetToTokens
functions for improved handling of chain IDs and token symbols.getToTokens
function.bridgeSlice
.