-
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
net: add localAddress/Port for better error msgs #3946
Changes from 3 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var net = require('net'); | ||
|
||
var client = net.connect({ | ||
port: common.PORT + 1, | ||
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'm not sure which port to use here, it simply should produce an ECONNREFUSED error when connecting. |
||
localPort: common.PORT, | ||
localAddress: '127.0.0.1' | ||
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. Instead of hard coding the IP address, can you use |
||
}); | ||
|
||
var onErrorCalled = false; | ||
client.on('error', function(err) { | ||
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. instead of having the You could then remove the |
||
assert.equal(err.localPort, common.PORT); | ||
assert.equal(err.localAddress, '127.0.0.1'); | ||
onErrorCalled = true; | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.ok(onErrorCalled); | ||
}); |
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.
mind making these
const
instead of var?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.
I copied that from another test. Should I make a PR that changes this for every test where it isn't already the new way?
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.
I believe the plan is to update them as we go. But in general, all new tests should use const wherever possible