summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-01-27 16:16:57 -0800
committerRich Trott <rtrott@gmail.com>2019-01-29 18:36:04 -0800
commitb8977045f209c0de2d4d0333d098acd1823ded63 (patch)
tree1e9c34c00c4bb63b139fb586433be60d229fecc4 /test/parallel
parent8e6667f4d5e29f67a3c423935ac852967d7cad78 (diff)
downloadandroid-node-v8-b8977045f209c0de2d4d0333d098acd1823ded63.tar.gz
android-node-v8-b8977045f209c0de2d4d0333d098acd1823ded63.tar.bz2
android-node-v8-b8977045f209c0de2d4d0333d098acd1823ded63.zip
test: refactor test-http-client-timeout-option-with-agent
* Switch from Date.now() to process.hrtime.bigint(). * Move start time recording to before the request is created, not after. Fixes: https://github.com/nodejs/node/issues/25746 PR-URL: https://github.com/nodejs/node/pull/25752 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-http-client-timeout-option-with-agent.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/parallel/test-http-client-timeout-option-with-agent.js b/test/parallel/test-http-client-timeout-option-with-agent.js
index 7f20eb4e13..11a2db419c 100644
--- a/test/parallel/test-http-client-timeout-option-with-agent.js
+++ b/test/parallel/test-http-client-timeout-option-with-agent.js
@@ -30,8 +30,8 @@ server.listen(0, options.host, () => {
function doRequest() {
options.port = server.address().port;
+ const start = process.hrtime.bigint();
const req = http.request(options);
- const start = Date.now();
req.on('error', () => {
// This space is intentionally left blank.
});
@@ -40,11 +40,11 @@ function doRequest() {
let timeout_events = 0;
req.on('timeout', common.mustCall(() => {
timeout_events += 1;
- const duration = Date.now() - start;
+ const duration = process.hrtime.bigint() - start;
// The timeout event cannot be precisely timed. It will delay
// some number of milliseconds.
assert.ok(
- duration >= HTTP_CLIENT_TIMEOUT,
+ duration >= BigInt(HTTP_CLIENT_TIMEOUT * 1e6),
`duration ${duration}ms less than timeout ${HTTP_CLIENT_TIMEOUT}ms`
);
}));