fix(client,testing,build): improve TypeScript compatibility for DNS client parsing and test suite
This commit is contained in:
+12
-10
@@ -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 = 8500;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +128,8 @@ tap.test('DNSSEC should sign entire RRset together, not individual records', asy
|
||||
const dnsResponse = await responsePromise;
|
||||
|
||||
// Count NS and RRSIG records
|
||||
const nsAnswers = dnsResponse.answers.filter(a => a.type === 'NS');
|
||||
const rrsigAnswers = dnsResponse.answers.filter(a => a.type === 'RRSIG');
|
||||
const nsAnswers = dnsResponse.answers!.filter(a => a.type === 'NS');
|
||||
const rrsigAnswers = dnsResponse.answers!.filter(a => a.type === 'RRSIG');
|
||||
|
||||
console.log('NS records returned:', nsAnswers.length);
|
||||
console.log('RRSIG records returned:', rrsigAnswers.length);
|
||||
@@ -197,7 +199,7 @@ tap.test('SOA records should be properly serialized and returned', async () => {
|
||||
const dnsResponse = await responsePromise;
|
||||
|
||||
// Should have SOA record in response
|
||||
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;
|
||||
@@ -269,7 +271,7 @@ tap.test('Primary nameserver should be configurable', async () => {
|
||||
const dnsResponse = await responsePromise;
|
||||
|
||||
// Should have SOA record with custom nameserver
|
||||
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;
|
||||
@@ -356,8 +358,8 @@ tap.test('Multiple A records should have single RRSIG when DNSSEC is enabled', a
|
||||
|
||||
const dnsResponse = await responsePromise;
|
||||
|
||||
const aAnswers = dnsResponse.answers.filter(a => a.type === 'A');
|
||||
const rrsigAnswers = dnsResponse.answers.filter(a => a.type === 'RRSIG');
|
||||
const aAnswers = dnsResponse.answers!.filter(a => a.type === 'A');
|
||||
const rrsigAnswers = dnsResponse.answers!.filter(a => a.type === 'RRSIG');
|
||||
|
||||
console.log('A records:', aAnswers.length);
|
||||
console.log('RRSIG records:', rrsigAnswers.length);
|
||||
@@ -370,4 +372,4 @@ tap.test('Multiple A records should have single RRSIG when DNSSEC is enabled', a
|
||||
dnsServer = null;
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
export default tap.start();
|
||||
|
||||
Reference in New Issue
Block a user