mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-06 12:51:54 +00:00
Refactor: consolidate mergeRelayList into utils.mjs
- Moved `mergeRelayList` from `src/lock-ops.mjs` and `src/lock-publisher.mjs` to `src/utils.mjs`. - Updated imports in `src/lock-ops.mjs` and `src/lock-publisher.mjs`. - Added unit tests for `mergeRelayList` in `test/utils.test.mjs`. - Restored `torch-config-test.json` which was deleted by the test suite. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
2b8a0c3d0d
commit
f54c540070
4 files changed
+24
-10
No files matched your search
+18
-1
@@ -2,7 +2,7 @@ import { describe, it, after } from 'node:test';
|
||||
import assert from 'node:assert';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { getIsoWeekStr, todayDateStr, nowUnix, ensureDir, detectPlatform } from '../src/utils.mjs';
|
||||
import { getIsoWeekStr, todayDateStr, nowUnix, ensureDir, detectPlatform, mergeRelayList } from '../src/utils.mjs';
|
||||
|
||||
describe('Date Utilities', () => {
|
||||
describe('todayDateStr', () => {
|
||||
@@ -59,6 +59,23 @@ describe('Date Utilities', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Relay Utilities', () => {
|
||||
describe('mergeRelayList', () => {
|
||||
it('merges two lists of relays without duplicates', () => {
|
||||
const primary = ['wss://relay1.com', 'wss://relay2.com'];
|
||||
const fallback = ['wss://relay2.com', 'wss://relay3.com'];
|
||||
const merged = mergeRelayList(primary, fallback);
|
||||
assert.deepStrictEqual(merged, ['wss://relay1.com', 'wss://relay2.com', 'wss://relay3.com']);
|
||||
});
|
||||
|
||||
it('handles empty lists', () => {
|
||||
assert.deepStrictEqual(mergeRelayList([], []), []);
|
||||
assert.deepStrictEqual(mergeRelayList(['wss://relay1.com'], []), ['wss://relay1.com']);
|
||||
assert.deepStrictEqual(mergeRelayList([], ['wss://relay1.com']), ['wss://relay1.com']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Platform Utilities', () => {
|
||||
describe('detectPlatform', () => {
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
Reference in new issue
Block a user