From: Brian Warner Date: Sat, 2 Dec 2006 23:03:09 +0000 (-0700) Subject: improve RemoteInterface specifications X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~498 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css?a=commitdiff_plain;h=70f58b195c8f3b136a80a84d90124eeda4c312f0;p=tahoe-lafs%2Ftahoe-lafs.git improve RemoteInterface specifications --- diff --git a/allmydata/interfaces.py b/allmydata/interfaces.py index 7886e0fb..0bacbd43 100644 --- a/allmydata/interfaces.py +++ b/allmydata/interfaces.py @@ -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() diff --git a/allmydata/test/test_storage.py b/allmydata/test/test_storage.py index fa9eafe0..b0628111 100644 --- a/allmydata/test/test_storage.py +++ b/allmydata/test/test_storage.py @@ -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