]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
client.py: create node key even when storage is disabled. Closes #1945.
authorBrian Warner <warner@lothar.com>
Thu, 18 Apr 2013 07:06:55 +0000 (00:06 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 18 Apr 2013 07:06:55 +0000 (00:06 -0700)
Thanks to Leif for the catch!

src/allmydata/client.py
src/allmydata/test/test_client.py

index 4f4745cca9fcf4c73fd68d1a43fbd83a3b4c8001..217a7b47448f145153095f87611c61483032480d 100644 (file)
@@ -134,6 +134,7 @@ class Client(node.Node, pollmixin.PollMixin):
         self.init_introducer_client()
         self.init_stats_provider()
         self.init_secrets()
+        self.init_node_key()
         self.init_storage()
         self.init_control()
         self.helper = None
@@ -209,7 +210,7 @@ class Client(node.Node, pollmixin.PollMixin):
         self.convergence = base32.a2b(convergence_s)
         self._secret_holder = SecretHolder(lease_secret, self.convergence)
 
-    def _maybe_create_node_key(self):
+    def init_node_key(self):
         # we only create the key once. On all subsequent runs, we re-use the
         # existing key
         def _make_key():
@@ -255,8 +256,6 @@ class Client(node.Node, pollmixin.PollMixin):
             return
         readonly = self.get_config("storage", "readonly", False, boolean=True)
 
-        self._maybe_create_node_key()
-
         storedir = os.path.join(self.basedir, self.STOREDIR)
 
         data = self.get_config("storage", "reserved_space", None)
index 61d0860395282d5e781f123d330edb921d94a833..796971b236140ed73e3872212ce90a72eb8c8e22 100644 (file)
@@ -78,6 +78,22 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
         cancel_secret = c.get_cancel_secret()
         self.failUnless(base32.b2a(cancel_secret))
 
+    def test_nodekey_yes_storage(self):
+        basedir = "test_client.Basic.test_nodekey_yes_storage"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                       BASECONFIG)
+        c = client.Client(basedir)
+        self.failUnless(c.get_long_nodeid().startswith("v0-"))
+
+    def test_nodekey_no_storage(self):
+        basedir = "test_client.Basic.test_nodekey_no_storage"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+                       BASECONFIG + "[storage]\n" + "enabled = false\n")
+        c = client.Client(basedir)
+        self.failUnless(c.get_long_nodeid().startswith("v0-"))
+
     def test_reserved_1(self):
         basedir = "client.Basic.test_reserved_1"
         os.mkdir(basedir)