@@ -85,92 +85,3 @@ suite.test('expired connection timeout', (done) => {
85
85
. then ( ( ) => clearTimeout ( timeoutId ) )
86
86
} )
87
87
} )
88
-
89
- // 'use strict'
90
- // const net = require('net')
91
- // const buffers = require('../../test-buffers')
92
- // const helper = require('./test-helper')
93
-
94
- // const suite = new helper.Suite()
95
-
96
- // const options = {
97
- // host: 'localhost',
98
- // port: Math.floor(Math.random() * 2000) + 2000,
99
- // connectionTimeoutMillis: 2000,
100
- // user: 'not',
101
- // database: 'existing',
102
- // }
103
-
104
- // const serverWithConnectionTimeout = (port, timeout, callback) => {
105
- // const sockets = new Set()
106
-
107
- // const server = net.createServer((socket) => {
108
- // sockets.add(socket)
109
- // socket.once('end', () => sockets.delete(socket))
110
-
111
- // socket.on('data', (data) => {
112
- // // deny request for SSL
113
- // if (data.length === 8) {
114
- // socket.write(Buffer.from('N', 'utf8'))
115
- // // consider all authentication requests as good
116
- // } else if (!data[0]) {
117
- // socket.write(buffers.authenticationOk())
118
- // // send ReadyForQuery `timeout` ms after authentication
119
- // setTimeout(() => socket.write(buffers.readyForQuery()), timeout).unref()
120
- // // respond with our canned response
121
- // } else {
122
- // socket.write(buffers.readyForQuery())
123
- // }
124
- // })
125
- // })
126
-
127
- // let closing = false
128
- // const closeServer = (done) => {
129
- // if (closing) return
130
- // closing = true
131
-
132
- // server.close(done)
133
- // for (const socket of sockets) {
134
- // socket.destroy()
135
- // }
136
- // }
137
-
138
- // server.listen(port, options.host, () => callback(closeServer))
139
- // }
140
-
141
- // suite.test('successful connection', (done) => {
142
- // serverWithConnectionTimeout(options.port, 0, (closeServer) => {
143
- // const timeoutId = setTimeout(() => {
144
- // throw new Error('Client should have connected successfully but it did not.')
145
- // }, 3000)
146
-
147
- // const client = new helper.Client(options)
148
- // client
149
- // .connect()
150
- // .then(() => client.end())
151
- // .then(() => closeServer(done))
152
- // .catch((err) => closeServer(() => done(err)))
153
- // .then(() => clearTimeout(timeoutId))
154
- // })
155
- // })
156
-
157
- // suite.test('expired connection timeout', (done) => {
158
- // const opts = { ...options, port: 54322 }
159
- // serverWithConnectionTimeout(opts.port, opts.connectionTimeoutMillis * 2, (closeServer) => {
160
- // const timeoutId = setTimeout(() => {
161
- // throw new Error('Client should have emitted an error but it did not.')
162
- // }, 3000)
163
-
164
- // const client = new helper.Client(opts)
165
- // client
166
- // .connect()
167
- // .then(() => client.end())
168
- // .then(() => closeServer(() => done(new Error('Connection timeout should have expired but it did not.'))))
169
- // .catch((err) => {
170
- // assert(err instanceof Error)
171
- // assert(/timeout expired\s*/.test(err.message))
172
- // closeServer(done)
173
- // })
174
- // .then(() => clearTimeout(timeoutId))
175
- // })
176
- // })
0 commit comments