diff --git a/app/features/account/ui/__tests__/AccountDownloadDropdown.test.tsx b/app/features/account/ui/__tests__/AccountDownloadDropdown.test.tsx index 16304b162..9724a4870 100644 --- a/app/features/account/ui/__tests__/AccountDownloadDropdown.test.tsx +++ b/app/features/account/ui/__tests__/AccountDownloadDropdown.test.tsx @@ -1,5 +1,5 @@ import { PublicKey } from '@solana/web3.js'; -import { render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { describe, expect, it, vi } from 'vitest'; import { AccountDownloadDropdown } from '../AccountDownloadDropdown'; @@ -48,7 +48,7 @@ describe('AccountDownloadDropdown', () => { it('should fetch raw data when dropdown opens', () => { render(); - screen.getByText('Download').click(); + fireEvent.click(screen.getByText('Download')); expect(mockMutate).toHaveBeenCalled(); }); diff --git a/app/utils/__tests__/cluster.test.ts b/app/utils/__tests__/cluster.test.ts new file mode 100644 index 000000000..5fb077626 --- /dev/null +++ b/app/utils/__tests__/cluster.test.ts @@ -0,0 +1,29 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import { modifyUrl } from '../cluster'; + +describe('modifyUrl', () => { + afterEach(() => { + vi.unstubAllGlobals(); + }); + + it('returns url unchanged when hostname is localhost', () => { + vi.stubGlobal('location', { hostname: 'localhost' }); + + expect(modifyUrl('https://api.mainnet.solana.com')).toBe('https://api.mainnet.solana.com'); + expect(modifyUrl('https://api.devnet.solana.com')).toBe('https://api.devnet.solana.com'); + }); + + it('replaces "api" with "explorer-api" when hostname is not localhost', () => { + vi.stubGlobal('location', { hostname: 'explorer.solana.com' }); + + expect(modifyUrl('https://api.mainnet.solana.com')).toBe('https://explorer-api.mainnet.solana.com'); + expect(modifyUrl('https://api.devnet.solana.com')).toBe('https://explorer-api.devnet.solana.com'); + }); + + it('returns url unchanged when url has no "api" and hostname is not localhost', () => { + vi.stubGlobal('location', { hostname: 'explorer.solana.com' }); + + expect(modifyUrl('https://simd-0296.surfnet.dev:8899')).toBe('https://simd-0296.surfnet.dev:8899'); + }); +}); diff --git a/app/utils/cluster.ts b/app/utils/cluster.ts index 9ae15758d..04afad455 100644 --- a/app/utils/cluster.ts +++ b/app/utils/cluster.ts @@ -44,7 +44,7 @@ export function clusterName(cluster: Cluster): string { } } -export const MAINNET_BETA_URL = 'https://api.mainnet-beta.solana.com'; +export const MAINNET_BETA_URL = 'https://api.mainnet.solana.com'; export const TESTNET_URL = 'https://api.testnet.solana.com'; export const DEVNET_URL = 'https://api.devnet.solana.com'; export const SIMD296_URL = 'https://simd-0296.surfnet.dev:8899'; @@ -63,7 +63,7 @@ export const SIMD296_URL = 'https://simd-0296.surfnet.dev:8899'; // so there is no need to set it. // For custom RPCs that differ from the defaults you must set both: // NEXT_PUBLIC_*_RPC_URL (client) and *_RPC_URL (server). -const modifyUrl = (url: string): string => { +export const modifyUrl = (url: string): string => { if (typeof window !== 'undefined' && window.location.hostname === 'localhost') { return url; } else { diff --git a/scripts/fetch_mainnet_activations.py b/scripts/fetch_mainnet_activations.py index ac6a43997..581375848 100644 --- a/scripts/fetch_mainnet_activations.py +++ b/scripts/fetch_mainnet_activations.py @@ -6,7 +6,7 @@ import json FEATURE_GATES_PATH = 'app/utils/feature-gate/featureGates.json' -MAINNET_RPC_URL = 'https://api.mainnet-beta.solana.com' +MAINNET_RPC_URL = 'https://api.mainnet.solana.com' RATE_LIMIT_DELAY = 0.5 MAX_RETRIES = 3