mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 12:20:50 +01:00
* Liberal use of common.mustCall()
* Rename test-dgram-empty-packet -> test-dgram-send-empty-packet
* Remove use of timers to avoid CI failures like seen in the Ref below:
```
not ok 237 parallel/test-dgram-empty-packet
---
duration_ms: 0.717
severity: fail
stack: |-
...
throw new Error('Timeout');
^
Error: Timeout
at Timeout._onTimeout
...
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
```
Refs: https://ci.nodejs.org/job/node-test-commit-freebsd/5341/nodes=freebsd11-x64/console:
PR-URL: https://github.com/nodejs/node/pull/9724
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
28 lines
659 B
JavaScript
28 lines
659 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
if (common.isOSX) {
|
|
common.skip('because of 17894467 Apple bug');
|
|
return;
|
|
}
|
|
|
|
const dgram = require('dgram');
|
|
|
|
const client = dgram.createSocket('udp4');
|
|
|
|
client.bind(0, common.mustCall(function() {
|
|
const port = this.address().port;
|
|
|
|
client.on('message', common.mustCall(function onMessage(buffer) {
|
|
assert.strictEqual(buffer.length, 0);
|
|
clearInterval(interval);
|
|
client.close();
|
|
}));
|
|
|
|
const buf = Buffer.alloc(0);
|
|
var interval = setInterval(function() {
|
|
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {}));
|
|
}, 10);
|
|
}));
|