| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ab4365e commit 72484e5
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,9 @@ const common = require('../common'); | |||
| 24 | 24 | if (!common.hasCrypto) | |
| 25 | 25 | common.skip('missing crypto'); | |
| 26 | 26 | ||
| 27 | + // This test ensures that the data received over tls-server after pause | ||
| 28 | + // is same as what it was sent | ||
| 29 | + | ||
| 27 | 30 | const assert = require('assert'); | |
| 28 | 31 | const tls = require('tls'); | |
| 29 | 32 | const fixtures = require('../common/fixtures'); | |
@@ -37,24 +40,23 @@ const bufSize = 1024 * 1024; | |||
| 37 | 40 | let sent = 0; | |
| 38 | 41 | let received = 0; | |
| 39 | 42 | ||
| 40 | - const server = tls.Server(options, function(socket) { | ||
| 43 | + const server = tls.Server(options, common.mustCall((socket) => { | ||
| 41 | 44 | socket.pipe(socket); | |
| 42 | - socket.on('data', function(c) { | ||
| 45 | + socket.on('data', (c) => { | ||
| 43 | 46 | console.error('data', c.length); | |
| 44 | 47 | }); | |
| 45 | - }); | ||
| 48 | + })); | ||
| 46 | 49 | ||
| 47 | - server.listen(0, function() { | ||
| 50 | + server.listen(0, common.mustCall(() => { | ||
| 48 | 51 | let resumed = false; | |
| 49 | 52 | const client = tls.connect({ | |
| 50 | - port: this.address().port, | ||
| 53 | + port: server.address().port, | ||
| 51 | 54 | rejectUnauthorized: false | |
| 52 | - }, function() { | ||
| 55 | + }, common.mustCall(() => { | ||
| 53 | 56 | console.error('connected'); | |
| 54 | 57 | client.pause(); | |
| 55 | 58 | console.error('paused'); | |
| 56 | - send(); | ||
| 57 | - function send() { | ||
| 59 | + const send = (() => { | ||
| 58 | 60 | console.error('sending'); | |
| 59 | 61 | const ret = client.write(Buffer.allocUnsafe(bufSize)); | |
| 60 | 62 | console.error(`write => ${ret}`); | |
@@ -69,9 +71,9 @@ server.listen(0, function() { | |||
| 69 | 71 | resumed = true; | |
| 70 | 72 | client.resume(); | |
| 71 | 73 | console.error('resumed', client); | |
| 72 | - } | ||
| 73 | - }); | ||
| 74 | - client.on('data', function(data) { | ||
| 74 | + })(); | ||
| 75 | + })); | ||
| 76 | + client.on('data', (data) => { | ||
| 75 | 77 | console.error('data'); | |
| 76 | 78 | assert.ok(resumed); | |
| 77 | 79 | received += data.length; | |
@@ -83,8 +85,8 @@ server.listen(0, function() { | |||
| 83 | 85 | server.close(); | |
| 84 | 86 | } | |
| 85 | 87 | }); | |
| 86 | - }); | ||
| 88 | + })); | ||
| 87 | 89 | ||
| 88 | - process.on('exit', function() { | ||
| 90 | + process.on('exit', () => { | ||
| 89 | 91 | assert.strictEqual(sent, received); | |
| 90 | 92 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments