From e62d2a5a275c2150bc4f0bd00a69f60640e59e58 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 20 Aug 2019 09:28:05 -0400 Subject: [PATCH 1/2] In reality we cannot handle a Deferred here ... yet? This code is invoked from an `__init__` where async is always tricky. Maybe we can invert the relationship someday. --- src/allmydata/interfaces.py | 2 +- src/allmydata/storage_client.py | 2 +- src/allmydata/test/test_storage_client.py | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 012eb53e2..0d9b3b885 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -3114,7 +3114,7 @@ class IFoolscapStoragePlugin(IPlugin): server portion of this plugin on the currently active connection, or ``None`` if no connection has been established yet. - :rtype: ``Deferred`` firing with ``IStorageServer`` + :rtype: ``IStorageServer`` """ def get_client_resource(configuration): diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index ef148a4c1..5f258d934 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -446,7 +446,7 @@ class _FoolscapStorage(object): permutation_seed = attr.ib() tubid = attr.ib() - storage_server = attr.ib() + storage_server = attr.ib(validator=attr.validators.provides(IStorageServer)) _furl = attr.ib() _short_description = attr.ib() diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py index b59b93347..fb56f5ecb 100644 --- a/src/allmydata/test/test_storage_client.py +++ b/src/allmydata/test/test_storage_client.py @@ -15,6 +15,9 @@ from testtools.matchers import ( AfterPreprocessing, ) +from zope.interface import ( + implementer, +) from zope.interface.verify import ( verifyObject, ) @@ -59,6 +62,7 @@ from allmydata.storage_client import ( ) from allmydata.interfaces import ( IConnectionStatus, + IStorageServer, ) SOME_FURL = b"pb://abcde@nowhere/fake" @@ -381,6 +385,9 @@ class FoolscapStorageServers(unittest.TestCase): """ Instances of ``_FoolscapStorage`` provide ``IFoolscapStorageServer``. """ + @implementer(IStorageServer) + class NotStorageServer(object): + pass self.assertTrue( verifyObject( IFoolscapStorageServer, @@ -388,7 +395,7 @@ class FoolscapStorageServers(unittest.TestCase): u"server-id", SOME_FURL, {u"permutation-seed-base32": base32.b2a(b"permutationseed")}, - object(), + NotStorageServer(), ), ), ) From 06e9d93d972befcc68fe4b0d92957203211a8ed7 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 20 Aug 2019 09:30:40 -0400 Subject: [PATCH 2/2] news fragment --- newsfragments/3250.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3250.minor diff --git a/newsfragments/3250.minor b/newsfragments/3250.minor new file mode 100644 index 000000000..e69de29bb