Skip to content
Snippets Groups Projects
Commit 00f85d15 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

pass the whole clock to StorageServer, as Tahoe-LAFS wants

parent 0db734c0
No related branches found
No related tags found
1 merge request!275Depend on/Compatibility with Tahoe-LAFS 1.17.0
...@@ -21,7 +21,6 @@ from __future__ import absolute_import ...@@ -21,7 +21,6 @@ from __future__ import absolute_import
from base64 import b64encode from base64 import b64encode
import attr import attr
from allmydata import __version__ as allmydata_version
from allmydata.storage.server import StorageServer from allmydata.storage.server import StorageServer
from fixtures import Fixture, TempDir from fixtures import Fixture, TempDir
from twisted.internet.task import Clock from twisted.internet.task import Clock
...@@ -51,18 +50,10 @@ class AnonymousStorageServer(Fixture): ...@@ -51,18 +50,10 @@ class AnonymousStorageServer(Fixture):
def _setUp(self): def _setUp(self):
self.tempdir = FilePath(self.useFixture(TempDir()).join(b"storage")) self.tempdir = FilePath(self.useFixture(TempDir()).join(b"storage"))
if allmydata_version >= "1.16.":
# This version of Tahoe adds a new StorageServer argument for
# controlling time.
timeargs = {"get_current_time": self.clock.seconds}
else:
# Older versions just use time.time() and there's not much we can
# do _here_. Code somewhere else will have to monkey-patch that
# to control things.
timeargs = {}
self.storage_server = StorageServer( self.storage_server = StorageServer(
self.tempdir.asBytesMode().path, b"x" * 20, **timeargs self.tempdir.asBytesMode().path,
b"x" * 20,
clock=self.clock,
) )
......
...@@ -21,7 +21,6 @@ from __future__ import absolute_import ...@@ -21,7 +21,6 @@ from __future__ import absolute_import
from allmydata.storage.common import storage_index_to_dir from allmydata.storage.common import storage_index_to_dir
from allmydata.storage.shares import get_share_file from allmydata.storage.shares import get_share_file
from challenge_bypass_ristretto import PublicKey, random_signing_key from challenge_bypass_ristretto import PublicKey, random_signing_key
from fixtures import MonkeyPatch
from foolscap.referenceable import LocalReferenceable from foolscap.referenceable import LocalReferenceable
from hypothesis import assume, given from hypothesis import assume, given
from hypothesis.strategies import data as data_strategy from hypothesis.strategies import data as data_strategy
...@@ -540,15 +539,6 @@ class ShareTests(TestCase): ...@@ -540,15 +539,6 @@ class ShareTests(TestCase):
self.clock.advance(when) self.clock.advance(when)
# anonymous_storage_server uses time.time() before Tahoe-LAFS 1.16,
# unfortunately. For Tahoe-LAFS 1.16, AnonymousStorageServer will
# glue self.clock in for us. For older versions we still need this
# monkey-patching.
#
# And useFixture does not interact very well with Hypothesis.
patch = MonkeyPatch("time.time", self.clock.seconds)
try:
patch.setUp()
# Create a share we can toy with. # Create a share we can toy with.
write_shares( write_shares(
self.anonymous_storage_server, self.anonymous_storage_server,
...@@ -565,8 +555,6 @@ class ShareTests(TestCase): ...@@ -565,8 +555,6 @@ class ShareTests(TestCase):
renew_secret, renew_secret,
cancel_secret, cancel_secret,
) )
finally:
patch.cleanUp()
expected = [ expected = [
{ {
...@@ -771,9 +759,6 @@ class ShareTests(TestCase): ...@@ -771,9 +759,6 @@ class ShareTests(TestCase):
""" """
self.clock.advance(when) self.clock.advance(when)
patch = MonkeyPatch("time.time", self.clock.seconds)
try:
patch.setUp()
# Create a share we can toy with. # Create a share we can toy with.
wrote, read = extract_result( wrote, read = extract_result(
self.client.slot_testv_and_readv_and_writev( self.client.slot_testv_and_readv_and_writev(
...@@ -786,8 +771,6 @@ class ShareTests(TestCase): ...@@ -786,8 +771,6 @@ class ShareTests(TestCase):
r_vector=[], r_vector=[],
), ),
) )
finally:
patch.cleanUp()
self.assertThat( self.assertThat(
wrote, wrote,
Equals(True), Equals(True),
...@@ -1052,10 +1035,6 @@ class ShareTests(TestCase): ...@@ -1052,10 +1035,6 @@ class ShareTests(TestCase):
r_vector=[], r_vector=[],
) )
patch = MonkeyPatch("time.time", self.clock.seconds)
try:
patch.setUp()
# Create a share we can toy with. # Create a share we can toy with.
self.assertThat(write(), is_successful_write()) self.assertThat(write(), is_successful_write())
...@@ -1064,8 +1043,6 @@ class ShareTests(TestCase): ...@@ -1064,8 +1043,6 @@ class ShareTests(TestCase):
self.clock.advance(self.server.LEASE_PERIOD.total_seconds() + 1) self.clock.advance(self.server.LEASE_PERIOD.total_seconds() + 1)
self.assertThat(write(), is_successful_write()) self.assertThat(write(), is_successful_write())
finally:
patch.cleanUp()
# The spent passes have been reported to the spending service. # The spent passes have been reported to the spending service.
self.assertThat( self.assertThat(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment