0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

Remove race condition from netCloseReadSuccess test

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2018-10-05 17:09:46 -07:00 committed by Ryan Dahl
parent 5f14ec486c
commit 3c212ddd1e

View file

@ -41,7 +41,9 @@ testPerm({ net: true }, async function netCloseReadSuccess() {
const addr = "127.0.0.1:4500";
const listener = deno.listen("tcp", addr);
const closeDeferred = deferred();
const closeReadDeferred = deferred();
listener.accept().then(async conn => {
await closeReadDeferred.promise;
await conn.write(new Uint8Array([1, 2, 3]));
const buf = new Uint8Array(1024);
const readResult = await conn.read(buf);
@ -54,6 +56,7 @@ testPerm({ net: true }, async function netCloseReadSuccess() {
});
const conn = await deno.dial("tcp", addr);
conn.closeRead(); // closing read
closeReadDeferred.resolve();
const buf = new Uint8Array(1024);
const readResult = await conn.read(buf);
assertEqual(0, readResult.nread); // No error, read nothing