Files
Firelink/scripts/aria2-route-contract.node-test.js
T
NimBold 3624db280c fix(downloads): report torrent allocation and remove files asynchronously
- Add lifecycle-fenced Aria2 allocation telemetry and shared animated status presentation.
- Persist background removal jobs, retain Removing rows, and provide explicit retry after failures.
- Fence cleanup against stale dispatch, native controls, completion races, and replaced assets across restart.
- Preserve completed and seeding payloads through Trash and permit safe permission-repair retries.
- Require patched engine capabilities and reproducible Windows/Linux provisioning; isolate packaged smoke storage.
- Verify 561 frontend tests, 672 native tests, 72 script tests, i18n/build checks, and macOS package/engine smoke checks.
2026-09-06 15:26:59 +03:30

91 lines
3.0 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
assertAria2AllocationCapabilities,
ARIA2_DNS_RESOLVER,
ARIA2_FIRELINK_REVISION,
ARIA2_NETWORK_TARGET_POLICY,
ARIA2_NETWORK_TARGET_POLICY_DIGEST,
assertAria2SystemResolverOptions,
assertAria2RouteCapabilities,
assertAria2RouteContract,
assertAria2RouteSource,
} from './aria2-route-contract.js';
const secureVersion = {
enabledFeatures: ['Async DNS'],
firelinkRevision: ARIA2_FIRELINK_REVISION,
firelinkDnsResolver: ARIA2_DNS_RESOLVER,
firelinkDnsResolvers: [ARIA2_DNS_RESOLVER],
firelinkNetworkTargetPolicies: ['none', ARIA2_NETWORK_TARGET_POLICY],
firelinkNetworkTargetPolicy: ARIA2_NETWORK_TARGET_POLICY,
firelinkNetworkTargetPolicyDigest: ARIA2_NETWORK_TARGET_POLICY_DIGEST,
firelinkNetworkTargetPolicyEnforced: true,
};
test('Aria2 source metadata must identify the Firelink route contract', () => {
const source = {
firelinkRouteContract: {
revision: ARIA2_FIRELINK_REVISION,
dnsResolver: ARIA2_DNS_RESOLVER,
networkTargetPolicy: ARIA2_NETWORK_TARGET_POLICY,
networkTargetPolicyDigest: ARIA2_NETWORK_TARGET_POLICY_DIGEST,
},
};
assert.doesNotThrow(() => assertAria2RouteSource(source, 'test-target'));
assert.throws(
() => assertAria2RouteSource({}, 'test-target'),
/not a Firelink route-contract build/,
);
assert.throws(
() => assertAria2RouteSource({
firelinkRouteContract: {
...source.firelinkRouteContract,
networkTargetPolicyDigest: 'sha256:wrong',
},
}, 'test-target'),
/networkTargetPolicyDigest/,
);
});
test('route capabilities are distinct from the active local-fixture policy', () => {
assert.doesNotThrow(() => assertAria2RouteCapabilities({
...secureVersion,
firelinkNetworkTargetPolicy: 'none',
firelinkNetworkTargetPolicyEnforced: false,
}));
assert.doesNotThrow(() => assertAria2RouteContract(secureVersion));
assert.throws(
() => assertAria2RouteContract({
...secureVersion,
firelinkNetworkTargetPolicy: 'none',
firelinkNetworkTargetPolicyEnforced: false,
}),
/route contract mismatch for firelinkNetworkTargetPolicy/,
);
});
test('system resolver options cannot retain the custom target policy', () => {
assert.doesNotThrow(() => assertAria2SystemResolverOptions({
'async-dns': 'false',
}));
assert.doesNotThrow(() => assertAria2SystemResolverOptions({
'async-dns': 'false',
'network-target-policy': 'none',
}));
assert.throws(
() => assertAria2SystemResolverOptions({
'async-dns': 'false',
'network-target-policy': ARIA2_NETWORK_TARGET_POLICY,
}),
/active target policy/,
);
});
test('allocation telemetry is mandatory and must be a JSON boolean capability', () => {
assert.throws(() => assertAria2AllocationCapabilities({ version: '1.37.0' }));
assert.throws(() => assertAria2AllocationCapabilities({ firelinkAllocationTelemetry: 'true' }));
assert.doesNotThrow(() => assertAria2AllocationCapabilities({ firelinkAllocationTelemetry: true }));
});