fix(client,testing,build): improve TypeScript compatibility for DNS client parsing and test suite
This commit is contained in:
+15
-13
@@ -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 = 8700;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ tap.test('Direct SOA query should work without timeout', async () => {
|
||||
const dnsResponse = dnsPacket.decode(msg);
|
||||
resolve(dnsResponse);
|
||||
} catch (e) {
|
||||
reject(new Error(`Failed to decode response: ${e.message}`));
|
||||
reject(new Error(`Failed to decode response: ${e instanceof Error ? e.message : String(e)}`));
|
||||
}
|
||||
client.close();
|
||||
});
|
||||
@@ -118,9 +120,9 @@ tap.test('Direct SOA query should work without timeout', async () => {
|
||||
|
||||
try {
|
||||
const dnsResponse = await responsePromise;
|
||||
console.log('SOA response received:', dnsResponse.answers.length, 'answers');
|
||||
console.log('SOA response received:', dnsResponse.answers!.length, 'answers');
|
||||
|
||||
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;
|
||||
@@ -189,7 +191,7 @@ tap.test('SOA query with DNSSEC should work', async () => {
|
||||
const dnsResponse = dnsPacket.decode(msg);
|
||||
resolve(dnsResponse);
|
||||
} catch (e) {
|
||||
reject(new Error(`Failed to decode response: ${e.message}`));
|
||||
reject(new Error(`Failed to decode response: ${e instanceof Error ? e.message : String(e)}`));
|
||||
}
|
||||
client.close();
|
||||
});
|
||||
@@ -211,10 +213,10 @@ tap.test('SOA query with DNSSEC should work', async () => {
|
||||
|
||||
try {
|
||||
const dnsResponse = await responsePromise;
|
||||
console.log('Response received with', dnsResponse.answers.length, 'answers');
|
||||
console.log('Response received with', dnsResponse.answers!.length, 'answers');
|
||||
|
||||
const soaAnswers = dnsResponse.answers.filter(a => a.type === 'SOA');
|
||||
const rrsigAnswers = dnsResponse.answers.filter(a => a.type === 'RRSIG');
|
||||
const soaAnswers = dnsResponse.answers!.filter(a => a.type === 'SOA');
|
||||
const rrsigAnswers = dnsResponse.answers!.filter(a => a.type === 'RRSIG');
|
||||
console.log('SOA records found:', soaAnswers.length);
|
||||
console.log('RRSIG records found:', rrsigAnswers.length);
|
||||
|
||||
@@ -312,7 +314,7 @@ tap.test('SOA serialization produces correct wire format', async () => {
|
||||
const dnsResponse = dnsPacket.decode(msg);
|
||||
resolve(dnsResponse);
|
||||
} catch (e) {
|
||||
reject(new Error(`Failed to decode response: ${e.message}`));
|
||||
reject(new Error(`Failed to decode response: ${e instanceof Error ? e.message : String(e)}`));
|
||||
}
|
||||
client.close();
|
||||
});
|
||||
@@ -334,7 +336,7 @@ tap.test('SOA serialization produces correct wire format', async () => {
|
||||
|
||||
try {
|
||||
const dnsResponse = await responsePromise;
|
||||
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;
|
||||
@@ -358,4 +360,4 @@ tap.test('SOA serialization produces correct wire format', async () => {
|
||||
dnsServer = null;
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
export default tap.start();
|
||||
|
||||
Reference in New Issue
Block a user