fix(client,testing,build): improve TypeScript compatibility for DNS client parsing and test suite

This commit is contained in:
2026-04-30 12:48:49 +00:00
parent 510801b109
commit 199dfe7ba3
18 changed files with 1944 additions and 3435 deletions
+8 -6
View File
@@ -1,12 +1,14 @@
import * as plugins from '../ts_server/plugins.js';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import { tapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
import { TapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
import * as dnsPacket from 'dns-packet';
import * as dgram from 'dgram';
import * as smartdns from '../ts_server/index.js';
let dnsServer: smartdns.DnsServer;
const tapNodeTools = new TapNodeTools(tap);
let dnsServer: smartdns.DnsServer | null;
// Port management for tests
let nextHttpsPort = 8800;
@@ -29,7 +31,7 @@ async function stopServer(server: smartdns.DnsServer | null | undefined) {
try {
await server.stop();
} catch (e) {
console.log('Handled error when stopping server:', e.message || e);
console.log('Handled error when stopping server:', e instanceof Error ? e.message : e);
}
}
@@ -98,7 +100,7 @@ tap.test('Simple SOA query without DNSSEC', async () => {
const dnsResponse = await responsePromise;
console.log('✅ SOA response without DNSSEC received');
const soaAnswers = dnsResponse.answers.filter(a => a.type === 'SOA');
const soaAnswers = dnsResponse.answers!.filter(a => a.type === 'SOA');
expect(soaAnswers.length).toEqual(1);
const soaData = (soaAnswers[0] as any).data;
@@ -191,11 +193,11 @@ tap.test('Direct SOA query without DNSSEC', async () => {
const dnsResponse = await responsePromise;
console.log('✅ Direct SOA query succeeded');
const soaAnswers = dnsResponse.answers.filter(a => a.type === 'SOA');
const soaAnswers = dnsResponse.answers!.filter(a => a.type === 'SOA');
expect(soaAnswers.length).toEqual(1);
await stopServer(dnsServer);
dnsServer = null;
});
export default tap.start();
export default tap.start();