()
| 52 | |
| 53 | // Send net.Socket to child. |
| 54 | function testSocket() { |
| 55 | |
| 56 | // Create a new server and connect to it, |
| 57 | // but the socket will be handled by the child. |
| 58 | const server = net.createServer(); |
| 59 | server.on('connection', mustCall((socket) => { |
| 60 | // TODO(@jasnell): Close does not seem to actually be called. |
| 61 | // It is not clear if it is needed. |
| 62 | socket.on('close', () => { |
| 63 | debug('CLIENT: socket closed'); |
| 64 | }); |
| 65 | child.send({ what: 'socket' }, socket); |
| 66 | })); |
| 67 | server.on('close', mustCall(() => { |
| 68 | debug('PARENT: server closed'); |
| 69 | })); |
| 70 | |
| 71 | server.listen(0, mustCall(() => { |
| 72 | debug('testSocket, listening'); |
| 73 | const connect = net.connect(server.address().port); |
| 74 | let store = ''; |
| 75 | connect.on('data', mustCallAtLeast((chunk) => { |
| 76 | store += chunk; |
| 77 | debug('CLIENT: got data'); |
| 78 | })); |
| 79 | connect.on('close', mustCall(() => { |
| 80 | debug('CLIENT: closed'); |
| 81 | assert.strictEqual(store, 'echo'); |
| 82 | server.close(); |
| 83 | })); |
| 84 | })); |
| 85 | } |
| 86 | |
| 87 | const onReady = mustCall((msg) => { |
| 88 | if (msg.what !== 'ready') return; |
no test coverage detected
searching dependent graphs…