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

internet: improve assert message #15998

Closed
Closed
Changes from 4 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
3 changes: 2 additions & 1 deletion test/internet/test-dgram-broadcast-multi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ if (process.argv[2] !== 'child') {
assert.strictEqual(
count,
messages.length,
'A worker received an invalid multicast message'
'A worker received an invalid multicast message. ' +
`Received ${count} and wanted ${messages.length}.`
Copy link
Member

@lpinca lpinca Oct 17, 2017

Choose a reason for hiding this comment

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

@nikkistonge sorry to pester, but I think the message is still misleading.

If you look at the code, the above assertion is run only when all workers have received all the messages. After that the test validates that each message received by the workers matches the original using a counter for each worker. If the count does not match the assertion throws.

My point is that the "Received x and wanted y." feedback is wrong as all messages have actually been received but one ore more of them is invalid/corrupted.

If you could just refactor this into assert.strictEqual(count, messages.length); that would be 10/10 imho as this will remove any possible confusion by using the default error message.

Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Ok changed, now it will use default message :)

);
});

Expand Down