mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
chore: refactor netHangsOnClose
test to not use deferred
(#11585)
This commit is contained in:
parent
87de8e82a1
commit
fcaf8cd8e3
1 changed files with 15 additions and 12 deletions
|
@ -551,7 +551,6 @@ unitTest(
|
||||||
},
|
},
|
||||||
async function netHangsOnClose() {
|
async function netHangsOnClose() {
|
||||||
let acceptedConn: Deno.Conn;
|
let acceptedConn: Deno.Conn;
|
||||||
const resolvable = deferred();
|
|
||||||
|
|
||||||
async function iteratorReq(listener: Deno.Listener): Promise<void> {
|
async function iteratorReq(listener: Deno.Listener): Promise<void> {
|
||||||
const p = new Uint8Array(10);
|
const p = new Uint8Array(10);
|
||||||
|
@ -570,13 +569,12 @@ unitTest(
|
||||||
assert(!!err);
|
assert(!!err);
|
||||||
assert(err instanceof Deno.errors.BadResource);
|
assert(err instanceof Deno.errors.BadResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvable.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const addr = { hostname: "127.0.0.1", port: 3500 };
|
const addr = { hostname: "127.0.0.1", port: 3500 };
|
||||||
const listener = Deno.listen(addr);
|
const listener = Deno.listen(addr);
|
||||||
iteratorReq(listener);
|
const listenerPromise = iteratorReq(listener);
|
||||||
|
const connectionPromise = (async () => {
|
||||||
const conn = await Deno.connect(addr);
|
const conn = await Deno.connect(addr);
|
||||||
await conn.write(new Uint8Array([1, 2, 3, 4]));
|
await conn.write(new Uint8Array([1, 2, 3, 4]));
|
||||||
const buf = new Uint8Array(10);
|
const buf = new Uint8Array(10);
|
||||||
|
@ -584,7 +582,12 @@ unitTest(
|
||||||
conn!.close();
|
conn!.close();
|
||||||
acceptedConn!.close();
|
acceptedConn!.close();
|
||||||
listener.close();
|
listener.close();
|
||||||
await resolvable;
|
})();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
listenerPromise,
|
||||||
|
connectionPromise,
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue