Skip to content

Commit 8b96535

Browse files
committed
tests: fixed odd internal error for one test
It was just a problem with trying to connect to '0.0.0.0' with the UTP socket.
1 parent a868d66 commit 8b96535

1 file changed

Lines changed: 19 additions & 58 deletions

File tree

tests/network/Proxy.test.ts

Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ describe(Proxy.name, () => {
640640
});
641641
utpConn.on('end', async () => {
642642
utpConn.destroy();
643-
})
643+
});
644644
const tlsSocket = new tls.TLSSocket(utpConn, {
645645
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
646646
cert: Buffer.from(serverCertPem, 'ascii'),
@@ -759,7 +759,7 @@ describe(Proxy.name, () => {
759759
});
760760
utpConn.on('end', async () => {
761761
utpConn.destroy();
762-
})
762+
});
763763
const tlsSocket = new tls.TLSSocket(utpConn, {
764764
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
765765
cert: Buffer.from(serverCertPem, 'ascii'),
@@ -885,7 +885,7 @@ describe(Proxy.name, () => {
885885
});
886886
utpConn.on('end', async () => {
887887
utpConn.destroy();
888-
})
888+
});
889889
const tlsSocket = new tls.TLSSocket(utpConn, {
890890
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
891891
cert: Buffer.from(serverCertPem, 'ascii'),
@@ -1165,7 +1165,7 @@ describe(Proxy.name, () => {
11651165
});
11661166
utpConn.on('end', async () => {
11671167
utpConn.destroy();
1168-
})
1168+
});
11691169
const tlsSocket = new tls.TLSSocket(utpConn, {
11701170
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
11711171
cert: Buffer.from(serverCertPem, 'ascii'),
@@ -2316,11 +2316,7 @@ describe(Proxy.name, () => {
23162316
const utpSocketPort = utpSocket.address().port;
23172317
const timer = timerStart(3000);
23182318
await expect(
2319-
proxy.openConnectionReverse(
2320-
localHost,
2321-
utpSocketPort as Port,
2322-
timer,
2323-
),
2319+
proxy.openConnectionReverse(localHost, utpSocketPort as Port, timer),
23242320
).rejects.toThrow(networkErrors.ErrorConnectionStartTimeout);
23252321
timerStop(timer);
23262322
await expect(serverConnP).resolves.toBeUndefined();
@@ -2370,15 +2366,9 @@ describe(Proxy.name, () => {
23702366
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
23712367
await utpSocketBind(0, localHost);
23722368
const utpSocketPort = utpSocket.address().port;
2373-
await proxy.openConnectionReverse(
2374-
localHost,
2375-
utpSocketPort as Port,
2376-
);
2369+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
23772370
expect(proxy.getConnectionReverseCount()).toBe(1);
2378-
await proxy.closeConnectionReverse(
2379-
localHost,
2380-
utpSocketPort as Port,
2381-
);
2371+
await proxy.closeConnectionReverse(localHost, utpSocketPort as Port);
23822372
await expect(serverConnP).resolves.toBeUndefined();
23832373
await expect(serverConnClosedP).resolves.toBeUndefined();
23842374
utpSocket.off('message', handleMessage);
@@ -2444,23 +2434,11 @@ describe(Proxy.name, () => {
24442434
const utpSocketBind2 = promisify(utpSocket2.bind).bind(utpSocket2);
24452435
await utpSocketBind2(0, localHost);
24462436
const utpSocketPort2 = utpSocket2.address().port;
2447-
await proxy.openConnectionReverse(
2448-
localHost,
2449-
utpSocketPort1 as Port,
2450-
);
2451-
await proxy.openConnectionReverse(
2452-
localHost,
2453-
utpSocketPort2 as Port,
2454-
);
2437+
await proxy.openConnectionReverse(localHost, utpSocketPort1 as Port);
2438+
await proxy.openConnectionReverse(localHost, utpSocketPort2 as Port);
24552439
expect(proxy.getConnectionReverseCount()).toBe(2);
2456-
await proxy.closeConnectionReverse(
2457-
localHost,
2458-
utpSocketPort1 as Port,
2459-
);
2460-
await proxy.closeConnectionReverse(
2461-
localHost,
2462-
utpSocketPort2 as Port,
2463-
);
2440+
await proxy.closeConnectionReverse(localHost, utpSocketPort1 as Port);
2441+
await proxy.closeConnectionReverse(localHost, utpSocketPort2 as Port);
24642442
expect(proxy.getConnectionReverseCount()).toBe(0);
24652443
await expect(serverConnP).resolves.toBeUndefined();
24662444
await expect(serverConnClosedP).resolves.toBeUndefined();
@@ -2515,10 +2493,7 @@ describe(Proxy.name, () => {
25152493
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
25162494
await utpSocketBind(0, localHost);
25172495
const utpSocketPort = utpSocket.address().port;
2518-
await proxy.openConnectionReverse(
2519-
localHost,
2520-
utpSocketPort as Port,
2521-
);
2496+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
25222497
expect(proxy.getConnectionReverseCount()).toBe(1);
25232498
await expect(serverConnP).resolves.toBeUndefined();
25242499
// The server receives the end confirmation for graceful exit
@@ -2560,7 +2535,8 @@ describe(Proxy.name, () => {
25602535
await proxy.start({
25612536
serverHost: serverHost(),
25622537
serverPort: serverPort(),
2563-
2538+
forwardHost: localHost,
2539+
proxyHost: localHost,
25642540
tlsConfig: {
25652541
keyPrivatePem: keyPairPem.privateKey,
25662542
certChainPem: certPem,
@@ -2583,10 +2559,7 @@ describe(Proxy.name, () => {
25832559
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
25842560
await utpSocketBind(0, localHost);
25852561
const utpSocketPort = utpSocket.address().port;
2586-
await proxy.openConnectionReverse(
2587-
localHost,
2588-
utpSocketPort as Port,
2589-
);
2562+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
25902563
expect(proxy.getConnectionReverseCount()).toBe(1);
25912564
// This retries multiple times
25922565
// This will eventually fail and trigger a ErrorConnectionComposeTimeout
@@ -2675,10 +2648,7 @@ describe(Proxy.name, () => {
26752648
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
26762649
await utpSocketBind(0, localHost);
26772650
const utpSocketPort = utpSocket.address().port;
2678-
await proxy.openConnectionReverse(
2679-
localHost,
2680-
utpSocketPort as Port,
2681-
);
2651+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
26822652
expect(proxy.getConnectionReverseCount()).toBe(1);
26832653
const { p: tlsSocketClosedP, resolveP: resolveTlsSocketClosedP } =
26842654
promise<void>();
@@ -2794,10 +2764,7 @@ describe(Proxy.name, () => {
27942764
};
27952765
await utpSocketBind(0, localHost);
27962766
const utpSocketPort = utpSocket.address().port;
2797-
await proxy.openConnectionReverse(
2798-
localHost,
2799-
utpSocketPort as Port,
2800-
);
2767+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
28012768
const utpConn = utpSocket.connect(proxyPort, proxyHost);
28022769
const tlsSocket = tls.connect(
28032770
{
@@ -2828,10 +2795,7 @@ describe(Proxy.name, () => {
28282795
await clientReadyP;
28292796
await clientSecureConnectP;
28302797
await serverConnP;
2831-
await proxy.closeConnectionReverse(
2832-
localHost,
2833-
utpSocketPort as Port,
2834-
);
2798+
await proxy.closeConnectionReverse(localHost, utpSocketPort as Port);
28352799
expect(proxy.getConnectionReverseCount()).toBe(0);
28362800
await clientCloseP;
28372801
await serverConnEndP;
@@ -2898,10 +2862,7 @@ describe(Proxy.name, () => {
28982862
};
28992863
await utpSocketBind(0, localHost);
29002864
const utpSocketPort = utpSocket.address().port;
2901-
await proxy.openConnectionReverse(
2902-
localHost,
2903-
utpSocketPort as Port,
2904-
);
2865+
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
29052866
const utpConn = utpSocket.connect(proxyPort, proxyHost);
29062867
const tlsSocket = tls.connect(
29072868
{

0 commit comments

Comments
 (0)