|
| 1 | +import { |
| 2 | + DEFAULT_HEIMDALL_HTTP_SERVER_URL, |
| 3 | + DEFAULT_HEIMDALL_RATE_LIMIT, |
| 4 | + DEFAULT_HEIMDALL_WS_SERVER_URL, |
| 5 | + resolveHeimdallRuntimeConfig, |
| 6 | + resolveHeimdallSetupConfig, |
| 7 | +} from './heimdallConfig'; |
| 8 | + |
| 9 | +describe('heimdall configuration compatibility', () => { |
| 10 | + it('prefers new setup keys when present', () => { |
| 11 | + expect(resolveHeimdallSetupConfig({ |
| 12 | + heimdall_http_server_url: 'http://heimdall.example/http', |
| 13 | + heimdall_ws_server_url: 'ws://heimdall.example/ws', |
| 14 | + })).toEqual({ |
| 15 | + heimdallHttpServerUrl: 'http://heimdall.example/http', |
| 16 | + heimdallWsServerUrl: 'ws://heimdall.example/ws', |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + it('falls back to legacy setup keys when the new keys are absent', () => { |
| 21 | + expect(resolveHeimdallSetupConfig({ |
| 22 | + aggregator_http_server_url: 'http://legacy.example/http', |
| 23 | + aggregator_ws_server_url: 'ws://legacy.example/ws', |
| 24 | + })).toEqual({ |
| 25 | + heimdallHttpServerUrl: 'http://legacy.example/http', |
| 26 | + heimdallWsServerUrl: 'ws://legacy.example/ws', |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + it('prefers new setup keys over legacy setup keys when both are present', () => { |
| 31 | + expect(resolveHeimdallSetupConfig({ |
| 32 | + heimdall_http_server_url: 'http://heimdall.example/http', |
| 33 | + aggregator_http_server_url: 'http://legacy.example/http', |
| 34 | + heimdall_ws_server_url: 'ws://heimdall.example/ws', |
| 35 | + aggregator_ws_server_url: 'ws://legacy.example/ws', |
| 36 | + })).toEqual({ |
| 37 | + heimdallHttpServerUrl: 'http://heimdall.example/http', |
| 38 | + heimdallWsServerUrl: 'ws://heimdall.example/ws', |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('preserves the current defaults when neither setup key exists', () => { |
| 43 | + expect(resolveHeimdallSetupConfig({})).toEqual({ |
| 44 | + heimdallHttpServerUrl: DEFAULT_HEIMDALL_HTTP_SERVER_URL, |
| 45 | + heimdallWsServerUrl: DEFAULT_HEIMDALL_WS_SERVER_URL, |
| 46 | + }); |
| 47 | + }); |
| 48 | + |
| 49 | + it('prefers the new runtime key when present', () => { |
| 50 | + expect(resolveHeimdallRuntimeConfig({ |
| 51 | + aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/', |
| 52 | + heimdall_rate_limit: 15, |
| 53 | + })).toEqual({ |
| 54 | + aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/', |
| 55 | + heimdallRateLimit: 15, |
| 56 | + }); |
| 57 | + }); |
| 58 | + |
| 59 | + it('falls back to the legacy runtime key when the new key is absent', () => { |
| 60 | + expect(resolveHeimdallRuntimeConfig({ |
| 61 | + aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/', |
| 62 | + aggregator_rate_limit: 20, |
| 63 | + })).toEqual({ |
| 64 | + aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/', |
| 65 | + heimdallRateLimit: 20, |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
| 69 | + it('prefers the new runtime key over the legacy runtime key when both are present', () => { |
| 70 | + expect(resolveHeimdallRuntimeConfig({ |
| 71 | + aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/', |
| 72 | + heimdall_rate_limit: 10, |
| 73 | + aggregator_rate_limit: 25, |
| 74 | + })).toEqual({ |
| 75 | + aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/', |
| 76 | + heimdallRateLimit: 10, |
| 77 | + }); |
| 78 | + }); |
| 79 | + |
| 80 | + it('preserves the current runtime default when neither rate-limit key exists', () => { |
| 81 | + expect(resolveHeimdallRuntimeConfig({ |
| 82 | + aggregation_pod_ldes_location: 'http://localhost:3000/aggregation_pod/', |
| 83 | + })).toEqual({ |
| 84 | + aggregationPodLdesLocation: 'http://localhost:3000/aggregation_pod/', |
| 85 | + heimdallRateLimit: DEFAULT_HEIMDALL_RATE_LIMIT, |
| 86 | + }); |
| 87 | + }); |
| 88 | +}); |
0 commit comments