| 38 | } |
| 39 | |
| 40 | function testLib(lib, cb) { |
| 41 | mkServer(lib, true, common.mustCall((tcpServer) => { |
| 42 | mkServer(lib, false, common.mustCall((unixServer) => { |
| 43 | const client = lib.connect({ |
| 44 | path: unixServer.address(), |
| 45 | port: tcpServer.address().port, |
| 46 | host: 'localhost', |
| 47 | rejectUnauthorized: false |
| 48 | }, common.mustCall(() => { |
| 49 | const bufs = []; |
| 50 | client.on('data', common.mustCall((d) => { |
| 51 | bufs.push(d); |
| 52 | })); |
| 53 | client.on('end', common.mustCall(() => { |
| 54 | const resp = Buffer.concat(bufs).toString(); |
| 55 | assert.strictEqual(resp, `${libName(lib)}:${unixServer.address()}`); |
| 56 | tcpServer.close(); |
| 57 | unixServer.close(); |
| 58 | cb(); |
| 59 | })); |
| 60 | })); |
| 61 | })); |
| 62 | })); |
| 63 | } |
| 64 | |
| 65 | testLib(net, common.mustCall(() => testLib(tls, common.mustCall()))); |