Skip to content

Commit b6d33f6

Browse files
rustyconovercodebytere
authored andcommittedFeb 29, 2020
test: change test to not be sensitive to buffer send size
Change the test to not be sensitive to the buffer size causing TCP resets to be received by the client causing the test to fail. The test now reads the entire expected buffer and then checks for the expected event to fire. PR-URL: #31499 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent cef5502 commit b6d33f6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed
 

‎test/parallel/test-tls-close-event-after-write.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,35 @@ const tls = require('tls');
1212
const fixtures = require('../common/fixtures');
1313
let cconn = null;
1414
let sconn = null;
15+
let read_len = 0;
16+
const buffer_size = 1024 * 1024;
1517

1618
function test() {
1719
if (cconn && sconn) {
1820
cconn.resume();
1921
sconn.resume();
20-
sconn.end(Buffer.alloc(1024 * 1024));
21-
cconn.end();
22+
sconn.end(Buffer.alloc(buffer_size));
2223
}
2324
}
2425

2526
const server = tls.createServer({
2627
key: fixtures.readKey('agent1-key.pem'),
2728
cert: fixtures.readKey('agent1-cert.pem')
28-
}, function(c) {
29-
c.on('close', function() {
30-
server.close();
31-
});
29+
}, (c) => {
30+
c.on('close', common.mustCall(() => server.close()));
3231
sconn = c;
3332
test();
3433
}).listen(0, common.mustCall(function() {
3534
tls.connect(this.address().port, {
3635
rejectUnauthorized: false
3736
}, common.mustCall(function() {
3837
cconn = this;
38+
cconn.on('data', (d) => {
39+
read_len += d.length;
40+
if (read_len === buffer_size) {
41+
cconn.end();
42+
}
43+
});
3944
test();
4045
}));
4146
}));

0 commit comments

Comments
 (0)
Please sign in to comment.