Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test-dgram-oob-buffer #13443

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/parallel/test-dgram-oob-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,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(() => {
socket.send(buf, 0, 0, address.port, address.address, common.noop);
socket.send(buf, 0, 4, address.port, address.address, common.noop);
socket.send(buf, 1, 3, address.port, address.address, common.noop);
socket.send(buf, 3, 1, address.port, address.address, common.noop);
socket.send(buf, 0, 0, port, address, common.mustNotCall());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the callback be called in all cases?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something like assert.ifError would be better here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The socket.close() on line 43 cancels the callbacks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the original test at defa637378a it seems like this test may no longer have the same meaning originally intended. It seems to me that the key point was the assert.throws() calls. However, they no longer throw.

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, common.noop);
socket.send(buf, 4, 0, port, address, common.mustNotCall());

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