test: fix test-async-wrap-getasyncid flakyness

The test used to assume that if the client successfully writes data to
the server and closes the connection, then the server must have received
that data and ran its connection callback wrapped by common.mustCall.

However, it is not necessarily the case, and as a result the test was
flaky.

With this change, the server is closed only once the server's connection
callback has been called, which guarantees that the server can accept
connections until it actually accepted the single connection that this
test requires to accept, making the test not flaky.

PR-URL: https://github.com/nodejs/node/pull/14329
Fixes: https://github.com/nodejs/node/issues/13020
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
This commit is contained in:
Julien Gilli 2017-07-17 10:21:21 -07:00
parent c24a73d23c
commit 2da1af0a93

View File

@ -160,6 +160,7 @@ if (common.hasCrypto) {
const stream_wrap = process.binding('stream_wrap');
const tcp_wrap = process.binding('tcp_wrap');
const server = net.createServer(common.mustCall((socket) => {
server.close();
socket.on('data', (x) => {
socket.end();
socket.destroy();
@ -176,7 +177,6 @@ if (common.hasCrypto) {
sreq.oncomplete = common.mustCall(() => {
handle.close();
server.close();
});
wreq.handle = handle;