]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
deal with the face that peerids are always binary in tests
authorBrian Warner <warner@lothar.com>
Sun, 3 Dec 2006 03:31:02 +0000 (20:31 -0700)
committerBrian Warner <warner@lothar.com>
Sun, 3 Dec 2006 03:31:02 +0000 (20:31 -0700)
allmydata/test/test_upload.py
allmydata/upload.py

index 8c1bb0768c1e63eebeedfd34a96e7a1069a0be9b..333143b22454ac834eda20a6970c734a8175253b 100644 (file)
@@ -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)
 
index 08b97c0ec57a953a6b939e5102938ff4ab8dab94..3850b4bbbff739b0077ed87cea3c65983c813b45 100644 (file)
@@ -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