test: cover dgram handle send failures
This commit adds test coverage for the case where a dgram socket successfully binds, but the handle's send() function fails. PR-URL: https://github.com/nodejs/node/pull/13158 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
413691fde0
commit
06757cd0dc
@ -35,3 +35,32 @@ getSocket((socket) => {
|
||||
|
||||
socket.send('foo', socket.address().port, 'localhost', callback);
|
||||
});
|
||||
|
||||
{
|
||||
const socket = dgram.createSocket('udp4');
|
||||
|
||||
socket.on('message', common.mustNotCall('Should not receive any messages.'));
|
||||
|
||||
socket.bind(common.mustCall(() => {
|
||||
const port = socket.address().port;
|
||||
const errCode = process.binding('uv').UV_UNKNOWN;
|
||||
const callback = common.mustCall((err) => {
|
||||
socket.close();
|
||||
assert.strictEqual(err.code, 'UNKNOWN');
|
||||
assert.strictEqual(err.errno, 'UNKNOWN');
|
||||
assert.strictEqual(err.syscall, 'send');
|
||||
assert.strictEqual(err.address, common.localhostIPv4);
|
||||
assert.strictEqual(err.port, port);
|
||||
assert.strictEqual(
|
||||
err.message,
|
||||
`${err.syscall} ${err.code} ${err.address}:${err.port}`
|
||||
);
|
||||
});
|
||||
|
||||
socket._handle.send = function() {
|
||||
return errCode;
|
||||
};
|
||||
|
||||
socket.send('foo', port, common.localhostIPv4, callback);
|
||||
}));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user