This commit is contained in:
2025-05-23 19:49:25 +00:00
parent e0f6e3237b
commit a7438a7cd6
40 changed files with 189 additions and 178 deletions

View File

@ -1,16 +1,15 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js';
import { startTestServer, stopTestServer, type ITestServer } from '../server.loader.js';
import type { SmtpServer } from '../../../ts/mail/delivery/smtpserver/index.js';
import { createConcurrentConnections, performSmtpHandshake, closeSmtpConnection } from '../../helpers/test.utils.js';
let testServer: ITestServer;
let testServer: SmtpServer;
const CONCURRENT_COUNT = 10;
tap.test('setup - start SMTP server', async () => {
testServer = await startTestServer({
port: 2526,
maxConnections: 100
});
expect(testServer).toBeInstanceOf(Object);
testServer = await startTestServer();
await new Promise(resolve => setTimeout(resolve, 1000));
expect(testServer.port).toEqual(2526);
});
@ -69,12 +68,10 @@ tap.test('CM-02: Connection limit enforcement - verify max connections', async (
const maxConnections = 5;
// Start a new server with lower connection limit
const limitedServer = await startTestServer({
port: 2527,
maxConnections: maxConnections
});
const limitedServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
// Try to create more connections than allowed
const attemptCount = maxConnections + 5;
console.log(`🔄 Attempting ${attemptCount} connections (limit: ${maxConnections})...`);
@ -104,7 +101,7 @@ tap.test('CM-02: Connection limit enforcement - verify max connections', async (
});
tap.test('cleanup - stop SMTP server', async () => {
await stopTestServer(testServer);
await stopTestServer();
console.log('✅ Test server stopped');
});