]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_checker: minor improvement in fake-server setup
authorBrian Warner <warner@lothar.com>
Thu, 17 May 2012 17:50:16 +0000 (10:50 -0700)
committerBrian Warner <warner@lothar.com>
Tue, 22 May 2012 02:49:36 +0000 (19:49 -0700)
This prepares for testing the differences between tubid and pubkey-based
name/longname.

src/allmydata/test/test_checker.py

index 79c12747808a915b42787c09b1e1329a4052daa7..f6e604778b9c15756600c1844a3c2b4f503e1a50 100644 (file)
@@ -5,6 +5,7 @@ from twisted.trial import unittest
 from twisted.internet import defer
 from allmydata import check_results, uri
 from allmydata import uri as tahoe_uri
+from allmydata.util import base32
 from allmydata.web import check_results as web_check_results
 from allmydata.storage_client import StorageFarmBroker, NativeStorageServer
 from allmydata.storage.server import storage_index_to_dir
@@ -22,20 +23,26 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin):
 
     def create_fake_client(self):
         sb = StorageFarmBroker(None, True)
-        for (peerid, nickname) in [("\x00"*20, "peer-0"),
-                                   ("\xff"*20, "peer-f"),
-                                   ("\x11"*20, "peer-11")] :
+        # s.get_name() (the "short description") will be "v0-00000000".
+        # s.get_longname() will include the -long suffix.
+        # s.get_peerid() (i.e. tubid) will be "aaa.." or "777.." or "ceir.."
+        servers = [("v0-00000000-long", "\x00"*20, "peer-0"),
+                   ("v0-ffffffff-long", "\xff"*20, "peer-f"),
+                   ("v0-11111111-long", "\x11"*20, "peer-11")]
+        for (key_s, peerid, nickname) in servers:
+            tubid_b32 = base32.b2a(peerid)
+            furl = "pb://%s@nowhere/fake" % tubid_b32
             ann = { "version": 0,
                     "service-name": "storage",
-                    "anonymous-storage-FURL": "pb://abcde@nowhere/fake",
+                    "anonymous-storage-FURL": furl,
                     "permutation-seed-base32": "",
                     "nickname": unicode(nickname),
                     "app-versions": {}, # need #466 and v2 introducer
                     "my-version": "ver",
                     "oldest-supported": "oldest",
                     }
-            s = NativeStorageServer(peerid, ann)
-            sb.test_add_server(peerid, s)
+            s = NativeStorageServer(key_s, ann)
+            sb.test_add_server(peerid, s) # XXX: maybe use key_s?
         c = FakeClient()
         c.storage_broker = sb
         return c