fix(client,testing,build): improve TypeScript compatibility for DNS client parsing and test suite
This commit is contained in:
+14
-12
@@ -1,11 +1,13 @@
|
||||
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;
|
||||
|
||||
// Cleanup function for servers
|
||||
async function stopServer(server: smartdns.DnsServer | null | undefined) {
|
||||
@@ -16,7 +18,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +80,7 @@ tap.test('Test SOA with DNSSEC timing', 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();
|
||||
});
|
||||
@@ -103,11 +105,11 @@ tap.test('Test SOA with DNSSEC timing', async () => {
|
||||
try {
|
||||
const dnsResponse = await responsePromise;
|
||||
console.log('Response details:');
|
||||
console.log('- Answers:', dnsResponse.answers.length);
|
||||
console.log('- Answer types:', dnsResponse.answers.map(a => a.type));
|
||||
console.log('- Answers:', dnsResponse.answers!.length);
|
||||
console.log('- Answer types:', dnsResponse.answers!.map(a => a.type));
|
||||
|
||||
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:', soaAnswers.length);
|
||||
console.log('- RRSIG records:', rrsigAnswers.length);
|
||||
@@ -187,7 +189,7 @@ tap.test('DNSSEC signing completes within reasonable time', 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();
|
||||
});
|
||||
@@ -215,8 +217,8 @@ tap.test('DNSSEC signing completes within reasonable time', async () => {
|
||||
expect(elapsed).toBeLessThan(2000);
|
||||
|
||||
// Verify correctness: SOA + RRSIG present
|
||||
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');
|
||||
|
||||
expect(soaAnswers.length).toEqual(1);
|
||||
expect(rrsigAnswers.length).toBeGreaterThan(0);
|
||||
@@ -234,4 +236,4 @@ tap.test('DNSSEC signing completes within reasonable time', async () => {
|
||||
dnsServer = null;
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
export default tap.start();
|
||||
|
||||
Reference in New Issue
Block a user