|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import ethereumConfig from './configs/ethereum.json'; |
| 3 | +import polygonConfig from './configs/polygon.json'; |
| 4 | +import arbitrumConfig from './configs/arbitrum.json'; |
| 5 | +import optimismConfig from './configs/optimism.json'; |
| 6 | +import baseConfig from './configs/base.json'; |
| 7 | + |
| 8 | +describe('chain configs: decentralized-first endpoints', () => { |
| 9 | + const configs = [ |
| 10 | + { name: 'Ethereum', config: ethereumConfig, poktDomain: 'eth-pokt.nodies.app' }, |
| 11 | + { name: 'Polygon', config: polygonConfig, poktDomain: 'polygon-pokt.nodies.app' }, |
| 12 | + { name: 'Arbitrum', config: arbitrumConfig, poktDomain: 'arb-pokt.nodies.app' }, |
| 13 | + { name: 'Optimism', config: optimismConfig, poktDomain: 'op-pokt.nodies.app' }, |
| 14 | + ]; |
| 15 | + |
| 16 | + for (const { name, config, poktDomain } of configs) { |
| 17 | + describe(name, () => { |
| 18 | + it('should have POKT (Nodies) as the first HTTP endpoint', () => { |
| 19 | + expect(config.endpoints.http[0]).toContain(poktDomain); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should not have Alchemy or Infura endpoints', () => { |
| 23 | + for (const url of config.endpoints.http) { |
| 24 | + expect(url).not.toContain('alchemy'); |
| 25 | + expect(url).not.toContain('infura'); |
| 26 | + } |
| 27 | + }); |
| 28 | + |
| 29 | + it('should not contain API keys in any endpoint URL', () => { |
| 30 | + for (const url of config.endpoints.http) { |
| 31 | + // No /v2/<key> or /v3/<key> patterns |
| 32 | + expect(url).not.toMatch(/\/v[23]\/[a-zA-Z0-9]{20,}/); |
| 33 | + } |
| 34 | + if (config.endpoints.ws) { |
| 35 | + for (const url of config.endpoints.ws) { |
| 36 | + expect(url).not.toMatch(/\/v[23]\/[a-zA-Z0-9]{20,}/); |
| 37 | + } |
| 38 | + } |
| 39 | + }); |
| 40 | + |
| 41 | + it('should have at least 3 HTTP fallback endpoints', () => { |
| 42 | + expect(config.endpoints.http.length).toBeGreaterThanOrEqual(3); |
| 43 | + }); |
| 44 | + }); |
| 45 | + } |
| 46 | + |
| 47 | + describe('Base (no POKT available)', () => { |
| 48 | + it('should have public endpoints as primary', () => { |
| 49 | + expect(baseConfig.endpoints.http.length).toBeGreaterThanOrEqual(3); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should not have Alchemy or Infura endpoints', () => { |
| 53 | + for (const url of baseConfig.endpoints.http) { |
| 54 | + expect(url).not.toContain('alchemy'); |
| 55 | + expect(url).not.toContain('infura'); |
| 56 | + } |
| 57 | + }); |
| 58 | + }); |
| 59 | +}); |
0 commit comments