node/test/parallel/test-dgram-connect-send-callback-buffer-length.js
jyjunyz 558e5c4367 test: add mustcall in test-dgram-connect-send-callback-buffer-length
add mustcall() on client.bind callback

PR-URL: https://github.com/nodejs/node/pull/27464
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-04-29 00:04:56 +08:00

25 lines
627 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
const client = dgram.createSocket('udp4');
const buf = Buffer.allocUnsafe(256);
const offset = 20;
const len = buf.length - offset;
const messageSent = common.mustCall(function messageSent(err, bytes) {
assert.ifError(err);
assert.notStrictEqual(bytes, buf.length);
assert.strictEqual(bytes, buf.length - offset);
client.close();
});
client.bind(0, common.mustCall(() => {
client.connect(client.address().port, common.mustCall(() => {
client.send(buf, offset, len, messageSent);
}));
}));