summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2019-05-31 11:09:34 +0100
committerBrendan Abolivier <babolivier@matrix.org>2019-05-31 11:09:39 +0100
commit4d794dae210ce30e87d8a6b9ee2f9b481cadf539 (patch)
tree6723d9e593f48877693cdefb8b3a5453e10ae4be
parentSample config (diff)
downloadsynapse-4d794dae210ce30e87d8a6b9ee2f9b481cadf539.tar.xz
Move delta from +10% to -10%
-rw-r--r--synapse/config/registration.py2
-rw-r--r--synapse/storage/_base.py4
-rw-r--r--tests/rest/client/v2_alpha/test_register.py4
3 files changed, 5 insertions, 5 deletions
diff --git a/synapse/config/registration.py b/synapse/config/registration.py
index 4af825a2ab..aad3400819 100644
--- a/synapse/config/registration.py
+++ b/synapse/config/registration.py
@@ -132,7 +132,7 @@ class RegistrationConfig(Config):
         # then derive an expiration date from the current validity period), and some time
         # after that the validity period changes and Synapse is restarted, the users'
         # expiration dates won't be updated unless their account is manually renewed. This
-        # date will be randomly selected within a range [now + period ; now + period + d],
+        # date will be randomly selected within a range [now + period - d ; now + period],
         # where d is equal to 10%% of the validity period.
         #
         #account_validity:
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 7f944ec717..086318a530 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -329,7 +329,7 @@ class SQLBaseStore(object):
              user_id (str): User ID to set an expiration date for.
              use_delta (bool): If set to False, the expiration date for the user will be
                 now + validity period. If set to True, this expiration date will be a
-                random value in the [now + period; now + period + d] range, d being a
+                random value in the [now + period - d ; now + period] range, d being a
                 delta equal to 10% of the validity period.
         """
         now_ms = self._clock.time_msec()
@@ -337,8 +337,8 @@ class SQLBaseStore(object):
 
         if use_delta:
             expiration_ts = self.rand.randrange(
+                expiration_ts - self._account_validity.startup_job_max_delta,
                 expiration_ts,
-                expiration_ts + self._account_validity.startup_job_max_delta,
             )
 
         self._simple_insert_txn(
diff --git a/tests/rest/client/v2_alpha/test_register.py b/tests/rest/client/v2_alpha/test_register.py
index 711628ded1..0cb6a363d6 100644
--- a/tests/rest/client/v2_alpha/test_register.py
+++ b/tests/rest/client/v2_alpha/test_register.py
@@ -467,5 +467,5 @@ class AccountValidityBackgroundJobTestCase(unittest.HomeserverTestCase):
 
         res = self.get_success(self.store.get_expiration_ts_for_user(user_id))
 
-        self.assertLessEqual(res, now_ms + self.validity_period + self.max_delta)
-        self.assertGreaterEqual(res, now_ms + self.validity_period)
+        self.assertGreaterEqual(res, now_ms + self.validity_period - self.max_delta)
+        self.assertLessEqual(res, now_ms + self.validity_period)