From 4be4caaf0aff082e09d38eec233f3a28411891a4 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Sat, 2 Dec 2006 20:31:02 -0700
Subject: [PATCH] deal with the face that peerids are always binary in tests

---
 allmydata/test/test_upload.py | 9 +++++----
 allmydata/upload.py           | 4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

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
-- 
2.45.2