Skip to content

Commit 777fa37

Browse files
committed
test: add separate termination for proxy
1 parent dcf30f2 commit 777fa37

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

test/unit/proxy-terminate-test.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,9 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
2424
global.gc?.()
2525
})
2626

27-
it("should throw if called after termination", async function () {
28-
await proxy.frontEnd.bind(await uniqAddress(proto))
29-
await proxy.backEnd.bind(await uniqAddress(proto))
30-
31-
const sleep_ms = 50
32-
33-
setTimeout(() => proxy.terminate(), sleep_ms)
34-
await proxy.run()
35-
27+
const terminator_test = () => {
3628
try {
37-
await proxy.terminate()
29+
proxy.terminate()
3830
assert.ok(false)
3931
} catch (err) {
4032
if (!isFullError(err)) {
@@ -44,6 +36,27 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
4436
assert.equal(err.code, "EBADF")
4537
assert.typeOf(err.errno, "number")
4638
}
39+
}
40+
41+
it("should throw if not started yet", async function () {
42+
await proxy.frontEnd.bind(await uniqAddress(proto))
43+
await proxy.backEnd.bind(await uniqAddress(proto))
44+
45+
terminator_test()
46+
})
47+
48+
it("should throw if called after termination", async function () {
49+
await proxy.frontEnd.bind(await uniqAddress(proto))
50+
await proxy.backEnd.bind(await uniqAddress(proto))
51+
52+
setTimeout(() => {
53+
proxy.terminate()
54+
}, 50)
55+
56+
await proxy.run()
57+
// TODO throws Operation not supported
58+
59+
terminator_test()
4760
})
4861
})
4962
}

0 commit comments

Comments
 (0)