-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: remove timers from test-tls-socket-close #53019
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ const cert = fixtures.readKey('agent2-cert.pem'); | |
let serverTlsSocket; | ||
const tlsServer = tls.createServer({ cert, key }, (socket) => { | ||
serverTlsSocket = socket; | ||
socket.on('data', (chunk) => { | ||
assert.strictEqual(chunk[0], 46); | ||
socket.write('.'); | ||
}); | ||
socket.on('close', dec); | ||
}); | ||
|
||
|
@@ -25,10 +29,10 @@ let netSocketCloseEmitted = false; | |
const netServer = net.createServer((socket) => { | ||
netSocket = socket; | ||
tlsServer.emit('connection', socket); | ||
socket.on('close', () => { | ||
socket.on('close', common.mustCall(() => { | ||
netSocketCloseEmitted = true; | ||
assert.strictEqual(serverTlsSocket.destroyed, true); | ||
}); | ||
})); | ||
}).listen(0, common.mustCall(() => { | ||
connectClient(netServer); | ||
})); | ||
|
@@ -45,24 +49,20 @@ function connectClient(server) { | |
rejectUnauthorized: false | ||
}); | ||
|
||
clientTlsSocket.write('foo', 'utf8', common.mustCall(() => { | ||
assert(netSocket); | ||
netSocket.setTimeout(common.platformTimeout(10), common.mustCall(() => { | ||
assert(serverTlsSocket); | ||
clientTlsSocket.write('.'); | ||
|
||
netSocket.destroy(); | ||
assert.strictEqual(netSocket.destroyed, true); | ||
clientTlsSocket.on('data', (chunk) => { | ||
assert.strictEqual(chunk[0], 46); | ||
|
||
setImmediate(() => { | ||
// Close callbacks are executed after `setImmediate()` callbacks. | ||
assert.strictEqual(netSocketCloseEmitted, false); | ||
assert.strictEqual(serverTlsSocket.destroyed, false); | ||
setImmediate(() => { | ||
assert.strictEqual(netSocketCloseEmitted, true); | ||
}); | ||
}); | ||
})); | ||
})); | ||
netSocket.destroy(); | ||
assert.strictEqual(netSocket.destroyed, true); | ||
|
||
setImmediate(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have separate tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really get what you mean, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are testing that the callback of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not called if e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added it only where it is needed given the current assumptions. If the logic changes there are other more places where it would be needed. |
||
// Close callbacks are executed after `setImmediate()` callbacks. | ||
assert.strictEqual(netSocketCloseEmitted, false); | ||
assert.strictEqual(serverTlsSocket.destroyed, false); | ||
}); | ||
}); | ||
|
||
clientTlsSocket.on('close', dec); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
common.mustCallAtLeast
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only one byte is sent by the other peer.