import { tap, expect } from '@git.zone/tstest/tapbundle'; import { createTestServer } from '../../helpers/server.loader.js'; import { createTestSmtpClient } from '../../helpers/smtp.client.js'; import { Email } from '../../../ts/mail/core/classes.email.js'; tap.test('CPERF-08: DNS Caching Tests', async () => { console.log('\n🌐 Testing SMTP Client DNS Caching'); console.log('=' .repeat(60)); const testServer = await createTestServer({}); try { console.log('\nTest: DNS caching with multiple connections'); // Create multiple clients to test DNS caching const clients = []; for (let i = 0; i < 3; i++) { const smtpClient = createTestSmtpClient({ host: testServer.hostname, port: testServer.port }); clients.push(smtpClient); console.log(` āœ“ Client ${i + 1} created (DNS should be cached)`); } // Send email with first client const email = new Email({ from: 'sender@example.com', to: 'recipient@example.com', subject: 'DNS Caching Test', text: 'Testing DNS caching efficiency' }); const result = await clients[0].sendMail(email); console.log(' āœ“ Email sent successfully'); expect(result).toBeDefined(); // Clean up all clients clients.forEach(client => client.close()); console.log(' āœ“ All clients closed'); console.log('\nāœ… CPERF-08: DNS caching tests completed'); } finally { testServer.server.close(); } }); tap.start();