deal with the face that peerids are always binary in tests
This commit is contained in:
parent
6f7095ebb2
commit
4be4caaf0a
|
@ -56,13 +56,14 @@ class FakeClient:
|
|||
if r == "disconnected":
|
||||
self.peers.append(None)
|
||||
else:
|
||||
self.peers.append(FakePeer(peerid, r))
|
||||
self.peers.append(FakePeer(str(peerid), r))
|
||||
|
||||
def permute_peerids(self, key, max_peers):
|
||||
assert max_peers == None
|
||||
return range(len(self.peers))
|
||||
return [str(i) for i in range(len(self.peers))]
|
||||
|
||||
def get_remote_service(self, peerid, name):
|
||||
peer = self.peers[peerid]
|
||||
peer = self.peers[int(peerid)]
|
||||
if not peer:
|
||||
return defer.fail(IndexError("no connection to that peer"))
|
||||
return defer.succeed(peer)
|
||||
|
@ -80,7 +81,7 @@ class NextPeer(unittest.TestCase):
|
|||
]
|
||||
|
||||
def compare_landlords(self, u, c, expected):
|
||||
exp = [(peerid, bucketnum, c.peers[peerid])
|
||||
exp = [(str(peerid), bucketnum, c.peers[peerid])
|
||||
for peerid, bucketnum in expected]
|
||||
self.failUnlessEqual(u.landlords, exp)
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ class FileUploader:
|
|||
|
||||
|
||||
def start(self):
|
||||
if self.debug:
|
||||
print "starting upload"
|
||||
# first step: who should we upload to?
|
||||
|
||||
# maybe limit max_peers to 2*len(self.shares), to reduce memory
|
||||
|
@ -53,6 +55,8 @@ class FileUploader:
|
|||
max_peers = None
|
||||
|
||||
self.permuted = self._peer.permute_peerids(self._verifierid, max_peers)
|
||||
for p in self.permuted:
|
||||
assert isinstance(p, str)
|
||||
# we will shrink self.permuted as we give up on peers
|
||||
self.peer_index = 0
|
||||
self.goodness_points = 0
|
||||
|
|
Loading…
Reference in New Issue