Skip to content

Commit 480d4cc

Browse files
cjihrigitaloacasas
authored andcommitted
test: add coverage to dgram receive error case
This commit adds coverage for the case where a dgram socket handle receives a message, but nread < 0, indicating an error. PR-URL: #11241 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent ccd1163 commit 480d4cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const dgram = require('dgram');
5+
const s = dgram.createSocket('udp4');
6+
7+
s.on('error', common.mustCall((err) => {
8+
s.close();
9+
10+
// Don't check the full error message, as the errno is not important here.
11+
assert(/^Error: recvmsg/.test(err));
12+
assert.strictEqual(err.syscall, 'recvmsg');
13+
}));
14+
15+
s.on('message', common.mustNotCall('no message should be received.'));
16+
s.bind(common.mustCall(() => s._handle.onmessage(-1, s._handle, null, null)));

0 commit comments

Comments
 (0)