GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 74ad2d91 authored by Georg Koppen's avatar Georg Koppen

Use freeze_time() in other parts of our tests, too

When using `_relays_with_flags()` and similar methods it's possible
that tests start to hang without time freezing. See bug 33748 for more
details. We work around this by providing the necessary `freeze_time()`
calls meanwhile.
parent 3efb6867
...@@ -3,6 +3,7 @@ import pytest ...@@ -3,6 +3,7 @@ import pytest
import os.path import os.path
from unittest import mock from unittest import mock
from freezegun import freeze_time
from stem import descriptor from stem import descriptor
from sbws import settings from sbws import settings
...@@ -120,7 +121,8 @@ def router_status(server_descriptor, router_statuses): ...@@ -120,7 +121,8 @@ def router_status(server_descriptor, router_statuses):
@pytest.fixture(scope='function') @pytest.fixture(scope='function')
def relay_list(args, conf, controller): def relay_list(args, conf, controller):
"""Returns a RelayList containing the Relays in the controller""" """Returns a RelayList containing the Relays in the controller"""
return relaylist.RelayList(args, conf, controller) with freeze_time("2020-02-29 10:00:00"):
return relaylist.RelayList(args, conf, controller)
@pytest.fixture(scope='function') @pytest.fixture(scope='function')
......
...@@ -71,9 +71,8 @@ def test_increment_recent_measurement_attempt(args, conf, controller): ...@@ -71,9 +71,8 @@ def test_increment_recent_measurement_attempt(args, conf, controller):
It also tests that the state file is updated correctly. It also tests that the state file is updated correctly.
""" """
state = State(conf['paths']['state_fpath']) state = State(conf['paths']['state_fpath'])
# For this test it does not matter that the consensus timestamps or relays with freeze_time("2020-02-29 10:00:00"):
# are not correct. relay_list = RelayList(args, conf, controller=controller, state=state)
relay_list = RelayList(args, conf, controller=controller, state=state)
# The initial count is 0 and the state does not have that key. # The initial count is 0 and the state does not have that key.
assert 0 == relay_list.recent_measurement_attempt_count assert 0 == relay_list.recent_measurement_attempt_count
assert not state.get("recent_measurement_attempt", None) assert not state.get("recent_measurement_attempt", None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment