0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-dgram-msgsize.js
Fabrice Tatieze f6d15b033b test: using const and strictEqual
PR-URL: https://github.com/nodejs/node/pull/9926
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-05 19:46:30 -08:00

19 lines
655 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
// Send a too big datagram. The destination doesn't matter because it's
// not supposed to get sent out anyway.
const buf = Buffer.allocUnsafe(256 * 1024);
const sock = dgram.createSocket('udp4');
sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb));
function cb(err) {
assert(err instanceof Error);
assert.strictEqual(err.code, 'EMSGSIZE');
assert.strictEqual(err.address, '127.0.0.1');
assert.strictEqual(err.port, 12345);
assert.strictEqual(err.message, 'send EMSGSIZE 127.0.0.1:12345');
sock.close();
}