diff --git a/test/parallel/test-dgram-ref.js b/test/parallel/test-dgram-ref.js index 6505ce9b1ec886..7b79340f924b06 100644 --- a/test/parallel/test-dgram-ref.js +++ b/test/parallel/test-dgram-ref.js @@ -1,7 +1,14 @@ 'use strict'; -require('../common'); -var dgram = require('dgram'); +const common = require('../common'); +const dgram = require('dgram'); // should not hang, see #1282 dgram.createSocket('udp4'); dgram.createSocket('udp6'); + +{ + // Test the case of ref()'ing a socket with no handle. + const s = dgram.createSocket('udp4'); + + s.close(common.mustCall(() => s.ref())); +} diff --git a/test/parallel/test-dgram-unref.js b/test/parallel/test-dgram-unref.js index e5f26b6f3387b8..1b92428a38e18b 100644 --- a/test/parallel/test-dgram-unref.js +++ b/test/parallel/test-dgram-unref.js @@ -2,8 +2,18 @@ const common = require('../common'); var dgram = require('dgram'); -var s = dgram.createSocket('udp4'); -s.bind(); -s.unref(); +{ + // Test the case of unref()'ing a socket with a handle. + const s = dgram.createSocket('udp4'); + s.bind(); + s.unref(); +} + +{ + // Test the case of unref()'ing a socket with no handle. + const s = dgram.createSocket('udp4'); + + s.close(common.mustCall(() => s.unref())); +} setTimeout(common.fail, 1000).unref();