From: Brian Warner Date: Fri, 6 Apr 2007 05:36:18 +0000 (-0700) Subject: encode: clean up some weirdness that was there to make unit tests easier to write X-Git-Url: https://git.rkrishnan.org/pf/content/frontends/statistics?a=commitdiff_plain;h=8d2def5b04c6751b393c1117ea3372583fcc5b87;p=tahoe-lafs%2Ftahoe-lafs.git encode: clean up some weirdness that was there to make unit tests easier to write --- diff --git a/src/allmydata/encode.py b/src/allmydata/encode.py index a0e92922..7d958b37 100644 --- a/src/allmydata/encode.py +++ b/src/allmydata/encode.py @@ -229,11 +229,8 @@ class Encoder(object): return dl def send_subshare(self, shareid, segment_num, subshare): - return self.send(shareid, "put_block", segment_num, subshare) - - def send(self, shareid, methname, *args, **kwargs): - ll = self.landlords[shareid] - return ll.callRemote(methname, *args, **kwargs) + sh = self.landlords[shareid] + return sh.callRemote("put_block", segment_num, subshare) def send_all_subshare_hash_trees(self): dl = [] @@ -250,7 +247,8 @@ class Encoder(object): # all_hashes[1] is the left child, == hash(ah[3]+ah[4]) # all_hashes[n] == hash(all_hashes[2*n+1] + all_hashes[2*n+2]) self.share_root_hashes[shareid] = t[0] - return self.send(shareid, "put_block_hashes", all_hashes) + sh = self.landlords[shareid] + return sh.callRemote("put_block_hashes", all_hashes) def send_all_share_hash_trees(self): dl = [] @@ -272,12 +270,13 @@ class Encoder(object): return defer.DeferredList(dl) def send_one_share_hash_tree(self, shareid, needed_hashes): - return self.send(shareid, "put_share_hashes", needed_hashes) + sh = self.landlords[shareid] + return sh.callRemote("put_share_hashes", needed_hashes) def close_all_shareholders(self): dl = [] for shareid in range(self.num_shares): - dl.append(self.send(shareid, "close")) + dl.append(self.landlords[shareid].callRemote("close")) return defer.DeferredList(dl) def done(self): diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py index 71a91d7e..6372af89 100644 --- a/src/allmydata/test/test_encode.py +++ b/src/allmydata/test/test_encode.py @@ -7,14 +7,6 @@ from allmydata import encode, download from allmydata.uri import pack_uri from cStringIO import StringIO -class MyEncoder(encode.Encoder): - def send(self, share_num, methname, *args, **kwargs): - if False and share_num < 10: - print "send[%d].%s()" % (share_num, methname) - if methname == "put_share_hashes": - print " ", [i for i,h in args[0]] - return defer.succeed(None) - class FakePeer: def __init__(self, mode="good"): self.ss = FakeStorageServer(mode)