mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
mutable: minor refactoring of _do_read, to make other tests easier
This commit is contained in:
parent
cad26e000d
commit
d6cde55c63
@ -1098,10 +1098,15 @@ class Publish:
|
||||
# the permuted peerlist.
|
||||
return d
|
||||
|
||||
def _do_read(self, ss, peerid, storage_index, shnums, readv):
|
||||
# isolate the callRemote to a separate method, so tests can subclass
|
||||
# Publish and override it
|
||||
d = ss.callRemote("slot_readv", storage_index, shnums, readv)
|
||||
return d
|
||||
|
||||
def _do_query(self, ss, peerid, storage_index):
|
||||
self.log("querying %s" % idlib.shortnodeid_b2a(peerid))
|
||||
d = ss.callRemote("slot_readv",
|
||||
storage_index, [], [(0, self._read_size)])
|
||||
d = self._do_read(ss, peerid, storage_index, [], [(0, self._read_size)])
|
||||
return d
|
||||
|
||||
def _got_query_results(self, datavs, peerid, permutedid,
|
||||
@ -1302,8 +1307,8 @@ class Publish:
|
||||
|
||||
def _do_privkey_query(self, rref, peerid, shnum, offset, length):
|
||||
started = time.time()
|
||||
d = rref.callRemote("slot_readv", self._storage_index,
|
||||
[shnum], [(offset, length)] )
|
||||
d = self._do_read(rref, peerid, self._storage_index,
|
||||
[shnum], [(offset, length)])
|
||||
d.addCallback(self._privkey_query_response, peerid, shnum, started)
|
||||
return d
|
||||
|
||||
|
@ -47,8 +47,9 @@ class FakeFilenode(mutable.MutableFileNode):
|
||||
return defer.succeed(None)
|
||||
|
||||
class FakePublish(mutable.Publish):
|
||||
def _do_query(self, ss, peerid, storage_index):
|
||||
def _do_read(self, ss, peerid, storage_index, shnums, readv):
|
||||
assert ss[0] == peerid
|
||||
assert shnums == []
|
||||
shares = self._peers[peerid]
|
||||
return defer.succeed(shares)
|
||||
|
||||
@ -275,6 +276,7 @@ class Publish(unittest.TestCase):
|
||||
p = FakePublish(fn)
|
||||
p._storage_index = "\x00"*32
|
||||
p._new_seqnum = 3
|
||||
p._read_size = 1000
|
||||
#r = mutable.Retrieve(fn)
|
||||
p._peers = {}
|
||||
for peerid in c._peerids:
|
||||
|
Loading…
Reference in New Issue
Block a user