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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,429 changes: 3,429 additions & 0 deletions packages/synapse-interface/__tests__/__fixtures__/mockRoutes.ts

Large diffs are not rendered by default.

105 changes: 65 additions & 40 deletions packages/synapse-interface/__tests__/getFromChainIds.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import { expect } from '@jest/globals'

import { getFromChainIds } from '@/utils/routeMaker/getFromChainIds'
import { mockRoutes } from './__fixtures__/mockRoutes'

jest.mock('../constants/existingBridgeRoutes', () => ({
__esModule: true,
EXISTING_BRIDGE_ROUTES: {
'GOHM-1': ['GOHM-10', 'GOHM-25', 'GOHM-56'],
'GOHM-10': ['GOHM-1', 'GOHM-25', 'GOHM-56'],
'GOHM-25': ['GOHM-1', 'GOHM-10', 'GOHM-56'],
'GOHM-56': ['GOHM-1', 'GOHM-10', 'GOHM-25'],
'HIGH-1': ['HIGH-56'],
'HIGH-56': ['HIGH-1'],
'USDC-1': ['USDC-10', 'USDC-25', 'USDC-56', 'NUSD-10'],
'NUSD-10': ['USDC-1'],
'USDC-10': ['USDC-1', 'USDC-25', 'USDC-56'],
'USDC-25': ['USDC-1', 'USDC-10', 'USDC-56'],
'USDC-56': ['USDC-1', 'USDC-10', 'USDC-25'],
'SYN-1': ['SYN-10', 'SYN-25', 'SYN-56'],
'SYN-10': ['SYN-1', 'SYN-25', 'SYN-56'],
'SYN-25': ['SYN-1', 'SYN-10', 'SYN-56'],
'SYN-56': ['SYN-1', 'SYN-10', 'SYN-25'],
'XYZ-50': ['XYZ-1'],
'XYZ-1': ['XYZ-50'],
get EXISTING_BRIDGE_ROUTES() {
return mockRoutes
},
}))

Expand All @@ -48,7 +32,12 @@ describe('getFromChainIds', () => {
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 10, 25, 56, 50])
expect(chainIds.sort()).toEqual(
[
1, 10, 1284, 8217, 43114, 53935, 1666600000, 56, 137, 288, 2000, 8453,
42161, 7700, 250, 1285, 1088, 25, 1313161554,
].sort()
)
})

it('has fromChainId', () => {
Expand All @@ -59,7 +48,12 @@ describe('getFromChainIds', () => {
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 10, 25, 56, 50])
expect(chainIds.sort()).toEqual(
[
1, 10, 1284, 8217, 43114, 53935, 1666600000, 56, 137, 288, 2000, 8453,
42161, 7700, 250, 1285, 1088, 25, 1313161554,
].sort()
)
})

it('has fromChainId, toChainId', () => {
Expand All @@ -70,18 +64,23 @@ describe('getFromChainIds', () => {
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 25, 56])
expect(chainIds.sort()).toEqual(
[
56, 1, 137, 288, 8453, 42161, 43114, 7700, 53935, 1284, 1285, 25, 250,
1088, 2000, 1313161554, 1666600000,
].sort()
)
})

it('has fromChainId, fromToken, toChainId', () => {
const chainIds = getFromChainIds({
fromChainId: 1,
fromTokenRouteSymbol: 'USDC',
fromChainId: 8453,
fromTokenRouteSymbol: 'crvUSD',
toChainId: 10,
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 25, 56])
expect(chainIds).toEqual([8453])
})

it('has fromChainId, fromToken, toChainId, toToken', () => {
Expand All @@ -92,62 +91,79 @@ describe('getFromChainIds', () => {
toTokenRouteSymbol: 'USDC',
})

expect(chainIds).toEqual([1, 25, 56])
expect(chainIds).toEqual([1, 8453, 42161, 43114])
})

it('has fromChainId, fromToken', () => {
const chainIds = getFromChainIds({
fromChainId: 1,
fromTokenRouteSymbol: 'USDC',
fromChainId: 8453,
fromTokenRouteSymbol: 'crvUSD',
toChainId: null,
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 10, 25, 56])
expect(chainIds).toEqual([8453])
})

it('has fromChainId, toToken', () => {
const chainIds = getFromChainIds({
fromChainId: 1,
fromTokenRouteSymbol: null,
toChainId: null,
toTokenRouteSymbol: 'XYZ',
toTokenRouteSymbol: 'crvUSD',
})

expect(chainIds).toEqual([1, 50])
expect(chainIds).toEqual([
10, 25, 56, 137, 250, 288, 1088, 2000, 7700, 8217, 8453, 42161, 43114,
53935, 1313161554, 1666600000, 1,
])
})

it('has toChainId', () => {
const chainIds = getFromChainIds({
fromChainId: null,
fromTokenRouteSymbol: null,
toChainId: 50,
toChainId: 8217,
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1])
expect(chainIds).toEqual([1284, 43114, 53935, 1666600000, 1, 2000])
})

it('has toChainId, toToken', () => {
const chainIds = getFromChainIds({
fromChainId: null,
fromTokenRouteSymbol: null,
toChainId: 1088,
toTokenRouteSymbol: 'm.USDC',
})

expect(chainIds).toEqual([
56, 1, 10, 137, 288, 42161, 43114, 7700, 25, 53935, 1313161554, 250,
1666600000,
])
})

it('has toChainId, toToken, non-existent path', () => {
const chainIds = getFromChainIds({
fromChainId: null,
fromTokenRouteSymbol: null,
toChainId: 50,
toTokenRouteSymbol: 'XYZ',
toTokenRouteSymbol: 'crvUSD',
})

expect(chainIds).toEqual([1])
expect(chainIds).toEqual([])
})

it('has fromToken', () => {
const chainIds = getFromChainIds({
fromChainId: null,
fromTokenRouteSymbol: 'USDC',
fromTokenRouteSymbol: 'crvUSD',
toChainId: null,
toTokenRouteSymbol: null,
})

expect(chainIds).toEqual([1, 10, 25, 56])
expect(chainIds).toEqual([8453])
})

it('has fromToken, toToken', () => {
Expand All @@ -158,17 +174,26 @@ describe('getFromChainIds', () => {
toTokenRouteSymbol: 'USDC',
})

expect(chainIds.sort()).toEqual([1, 10, 25, 56].sort())
expect(chainIds.sort()).toEqual(
[
1, 10, 137, 2000, 25, 288, 42161, 43114, 53935, 56, 7700, 8217, 8453,
].sort()
)
})

it('has toToken', () => {
const chainIds = getFromChainIds({
fromChainId: null,
fromTokenRouteSymbol: null,
toChainId: null,
toTokenRouteSymbol: 'XYZ',
toTokenRouteSymbol: 'USDC.e',
})

expect(chainIds.sort()).toEqual([50, 1].sort())
expect(chainIds.sort()).toEqual(
[
1, 10, 1088, 1313161554, 137, 1666600000, 2000, 25, 250, 288, 42161,
43114, 53935, 56, 7700, 8217, 8453,
].sort()
)
})
})
Loading
Loading