1
1
'use strict' ;
2
- var common = require ( '../common' ) ;
3
- var assert = require ( 'assert' ) ;
2
+ const common = require ( '../common' ) ;
4
3
5
4
if ( ! common . hasCrypto ) {
6
5
common . skip ( 'missing crypto' ) ;
7
6
return ;
8
7
}
9
- var tls = require ( 'tls ' ) ;
8
+ const assert = require ( 'assert ' ) ;
10
9
11
- var fs = require ( 'fs ' ) ;
10
+ const tls = require ( 'tls ' ) ;
12
11
13
- var dir = common . fixturesDir ;
14
- var options = { key : fs . readFileSync ( dir + '/test_key.pem' ) ,
15
- cert : fs . readFileSync ( dir + '/test_cert.pem' ) ,
16
- ca : [ fs . readFileSync ( dir + '/test_ca.pem' ) ] } ;
12
+ const fs = require ( 'fs' ) ;
17
13
18
- var writes = [
14
+ const dir = common . fixturesDir ;
15
+ const options = { key : fs . readFileSync ( dir + '/test_key.pem' ) ,
16
+ cert : fs . readFileSync ( dir + '/test_cert.pem' ) ,
17
+ ca : [ fs . readFileSync ( dir + '/test_ca.pem' ) ] } ;
18
+
19
+ const writes = [
19
20
'some server data' ,
20
21
'and a separate packet' ,
21
22
'and one more' ,
22
23
] ;
23
- var receivedWrites = 0 ;
24
+ let receivedWrites = 0 ;
24
25
25
- var server = tls . createServer ( options , function ( c ) {
26
+ const server = tls . createServer ( options , function ( c ) {
26
27
writes . forEach ( function ( str ) {
27
28
c . write ( str ) ;
28
29
} ) ;
29
- } ) . listen ( 0 , function ( ) {
30
+ } ) . listen ( 0 , common . mustCall ( function ( ) {
30
31
const connectOpts = { rejectUnauthorized : false } ;
31
- var c = tls . connect ( this . address ( ) . port , connectOpts , function ( ) {
32
+ const c = tls . connect ( this . address ( ) . port , connectOpts , function ( ) {
32
33
c . write ( 'some client data' ) ;
33
34
c . on ( 'readable' , function ( ) {
34
- var data = c . read ( ) ;
35
+ let data = c . read ( ) ;
35
36
if ( data === null )
36
37
return ;
37
38
@@ -47,8 +48,9 @@ var server = tls.createServer(options, function(c) {
47
48
}
48
49
} ) ;
49
50
} ) ;
50
- } ) ;
51
+ } ) ) ;
52
+
51
53
52
54
process . on ( 'exit' , function ( ) {
53
- assert . equal ( receivedWrites , writes . length ) ;
55
+ assert . strictEqual ( receivedWrites , writes . length ) ;
54
56
} ) ;
0 commit comments