From: Brian Warner Date: Sun, 3 Dec 2006 03:31:02 +0000 (-0700) Subject: deal with the face that peerids are always binary in tests X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~488 X-Git-Url: https://git.rkrishnan.org/a?a=commitdiff_plain;h=4be4caaf0aff082e09d38eec233f3a28411891a4;p=tahoe-lafs%2Ftahoe-lafs.git deal with the face that peerids are always binary in tests --- diff --git a/allmydata/test/test_upload.py b/allmydata/test/test_upload.py index 8c1bb076..333143b2 100644 --- a/allmydata/test/test_upload.py +++ b/allmydata/test/test_upload.py @@ -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) diff --git a/allmydata/upload.py b/allmydata/upload.py index 08b97c0e..3850b4bb 100644 --- a/allmydata/upload.py +++ b/allmydata/upload.py @@ -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