• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const tick = require('../common/tick');
6const initHooks = require('./init-hooks');
7const { checkInvocations } = require('./hook-checks');
8const dgram = require('dgram');
9
10const hooks = initHooks();
11
12hooks.enable();
13const sock = dgram.createSocket('udp4');
14
15const as = hooks.activitiesOfTypes('UDPWRAP');
16const udpwrap = as[0];
17assert.strictEqual(as.length, 1);
18assert.strictEqual(udpwrap.type, 'UDPWRAP');
19assert.strictEqual(typeof udpwrap.uid, 'number');
20assert.strictEqual(typeof udpwrap.triggerAsyncId, 'number');
21checkInvocations(udpwrap, { init: 1 }, 'after dgram.createSocket call');
22
23sock.close(common.mustCall(onsockClosed));
24
25function onsockClosed() {
26  checkInvocations(udpwrap, { init: 1 }, 'when socket is closed');
27  tick(2);
28}
29
30process.on('exit', onexit);
31
32function onexit() {
33  hooks.disable();
34  hooks.sanityCheck('UDPWRAP');
35  checkInvocations(udpwrap, { init: 1, destroy: 1 },
36                   'when process exits');
37}
38