@@ -3,6 +3,7 @@ import { join } from 'path';
33import {
44 CHAIN_IDS ,
55 CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP ,
6+ FEATURED_RPCS ,
67 NETWORK_TO_NAME_MAP ,
78} from './network' ;
89
@@ -24,4 +25,70 @@ describe('NetworkConstants', () => {
2425 expect ( NETWORK_TO_NAME_MAP [ CHAIN_IDS . OPTIMISM ] ) . toBe ( 'OP Mainnet' ) ;
2526 expect ( NETWORK_TO_NAME_MAP [ CHAIN_IDS . POLYGON ] ) . toBe ( 'Polygon' ) ;
2627 } ) ;
28+ describe ( 'popularNetwork' , ( ) => {
29+ it ( 'should have correct chainIds for all popular network' , ( ) => {
30+ const expectedChainIds : { [ key : string ] : string } = {
31+ 'Arbitrum One' : CHAIN_IDS . ARBITRUM ,
32+ 'Avalanche Network C-Chain' : CHAIN_IDS . AVALANCHE ,
33+ 'BNB Chain' : CHAIN_IDS . BSC ,
34+ 'OP Mainnet' : CHAIN_IDS . OPTIMISM ,
35+ 'Polygon Mainnet' : CHAIN_IDS . POLYGON ,
36+ 'zkSync Era Mainnet' : CHAIN_IDS . ZKSYNC_ERA ,
37+ 'Base Mainnet' : CHAIN_IDS . BASE ,
38+ } ;
39+
40+ FEATURED_RPCS . forEach ( ( rpc ) => {
41+ expect ( rpc . chainId ) . toBe ( expectedChainIds [ rpc . nickname ] ) ;
42+ } ) ;
43+ } ) ;
44+ } ) ;
45+
46+ describe ( 'FEATURED_RPCS Infura Usage Tests' , ( ) => {
47+ it ( 'arbitrum entry should use Infura' , ( ) => {
48+ const arbitrumRpc = FEATURED_RPCS . find (
49+ ( rpc ) => rpc . chainId === CHAIN_IDS . ARBITRUM ,
50+ ) ;
51+ expect ( arbitrumRpc ?. rpcUrl ) . toContain ( 'infura.io' ) ;
52+ } ) ;
53+
54+ it ( 'avalanche entry should use Infura' , ( ) => {
55+ const avalancheRpc = FEATURED_RPCS . find (
56+ ( rpc ) => rpc . chainId === CHAIN_IDS . AVALANCHE ,
57+ ) ;
58+ expect ( avalancheRpc ?. rpcUrl ) . toContain ( 'infura.io' ) ;
59+ } ) ;
60+
61+ it ( 'bsc entry should not use Infura' , ( ) => {
62+ const bscRpc = FEATURED_RPCS . find ( ( rpc ) => rpc . chainId === CHAIN_IDS . BSC ) ;
63+ expect ( bscRpc ?. rpcUrl ) . not . toContain ( 'infura.io' ) ;
64+ } ) ;
65+
66+ it ( 'optimism entry should use Infura' , ( ) => {
67+ const optimismRpc = FEATURED_RPCS . find (
68+ ( rpc ) => rpc . chainId === CHAIN_IDS . OPTIMISM ,
69+ ) ;
70+ expect ( optimismRpc ?. rpcUrl ) . toContain ( 'infura.io' ) ;
71+ } ) ;
72+
73+ it ( 'polygon entry should use Infura' , ( ) => {
74+ const polygonRpc = FEATURED_RPCS . find (
75+ ( rpc ) => rpc . chainId === CHAIN_IDS . POLYGON ,
76+ ) ;
77+ expect ( polygonRpc ?. rpcUrl ) . toContain ( 'infura.io' ) ;
78+ } ) ;
79+
80+ it ( 'zkSync Era entry should not use Infura' , ( ) => {
81+ const zksyncEraRpc = FEATURED_RPCS . find (
82+ ( rpc ) => rpc . chainId === CHAIN_IDS . ZKSYNC_ERA ,
83+ ) ;
84+ expect ( zksyncEraRpc ?. rpcUrl ) . not . toContain ( 'infura.io' ) ;
85+ } ) ;
86+
87+ it ( 'base entry should not use Infura' , ( ) => {
88+ const baseRpc = FEATURED_RPCS . find (
89+ ( rpc ) => rpc . chainId === CHAIN_IDS . BASE ,
90+ ) ;
91+ expect ( baseRpc ?. rpcUrl ) . not . toContain ( 'infura.io' ) ;
92+ } ) ;
93+ } ) ;
2794} ) ;
0 commit comments