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