Skip to content

Commit 82882f4

Browse files
cjihrigitaloacasas
authored andcommitted
test: cover dgram socket close during bind case
This commit tests the scenario where a dgram socket closes during a call to Socket#bind(). PR-URL: #11383 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c3c874f commit 82882f4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
const common = require('../common');
3+
const dgram = require('dgram');
4+
const socket = dgram.createSocket('udp4');
5+
const lookup = socket._handle.lookup;
6+
7+
// Test the scenario where the socket is closed during a bind operation.
8+
socket._handle.bind = common.mustNotCall('bind() should not be called.');
9+
10+
socket._handle.lookup = common.mustCall(function(address, callback) {
11+
socket.close(common.mustCall(() => {
12+
lookup.call(this, address, callback);
13+
}));
14+
});
15+
16+
socket.bind(common.mustNotCall('Socket should not bind.'));

0 commit comments

Comments
 (0)