File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ // Flags: --expose-internals --no-warnings --allow-natives-syntax --test-udp-no-try-send
2+ 'use strict' ;
3+
4+ const common = require ( '../common' ) ;
5+ const assert = require ( 'assert' ) ;
6+ const dgram = require ( 'dgram' ) ;
7+
8+ const { internalBinding } = require ( 'internal/test/binding' ) ;
9+
10+ function testFastDgram ( ) {
11+ const server = dgram . createSocket ( 'udp4' ) ;
12+ const client = dgram . createSocket ( 'udp4' ) ;
13+
14+ server . bind ( 0 , common . mustCall ( ( ) => {
15+ client . connect ( server . address ( ) . port , common . mustCall ( ( ) => {
16+ // Send some packets to queue them up (using --test-udp-no-try-send flag)
17+ client . send ( 'Hello' ) ;
18+ client . send ( 'World' ) ;
19+
20+ assert . strictEqual ( typeof client . getSendQueueSize ( ) , 'number' ) ;
21+ assert . strictEqual ( typeof client . getSendQueueCount ( ) , 'number' ) ;
22+
23+ client . close ( ) ;
24+ server . close ( ) ;
25+ } ) ) ;
26+ } ) ) ;
27+ }
28+
29+ eval ( '%PrepareFunctionForOptimization(testFastDgram)' ) ;
30+ testFastDgram ( ) ;
31+ eval ( '%OptimizeFunctionOnNextCall(testFastDgram)' ) ;
32+ testFastDgram ( ) ;
33+
34+ if ( common . isDebug ) {
35+ const { getV8FastApiCallCount } = internalBinding ( 'debug' ) ;
36+ assert . strictEqual ( getV8FastApiCallCount ( 'udp.getSendQueueSize' ) , 1 ) ;
37+ assert . strictEqual ( getV8FastApiCallCount ( 'udp.getSendQueueCount' ) , 1 ) ;
38+ }
You can’t perform that action at this time.
0 commit comments