Skip to content

Commit

Permalink
tests: fixed odd internal error for one test
Browse files Browse the repository at this point in the history
It was just a problem with trying to connect to '0.0.0.0' with the UTP socket.
  • Loading branch information
tegefaulkes committed May 26, 2022
1 parent 5f97ff6 commit 80c80f1
Showing 1 changed file with 19 additions and 58 deletions.
77 changes: 19 additions & 58 deletions tests/network/Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ describe(Proxy.name, () => {
});
utpConn.on('end', async () => {
utpConn.destroy();
})
});
const tlsSocket = new tls.TLSSocket(utpConn, {
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
cert: Buffer.from(serverCertPem, 'ascii'),
Expand Down Expand Up @@ -759,7 +759,7 @@ describe(Proxy.name, () => {
});
utpConn.on('end', async () => {
utpConn.destroy();
})
});
const tlsSocket = new tls.TLSSocket(utpConn, {
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
cert: Buffer.from(serverCertPem, 'ascii'),
Expand Down Expand Up @@ -885,7 +885,7 @@ describe(Proxy.name, () => {
});
utpConn.on('end', async () => {
utpConn.destroy();
})
});
const tlsSocket = new tls.TLSSocket(utpConn, {
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
cert: Buffer.from(serverCertPem, 'ascii'),
Expand Down Expand Up @@ -1165,7 +1165,7 @@ describe(Proxy.name, () => {
});
utpConn.on('end', async () => {
utpConn.destroy();
})
});
const tlsSocket = new tls.TLSSocket(utpConn, {
key: Buffer.from(serverKeyPairPem.privateKey, 'ascii'),
cert: Buffer.from(serverCertPem, 'ascii'),
Expand Down Expand Up @@ -2316,11 +2316,7 @@ describe(Proxy.name, () => {
const utpSocketPort = utpSocket.address().port;
const timer = timerStart(3000);
await expect(
proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
timer,
),
proxy.openConnectionReverse(localHost, utpSocketPort as Port, timer),
).rejects.toThrow(networkErrors.ErrorConnectionStartTimeout);
timerStop(timer);
await expect(serverConnP).resolves.toBeUndefined();
Expand Down Expand Up @@ -2370,15 +2366,9 @@ describe(Proxy.name, () => {
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
expect(proxy.getConnectionReverseCount()).toBe(1);
await proxy.closeConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.closeConnectionReverse(localHost, utpSocketPort as Port);
await expect(serverConnP).resolves.toBeUndefined();
await expect(serverConnClosedP).resolves.toBeUndefined();
utpSocket.off('message', handleMessage);
Expand Down Expand Up @@ -2444,23 +2434,11 @@ describe(Proxy.name, () => {
const utpSocketBind2 = promisify(utpSocket2.bind).bind(utpSocket2);
await utpSocketBind2(0, localHost);
const utpSocketPort2 = utpSocket2.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort1 as Port,
);
await proxy.openConnectionReverse(
localHost,
utpSocketPort2 as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort1 as Port);
await proxy.openConnectionReverse(localHost, utpSocketPort2 as Port);
expect(proxy.getConnectionReverseCount()).toBe(2);
await proxy.closeConnectionReverse(
localHost,
utpSocketPort1 as Port,
);
await proxy.closeConnectionReverse(
localHost,
utpSocketPort2 as Port,
);
await proxy.closeConnectionReverse(localHost, utpSocketPort1 as Port);
await proxy.closeConnectionReverse(localHost, utpSocketPort2 as Port);
expect(proxy.getConnectionReverseCount()).toBe(0);
await expect(serverConnP).resolves.toBeUndefined();
await expect(serverConnClosedP).resolves.toBeUndefined();
Expand Down Expand Up @@ -2515,10 +2493,7 @@ describe(Proxy.name, () => {
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
expect(proxy.getConnectionReverseCount()).toBe(1);
await expect(serverConnP).resolves.toBeUndefined();
// The server receives the end confirmation for graceful exit
Expand Down Expand Up @@ -2560,7 +2535,8 @@ describe(Proxy.name, () => {
await proxy.start({
serverHost: serverHost(),
serverPort: serverPort(),

forwardHost: localHost,
proxyHost: localHost,
tlsConfig: {
keyPrivatePem: keyPairPem.privateKey,
certChainPem: certPem,
Expand All @@ -2583,10 +2559,7 @@ describe(Proxy.name, () => {
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
expect(proxy.getConnectionReverseCount()).toBe(1);
// This retries multiple times
// This will eventually fail and trigger a ErrorConnectionComposeTimeout
Expand Down Expand Up @@ -2675,10 +2648,7 @@ describe(Proxy.name, () => {
const utpSocketBind = promisify(utpSocket.bind).bind(utpSocket);
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
expect(proxy.getConnectionReverseCount()).toBe(1);
const { p: tlsSocketClosedP, resolveP: resolveTlsSocketClosedP } =
promise<void>();
Expand Down Expand Up @@ -2794,10 +2764,7 @@ describe(Proxy.name, () => {
};
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
const utpConn = utpSocket.connect(proxyPort, proxyHost);
const tlsSocket = tls.connect(
{
Expand Down Expand Up @@ -2828,10 +2795,7 @@ describe(Proxy.name, () => {
await clientReadyP;
await clientSecureConnectP;
await serverConnP;
await proxy.closeConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.closeConnectionReverse(localHost, utpSocketPort as Port);
expect(proxy.getConnectionReverseCount()).toBe(0);
await clientCloseP;
await serverConnEndP;
Expand Down Expand Up @@ -2898,10 +2862,7 @@ describe(Proxy.name, () => {
};
await utpSocketBind(0, localHost);
const utpSocketPort = utpSocket.address().port;
await proxy.openConnectionReverse(
localHost,
utpSocketPort as Port,
);
await proxy.openConnectionReverse(localHost, utpSocketPort as Port);
const utpConn = utpSocket.connect(proxyPort, proxyHost);
const tlsSocket = tls.connect(
{
Expand Down

0 comments on commit 80c80f1

Please sign in to comment.