diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-04 19:45:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 19:45:10 -0400 |
commit | fcaf8cd8e37459658a6c06d7e16b3adc9436a135 (patch) | |
tree | 2aa0e4cc1dc6afc4188a33bc3bffd102b90966e2 /cli/tests | |
parent | 87de8e82a157ecbcc596b0226b8a6fc0e81a8b1b (diff) |
chore: refactor `netHangsOnClose` test to not use `deferred` (#11585)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/net_test.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts index 8b66ff3fa..a7a9454c0 100644 --- a/cli/tests/unit/net_test.ts +++ b/cli/tests/unit/net_test.ts @@ -551,7 +551,6 @@ unitTest( }, async function netHangsOnClose() { let acceptedConn: Deno.Conn; - const resolvable = deferred(); async function iteratorReq(listener: Deno.Listener): Promise<void> { const p = new Uint8Array(10); @@ -570,21 +569,25 @@ unitTest( assert(!!err); assert(err instanceof Deno.errors.BadResource); } - - resolvable.resolve(); } const addr = { hostname: "127.0.0.1", port: 3500 }; const listener = Deno.listen(addr); - iteratorReq(listener); - const conn = await Deno.connect(addr); - await conn.write(new Uint8Array([1, 2, 3, 4])); - const buf = new Uint8Array(10); - await conn.read(buf); - conn!.close(); - acceptedConn!.close(); - listener.close(); - await resolvable; + const listenerPromise = iteratorReq(listener); + const connectionPromise = (async () => { + const conn = await Deno.connect(addr); + await conn.write(new Uint8Array([1, 2, 3, 4])); + const buf = new Uint8Array(10); + await conn.read(buf); + conn!.close(); + acceptedConn!.close(); + listener.close(); + })(); + + await Promise.all([ + listenerPromise, + connectionPromise, + ]); }, ); |