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: refactor test for net listen on fd0 #10025

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
28 changes: 10 additions & 18 deletions test/parallel/test-net-listen-fd0.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const net = require('net');

var gotError = false;

process.on('exit', function() {
assert(gotError instanceof Error);
});

// this should fail with an async EINVAL error, not throw an exception
net.createServer(common.fail).listen({fd: 0}).on('error', function(e) {
switch (e.code) {
case 'EINVAL':
case 'ENOTSOCK':
gotError = e;
break;
}
});
// This should fail with an async EINVAL error, not throw an exception
net.createServer(common.fail)
.listen({fd: 0})
.on('error', common.mustCall(function(e) {
assert(e instanceof Error);
assert(['EINVAL', 'ENOTSOCK'].includes(e.code));
}));