Skip to content

Commit

Permalink
Remove race condition from netCloseReadSuccess test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo authored and ry committed Oct 6, 2018
1 parent 5f14ec4 commit 3c212dd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/net_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 3c212dd

Please sign in to comment.