1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix: listenTlsWithReuseAddr test (#16420)

This commit is contained in:
Bartek Iwańczuk 2022-10-25 20:15:20 +02:00 committed by GitHub
parent ffff814540
commit 1f6aeb430b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1378,7 +1378,7 @@ Deno.test(
); );
Deno.test( Deno.test(
{ permissions: { read: false, net: true } }, { permissions: { net: true } },
async function listenTlsWithReuseAddr() { async function listenTlsWithReuseAddr() {
const resolvable1 = deferred(); const resolvable1 = deferred();
const hostname = "localhost"; const hostname = "localhost";
@ -1386,44 +1386,27 @@ Deno.test(
const listener1 = Deno.listenTls({ hostname, port, cert, key }); const listener1 = Deno.listenTls({ hostname, port, cert, key });
const response1 = encoder.encode( listener1.accept().then((conn) => {
"HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n", conn.close();
); resolvable1.resolve();
});
listener1.accept().then(
async (conn) => {
await conn.write(response1);
setTimeout(() => {
conn.close();
resolvable1.resolve();
}, 0);
},
);
const conn1 = await Deno.connectTls({ hostname, port, caCerts }); const conn1 = await Deno.connectTls({ hostname, port, caCerts });
conn1.close(); conn1.close();
listener1.close();
await resolvable1; await resolvable1;
listener1.close();
const resolvable2 = deferred(); const resolvable2 = deferred();
const listener2 = Deno.listenTls({ hostname, port, cert, key }); const listener2 = Deno.listenTls({ hostname, port, cert, key });
const response2 = encoder.encode(
"HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n",
);
listener2.accept().then( listener2.accept().then((conn) => {
async (conn) => { conn.close();
await conn.write(response2); resolvable2.resolve();
setTimeout(() => { });
conn.close();
resolvable2.resolve();
}, 0);
},
);
const conn2 = await Deno.connectTls({ hostname, port, caCerts }); const conn2 = await Deno.connectTls({ hostname, port, caCerts });
conn2.close(); conn2.close();
listener2.close();
await resolvable2; await resolvable2;
listener2.close();
}, },
); );