Refactor VPN proxy client implementation
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { parseSubscriptionBody } from '../src/server/subscription.js';
|
||||
import { createStateSnapshot, normalizeStoredState } from '../src/shared/contracts/state.js';
|
||||
import { parseSubscriptionBody } from '../dist/server/subscription.js';
|
||||
import { createStateSnapshot, normalizeStoredState } from '../dist/shared/contracts/state.js';
|
||||
|
||||
const outbound = (index) => ({
|
||||
type: 'vless',
|
||||
@@ -52,3 +52,14 @@ test('data invariant: one canonical snapshot owns server selection and never exp
|
||||
assert.equal(snapshot.servers.find((server) => server.id === selectedServerId)?.host, 'vpn-17.example.test');
|
||||
assert.equal(JSON.stringify(snapshot).includes('private-token'), false);
|
||||
});
|
||||
|
||||
test('persisted numeric IDs and legacy tags keep their previous string normalization', () => {
|
||||
const stored = normalizeStoredState({
|
||||
servers: [{ id: '42', label: '7', host: 'vpn.example', port: 443, protocol: 'vless' }],
|
||||
selectedServerId: 42,
|
||||
appliedTag: 7,
|
||||
});
|
||||
|
||||
assert.equal(stored.selectedServerId, '42');
|
||||
assert.equal(stored.appliedServerId, '42');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user