Skip to content
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: fix flaky test-net-connect-local-error #12964

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');

const server = net.createServer();
server.listen(0);
const port = server.address().port;
const client = net.connect({
port: port + 1,
localPort: port,
port: common.PORT + 1,
localPort: common.PORT,
localAddress: common.localhostIPv4
});

client.on('error', common.mustCall(function onError(err) {
assert.strictEqual(err.syscall, 'connect');
assert.strictEqual(err.code, 'ECONNREFUSED');
assert.strictEqual(
err.localPort,
port,
`${err.localPort} !== ${port} in ${err}`
common.PORT,
`${err.localPort} !== ${common.PORT} in ${err}`
);
assert.strictEqual(
err.localAddress,
common.localhostIPv4,
`${err.localAddress} !== ${common.localhostIPv4} in ${err}`
);
}));
server.close();
assert.strictEqual(
err.message,
`connect ECONNREFUSED ${err.address}:${err.port} ` +
`- Local (${err.localAddress}:${err.localPort})`
);
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Future reference we require an LF as the last character of all files.
That's why the linter failed (always good to do make lint) before a commit
Don't worry about this, I'll fix this when I land the PR.

Copy link
Author

@sebastianplesciuc sebastianplesciuc May 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I didn't think to run the linter since make test failed on my machine. It may be my fault. I might need to rebuild.

P.S.: Yep. I needed to rebuild :( My bad.