bunch of changes

This commit is contained in:
Yaroslav Kukharuk
2021-02-24 13:55:49 +02:00
parent 7003f4cfe6
commit cf0679fa0b
10 changed files with 78 additions and 1201 deletions
+15 -1
View File
@@ -2,7 +2,7 @@ import http from 'http';
import net from 'net';
import assert from 'assert';
import TunnelAgent from './TunnelAgent';
import TunnelAgent from './TunnelAgent.js';
describe('TunnelAgent', () => {
it('should create an empty agent', async () => {
@@ -180,4 +180,18 @@ describe('TunnelAgent', () => {
connectedSockets: 0,
});
});
it('should disconnect clients by timeout', async () => {
const agent = new TunnelAgent({socketTimeout: 600});
const info = await agent.listen();
const offlinePromise = new Promise(resolve => agent.once('offline', resolve));
const sock = net.createConnection({ port: info.port });
await new Promise(resolve => sock.once('connect', resolve));
await offlinePromise;
agent.destroy();
sock.destroy();
});
});