@@ -13,7 +13,7 @@ const options = {
13
13
database : 'existing' ,
14
14
}
15
15
16
- const serverWithConnectionTimeout = ( timeout , callback ) => {
16
+ const serverWithConnectionTimeout = ( port , timeout , callback ) => {
17
17
const sockets = new Set ( )
18
18
19
19
const server = net . createServer ( ( socket ) => {
@@ -47,11 +47,11 @@ const serverWithConnectionTimeout = (timeout, callback) => {
47
47
}
48
48
}
49
49
50
- server . listen ( options . port , options . host , ( ) => callback ( closeServer ) )
50
+ server . listen ( port , options . host , ( ) => callback ( closeServer ) )
51
51
}
52
52
53
53
suite . test ( 'successful connection' , ( done ) => {
54
- serverWithConnectionTimeout ( 0 , ( closeServer ) => {
54
+ serverWithConnectionTimeout ( options . port , 0 , ( closeServer ) => {
55
55
const timeoutId = setTimeout ( ( ) => {
56
56
throw new Error ( 'Client should have connected successfully but it did not.' )
57
57
} , 3000 )
@@ -67,12 +67,13 @@ suite.test('successful connection', (done) => {
67
67
} )
68
68
69
69
suite . test ( 'expired connection timeout' , ( done ) => {
70
- serverWithConnectionTimeout ( options . connectionTimeoutMillis * 2 , ( closeServer ) => {
70
+ const opts = { ...options , port : 54322 }
71
+ serverWithConnectionTimeout ( opts . port , opts . connectionTimeoutMillis * 2 , ( closeServer ) => {
71
72
const timeoutId = setTimeout ( ( ) => {
72
73
throw new Error ( 'Client should have emitted an error but it did not.' )
73
74
} , 3000 )
74
75
75
- const client = new helper . Client ( options )
76
+ const client = new helper . Client ( opts )
76
77
client
77
78
. connect ( )
78
79
. then ( ( ) => client . end ( ) )
0 commit comments