From 5da7ebdfe724aa3a237b6462424d3a4aba9729aa Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 11 Oct 2017 16:34:13 -0400 Subject: [PATCH] Make rate limiter tests more tolerant of slight timing variations. This package contains some of the most fragile tests in the entire codebase, in large part because the author did not account for the nondeterminism of JS timers across platforms and test runs. --- packages/ddp-rate-limiter/ddp-rate-limiter-tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ddp-rate-limiter/ddp-rate-limiter-tests.js b/packages/ddp-rate-limiter/ddp-rate-limiter-tests.js index 2d30d61df6..3c300181bf 100644 --- a/packages/ddp-rate-limiter/ddp-rate-limiter-tests.js +++ b/packages/ddp-rate-limiter/ddp-rate-limiter-tests.js @@ -95,7 +95,7 @@ testAsyncMulti("ddp rate limiter - callbacks get passed correct arguments", [ Meteor.call( "getLastRateLimitEvent", expect(function (error, result) { test.isTrue(result.reply.allowed); - test.isTrue(result.reply.timeToReset < RATE_LIMIT_INTERVAL_TIME_MS); + test.isTrue(result.reply.timeToReset < RATE_LIMIT_INTERVAL_TIME_MS + 100); test.equal(result.reply.numInvocationsLeft, 4); test.equal(result.ruleInput.userId, Meteor.userId()); @@ -118,7 +118,7 @@ testAsyncMulti("ddp rate limiter - callbacks get passed correct arguments", [ Meteor.call( "getLastRateLimitEvent", expect(function (error, result) { test.isFalse(result.reply.allowed); - test.isTrue(result.reply.timeToReset < RATE_LIMIT_INTERVAL_TIME_MS); + test.isTrue(result.reply.timeToReset < RATE_LIMIT_INTERVAL_TIME_MS + 100); test.equal(result.reply.numInvocationsLeft, 0); test.equal(result.ruleInput.userId, Meteor.userId());