Skip to content

Commit

Permalink
test: cover dgram socket close during bind case
Browse files Browse the repository at this point in the history
This commit tests the scenario where a dgram socket closes
during a call to Socket#bind().

PR-URL: #11383
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
cjihrig authored and italoacasas committed Feb 22, 2017
1 parent c3c874f commit 82882f4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/parallel/test-dgram-close-during-bind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';
const common = require('../common');
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
const lookup = socket._handle.lookup;

// Test the scenario where the socket is closed during a bind operation.
socket._handle.bind = common.mustNotCall('bind() should not be called.');

socket._handle.lookup = common.mustCall(function(address, callback) {
socket.close(common.mustCall(() => {
lookup.call(this, address, callback);
}));
});

socket.bind(common.mustNotCall('Socket should not bind.'));

0 comments on commit 82882f4

Please sign in to comment.