From 82882f4e90a23f989a4d7c6b9098413b3957a64e Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 14 Feb 2017 14:07:39 -0500 Subject: [PATCH] test: cover dgram socket close during bind case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit tests the scenario where a dgram socket closes during a call to Socket#bind(). PR-URL: https://github.com/nodejs/node/pull/11383 Reviewed-By: Rich Trott Reviewed-By: Michaƫl Zasso --- test/parallel/test-dgram-close-during-bind.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/parallel/test-dgram-close-during-bind.js diff --git a/test/parallel/test-dgram-close-during-bind.js b/test/parallel/test-dgram-close-during-bind.js new file mode 100644 index 00000000000000..1764f66e7338ac --- /dev/null +++ b/test/parallel/test-dgram-close-during-bind.js @@ -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.'));