mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-11-02 02:41:54 +00:00
Merge pull request #64 from PR0M3TH3AN/refactor/verify-hardcoded-relays-6138275059730299152
🧹 Verify and test relay configuration logic
This commit is contained in:
1 file changed
+31
-1
@@ -2,7 +2,8 @@ import { test, describe, it, after, beforeEach } from 'node:test';
|
||||
import assert from 'node:assert';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { getTorchConfigPath, parseTorchConfig, loadTorchConfig, _resetTorchConfigCache } from '../src/torch-config.mjs';
|
||||
import { getTorchConfigPath, parseTorchConfig, loadTorchConfig, _resetTorchConfigCache, getRelays } from '../src/torch-config.mjs';
|
||||
import { DEFAULT_RELAYS } from '../src/constants.mjs';
|
||||
|
||||
describe('torch-config', () => {
|
||||
describe('getTorchConfigPath', () => {
|
||||
@@ -181,4 +182,33 @@ describe('torch-config', () => {
|
||||
assert.strictEqual(config1, config2, 'Should be the same object');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRelays', () => {
|
||||
const originalEnv = process.env.NOSTR_LOCK_RELAYS;
|
||||
|
||||
beforeEach(() => {
|
||||
_resetTorchConfigCache();
|
||||
delete process.env.NOSTR_LOCK_RELAYS;
|
||||
});
|
||||
|
||||
after(() => {
|
||||
if (originalEnv === undefined) {
|
||||
delete process.env.NOSTR_LOCK_RELAYS;
|
||||
} else {
|
||||
process.env.NOSTR_LOCK_RELAYS = originalEnv;
|
||||
}
|
||||
_resetTorchConfigCache();
|
||||
});
|
||||
|
||||
it('returns default relays when no config or env var is set', () => {
|
||||
const relays = getRelays();
|
||||
assert.deepStrictEqual(relays, DEFAULT_RELAYS);
|
||||
});
|
||||
|
||||
it('returns relays from env var if set', () => {
|
||||
process.env.NOSTR_LOCK_RELAYS = 'wss://env.relay,wss://env.relay2';
|
||||
const relays = getRelays();
|
||||
assert.deepStrictEqual(relays, ['wss://env.relay', 'wss://env.relay2']);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user