|
| 1 | +// Flags: --expose-internals |
1 | 2 | 'use strict';
|
2 | 3 |
|
3 | 4 | const common = require('../common');
|
@@ -25,41 +26,46 @@ const strictEqual = require('assert').strictEqual;
|
25 | 26 |
|
26 | 27 |
|
27 | 28 | const dgram = require('dgram');
|
| 29 | +const { kStateSymbol } = require('internal/dgram'); |
28 | 30 |
|
29 | 31 | // dgram ipv4
|
30 | 32 | {
|
31 | 33 | const sock4 = dgram.createSocket('udp4');
|
32 |
| - strictEqual(Object.getPrototypeOf(sock4._handle).hasOwnProperty('hasRef'), |
| 34 | + const handle = sock4[kStateSymbol].handle; |
| 35 | + |
| 36 | + strictEqual(Object.getPrototypeOf(handle).hasOwnProperty('hasRef'), |
33 | 37 | true, 'udp_wrap: ipv4: hasRef() missing');
|
34 |
| - strictEqual(sock4._handle.hasRef(), |
| 38 | + strictEqual(handle.hasRef(), |
35 | 39 | true, 'udp_wrap: ipv4: not initially refed');
|
36 | 40 | sock4.unref();
|
37 |
| - strictEqual(sock4._handle.hasRef(), |
| 41 | + strictEqual(handle.hasRef(), |
38 | 42 | false, 'udp_wrap: ipv4: unref() ineffective');
|
39 | 43 | sock4.ref();
|
40 |
| - strictEqual(sock4._handle.hasRef(), |
| 44 | + strictEqual(handle.hasRef(), |
41 | 45 | true, 'udp_wrap: ipv4: ref() ineffective');
|
42 |
| - sock4._handle.close(common.mustCall(() => |
43 |
| - strictEqual(sock4._handle.hasRef(), |
| 46 | + handle.close(common.mustCall(() => |
| 47 | + strictEqual(handle.hasRef(), |
44 | 48 | false, 'udp_wrap: ipv4: not unrefed on close')));
|
45 | 49 | }
|
46 | 50 |
|
47 | 51 |
|
48 | 52 | // dgram ipv6
|
49 | 53 | {
|
50 | 54 | const sock6 = dgram.createSocket('udp6');
|
51 |
| - strictEqual(Object.getPrototypeOf(sock6._handle).hasOwnProperty('hasRef'), |
| 55 | + const handle = sock6[kStateSymbol].handle; |
| 56 | + |
| 57 | + strictEqual(Object.getPrototypeOf(handle).hasOwnProperty('hasRef'), |
52 | 58 | true, 'udp_wrap: ipv6: hasRef() missing');
|
53 |
| - strictEqual(sock6._handle.hasRef(), |
| 59 | + strictEqual(handle.hasRef(), |
54 | 60 | true, 'udp_wrap: ipv6: not initially refed');
|
55 | 61 | sock6.unref();
|
56 |
| - strictEqual(sock6._handle.hasRef(), |
| 62 | + strictEqual(handle.hasRef(), |
57 | 63 | false, 'udp_wrap: ipv6: unref() ineffective');
|
58 | 64 | sock6.ref();
|
59 |
| - strictEqual(sock6._handle.hasRef(), |
| 65 | + strictEqual(handle.hasRef(), |
60 | 66 | true, 'udp_wrap: ipv6: ref() ineffective');
|
61 |
| - sock6._handle.close(common.mustCall(() => |
62 |
| - strictEqual(sock6._handle.hasRef(), |
| 67 | + handle.close(common.mustCall(() => |
| 68 | + strictEqual(handle.hasRef(), |
63 | 69 | false, 'udp_wrap: ipv6: not unrefed on close')));
|
64 | 70 | }
|
65 | 71 |
|
|
0 commit comments