mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 14:34:40 +00:00

Improve error messages in the async hooks tests, mostly by removing unhelpful `message` parameters for assertions. PR-URL: https://github.com/nodejs/node/pull/13243 Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
38 lines
1012 B
JavaScript
38 lines
1012 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const tick = require('./tick');
|
|
const initHooks = require('./init-hooks');
|
|
const { checkInvocations } = require('./hook-checks');
|
|
const dgram = require('dgram');
|
|
|
|
const hooks = initHooks();
|
|
|
|
hooks.enable();
|
|
const sock = dgram.createSocket('udp4');
|
|
|
|
const as = hooks.activitiesOfTypes('UDPWRAP');
|
|
const udpwrap = as[0];
|
|
assert.strictEqual(as.length, 1);
|
|
assert.strictEqual(udpwrap.type, 'UDPWRAP');
|
|
assert.strictEqual(typeof udpwrap.uid, 'number');
|
|
assert.strictEqual(typeof udpwrap.triggerId, 'number');
|
|
checkInvocations(udpwrap, { init: 1 }, 'after dgram.createSocket call');
|
|
|
|
sock.close(common.mustCall(onsockClosed));
|
|
|
|
function onsockClosed() {
|
|
checkInvocations(udpwrap, { init: 1 }, 'when socket is closed');
|
|
tick(2);
|
|
}
|
|
|
|
process.on('exit', onexit);
|
|
|
|
function onexit() {
|
|
hooks.disable();
|
|
hooks.sanityCheck('UDPWRAP');
|
|
checkInvocations(udpwrap, { init: 1, destroy: 1 },
|
|
'when process exits');
|
|
}
|