improve RemoteInterface specifications
authorBrian Warner <warner@lothar.com>
Sat, 2 Dec 2006 23:03:09 +0000 (16:03 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 2 Dec 2006 23:03:09 +0000 (16:03 -0700)
allmydata/interfaces.py
allmydata/test/test_storage.py

index 7886e0fbf6fce9f9a55d91e4ec91673ba84e886c..0bacbd439c470b7d3ae0d220b7fc8a174ce90278 100644 (file)
@@ -2,40 +2,42 @@
 from foolscap.schema import StringConstraint, ListOf, TupleOf, Any, Nothing
 from foolscap import RemoteInterface
 
-Nodeid = StringConstraint(20)
+Nodeid = StringConstraint(20) # base32 encoded 20-byte SHA1 hash
 PBURL = StringConstraint()
+Tubid = StringConstraint()
+ShareData = StringConstraint(20000)
 # these three are here because Foolscap does not yet support the kind of
 # restriction I really want to apply to these.
-RIClient_ = Any
-Referenceable_ = Any
-RIBucketWriter_ = Any
+RIClient_ = Any()
+Referenceable_ = Any()
+RIBucketWriter_ = Any()
 
 class RIQueenRoster(RemoteInterface):
     def hello(nodeid=Nodeid, node=RIClient_, pburl=PBURL):
-        return Nothing
+        return Nothing()
 
 class RIClient(RemoteInterface):
     def get_service(name=str):
         return Referenceable_
     def add_peers(new_peers=ListOf(TupleOf(Nodeid, PBURL), maxLength=100)):
-        return Nothing
+        return Nothing()
     def lost_peers(lost_peers=ListOf(Nodeid)):
-        return Nothing
+        return Nothing()
 
 class RIStorageServer(RemoteInterface):
     def allocate_bucket(verifierid=Nodeid, bucket_num=int, size=int,
-                        leaser=Nodeid):
+                        leaser=Tubid):
         return RIBucketWriter_
 
 
 class RIBucketWriter(RemoteInterface):
-    def write(data=str):
-        return Nothing
+    def write(data=ShareData):
+        return Nothing()
 
     def set_size(size=int):
-        return Nothing
+        return Nothing()
 
     def close():
-        return Nothing
+        return Nothing()
 
 
index fa9eafe04ea231bd2c5eede2426b3b8957097c8d..b062811163dae78eca4969fb322eecb39d5d719b 100644 (file)
@@ -7,6 +7,7 @@ from twisted.application import service
 from twisted.internet import defer
 from twisted.python import log
 from foolscap import Tub
+from foolscap.eventual import flushEventualQueue
 
 from allmydata import client
 
@@ -129,4 +130,6 @@ class StorageTest(unittest.TestCase):
         return rssd
 
     def tearDown(self):
-        return self.svc.stopService()
+        d = self.svc.stopService()
+        d.addCallback(lambda res: flushEventualQueue())
+        return d