Skip to content

Commit

Permalink
test: refactor test-dgram-oob-buffer
Browse files Browse the repository at this point in the history
* Change common.noop to common.mustNotCall() to verify callback is not
  invoked.
* Add destructuring assignment for clarity. Yeah, clarity. That's why.

PR-URL: #13443
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Aug 16, 2017
1 parent 08f7cca commit 91fb0cb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/parallel/test-dgram-oob-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ const socket = dgram.createSocket('udp4');
const buf = Buffer.from([1, 2, 3, 4]);
const portGetter = dgram.createSocket('udp4')
.bind(0, 'localhost', common.mustCall(() => {
const address = portGetter.address();
const { address, port } = portGetter.address();
portGetter.close(common.mustCall(() => {
function ok() {}
socket.send(buf, 0, 0, address.port, address.address, ok);
socket.send(buf, 0, 4, address.port, address.address, ok);
socket.send(buf, 1, 3, address.port, address.address, ok);
socket.send(buf, 3, 1, address.port, address.address, ok);
socket.send(buf, 0, 0, port, address, common.mustNotCall());
socket.send(buf, 0, 4, port, address, common.mustNotCall());
socket.send(buf, 1, 3, port, address, common.mustNotCall());
socket.send(buf, 3, 1, port, address, common.mustNotCall());
// Since length of zero means nothing, don't error despite OOB.
socket.send(buf, 4, 0, address.port, address.address, ok);
socket.send(buf, 4, 0, port, address, common.mustNotCall());

socket.close();
}));
Expand Down

0 comments on commit 91fb0cb

Please sign in to comment.