mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-29 17:28:53 +00:00
A little closer to passing.
This commit is contained in:
parent
dcdce83883
commit
57cda41daa
@ -781,7 +781,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
vk_string = ed25519.string_from_verifying_key(self._node_public_key)
|
vk_string = ed25519.string_from_verifying_key(self._node_public_key)
|
||||||
vk_bytes = remove_prefix(vk_string, ed25519.PUBLIC_KEY_PREFIX)
|
vk_bytes = remove_prefix(vk_string, ed25519.PUBLIC_KEY_PREFIX)
|
||||||
seed = base32.b2a(vk_bytes)
|
seed = base32.b2a(vk_bytes)
|
||||||
self.config.write_config_file("permutation-seed", seed+"\n")
|
self.config.write_config_file("permutation-seed", seed+b"\n", mode="wb")
|
||||||
return seed.strip()
|
return seed.strip()
|
||||||
|
|
||||||
def get_anonymous_storage_server(self):
|
def get_anonymous_storage_server(self):
|
||||||
@ -806,7 +806,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
|
|
||||||
config_storedir = self.get_config(
|
config_storedir = self.get_config(
|
||||||
"storage", "storage_dir", self.STOREDIR,
|
"storage", "storage_dir", self.STOREDIR,
|
||||||
).decode('utf-8')
|
)
|
||||||
storedir = self.config.get_config_path(config_storedir)
|
storedir = self.config.get_config_path(config_storedir)
|
||||||
|
|
||||||
data = self.config.get_config("storage", "reserved_space", None)
|
data = self.config.get_config("storage", "reserved_space", None)
|
||||||
@ -1021,7 +1021,7 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
c = ControlServer()
|
c = ControlServer()
|
||||||
c.setServiceParent(self)
|
c.setServiceParent(self)
|
||||||
control_url = self.control_tub.registerReference(c)
|
control_url = self.control_tub.registerReference(c)
|
||||||
self.config.write_private_config("control.furl", control_url + b"\n")
|
self.config.write_private_config("control.furl", (control_url + "\n").encode("utf-8"))
|
||||||
|
|
||||||
def init_helper(self):
|
def init_helper(self):
|
||||||
self.helper = Helper(self.config.get_config_path("helper"),
|
self.helper = Helper(self.config.get_config_path("helper"),
|
||||||
|
@ -549,8 +549,11 @@ def _convert_tub_port(s):
|
|||||||
:returns: a proper Twisted endpoint string like (`tcp:X`) is `s`
|
:returns: a proper Twisted endpoint string like (`tcp:X`) is `s`
|
||||||
is a bare number, or returns `s` as-is
|
is a bare number, or returns `s` as-is
|
||||||
"""
|
"""
|
||||||
if re.search(r'^\d+$', s):
|
us = s
|
||||||
return "tcp:{}".format(int(s))
|
if isinstance(s, bytes):
|
||||||
|
us = s.decode("utf-8")
|
||||||
|
if re.search(r'^\d+$', us):
|
||||||
|
return "tcp:{}".format(int(us))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,24 +109,24 @@ class StorageClientConfig(object):
|
|||||||
|
|
||||||
:param _Config config: The loaded Tahoe-LAFS node configuration.
|
:param _Config config: The loaded Tahoe-LAFS node configuration.
|
||||||
"""
|
"""
|
||||||
ps = config.get_config("client", "peers.preferred", b"").split(b",")
|
ps = config.get_config("client", "peers.preferred", "").split(",")
|
||||||
preferred_peers = tuple([p.strip() for p in ps if p != b""])
|
preferred_peers = tuple([p.strip() for p in ps if p != ""])
|
||||||
|
|
||||||
enabled_storage_plugins = (
|
enabled_storage_plugins = (
|
||||||
name.strip()
|
name.strip()
|
||||||
for name
|
for name
|
||||||
in config.get_config(
|
in config.get_config(
|
||||||
b"client",
|
"client",
|
||||||
b"storage.plugins",
|
"storage.plugins",
|
||||||
b"",
|
"",
|
||||||
).decode("utf-8").split(u",")
|
).split(",")
|
||||||
if name.strip()
|
if name.strip()
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_plugins = {}
|
storage_plugins = {}
|
||||||
for plugin_name in enabled_storage_plugins:
|
for plugin_name in enabled_storage_plugins:
|
||||||
try:
|
try:
|
||||||
plugin_config = config.items(b"storageclient.plugins." + plugin_name)
|
plugin_config = config.items("storageclient.plugins." + plugin_name)
|
||||||
except NoSectionError:
|
except NoSectionError:
|
||||||
plugin_config = []
|
plugin_config = []
|
||||||
storage_plugins[plugin_name] = dict(plugin_config)
|
storage_plugins[plugin_name] = dict(plugin_config)
|
||||||
@ -264,6 +264,7 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
|
|
||||||
# these two are used in unit tests
|
# these two are used in unit tests
|
||||||
def test_add_rref(self, serverid, rref, ann):
|
def test_add_rref(self, serverid, rref, ann):
|
||||||
|
assert isinstance(serverid, bytes)
|
||||||
s = self._make_storage_server(
|
s = self._make_storage_server(
|
||||||
serverid.decode("ascii"),
|
serverid.decode("ascii"),
|
||||||
{"ann": ann.copy()},
|
{"ann": ann.copy()},
|
||||||
@ -273,6 +274,7 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
self.servers[serverid] = s
|
self.servers[serverid] = s
|
||||||
|
|
||||||
def test_add_server(self, server_id, s):
|
def test_add_server(self, server_id, s):
|
||||||
|
assert isinstance(server_id, bytes)
|
||||||
s.on_status_changed(lambda _: self._got_connection())
|
s.on_status_changed(lambda _: self._got_connection())
|
||||||
self.servers[server_id] = s
|
self.servers[server_id] = s
|
||||||
|
|
||||||
@ -313,6 +315,7 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
{u"ann": ann},
|
{u"ann": ann},
|
||||||
)
|
)
|
||||||
server_id = s.get_serverid()
|
server_id = s.get_serverid()
|
||||||
|
assert isinstance(server_id, bytes)
|
||||||
old = self.servers.get(server_id)
|
old = self.servers.get(server_id)
|
||||||
if old:
|
if old:
|
||||||
if old.get_announcement() == ann:
|
if old.get_announcement() == ann:
|
||||||
@ -335,6 +338,7 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
# almost always be the case for normal runtime).
|
# almost always be the case for normal runtime).
|
||||||
# now we forget about them and start using the new one
|
# now we forget about them and start using the new one
|
||||||
s.setServiceParent(self)
|
s.setServiceParent(self)
|
||||||
|
assert isinstance(server_id, bytes)
|
||||||
self.servers[server_id] = s
|
self.servers[server_id] = s
|
||||||
s.start_connecting(self._trigger_connections)
|
s.start_connecting(self._trigger_connections)
|
||||||
# the descriptor will manage their own Reconnector, and each time we
|
# the descriptor will manage their own Reconnector, and each time we
|
||||||
@ -373,11 +377,13 @@ class StorageFarmBroker(service.MultiService):
|
|||||||
return frozenset(self.servers.values())
|
return frozenset(self.servers.values())
|
||||||
|
|
||||||
def get_nickname_for_serverid(self, serverid):
|
def get_nickname_for_serverid(self, serverid):
|
||||||
|
assert isinstance(serverid, bytes)
|
||||||
if serverid in self.servers:
|
if serverid in self.servers:
|
||||||
return self.servers[serverid].get_nickname()
|
return self.servers[serverid].get_nickname()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_stub_server(self, serverid):
|
def get_stub_server(self, serverid):
|
||||||
|
assert isinstance(serverid, bytes)
|
||||||
if serverid in self.servers:
|
if serverid in self.servers:
|
||||||
return self.servers[serverid]
|
return self.servers[serverid]
|
||||||
# some time before 1.12, we changed "serverid" to be "key_s" (the
|
# some time before 1.12, we changed "serverid" to be "key_s" (the
|
||||||
@ -504,7 +510,7 @@ class _FoolscapStorage(object):
|
|||||||
if isinstance(seed, unicode):
|
if isinstance(seed, unicode):
|
||||||
seed = seed.encode("utf-8")
|
seed = seed.encode("utf-8")
|
||||||
ps = base32.a2b(seed)
|
ps = base32.a2b(seed)
|
||||||
elif re.search(r'^v0-[0-9a-zA-Z]{52}$', server_id):
|
elif re.search(br'^v0-[0-9a-zA-Z]{52}$', server_id):
|
||||||
ps = base32.a2b(server_id[3:])
|
ps = base32.a2b(server_id[3:])
|
||||||
else:
|
else:
|
||||||
log.msg("unable to parse serverid '%(server_id)s as pubkey, "
|
log.msg("unable to parse serverid '%(server_id)s as pubkey, "
|
||||||
|
@ -243,7 +243,7 @@ class UseNode(object):
|
|||||||
[storageclient.plugins.{storage_plugin}]
|
[storageclient.plugins.{storage_plugin}]
|
||||||
{config}
|
{config}
|
||||||
""".format(
|
""".format(
|
||||||
storage_plugin=self.storage_plugin,
|
storage_plugin=self.storage_plugin.decode("ascii"),
|
||||||
config=format_config_items(self.plugin_config),
|
config=format_config_items(self.plugin_config),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -259,8 +259,8 @@ introducer.furl = {furl}
|
|||||||
storage.plugins = {storage_plugin}
|
storage.plugins = {storage_plugin}
|
||||||
{plugin_config_section}
|
{plugin_config_section}
|
||||||
""".format(
|
""".format(
|
||||||
furl=self.introducer_furl,
|
furl=self.introducer_furl.decode("ascii"),
|
||||||
storage_plugin=self.storage_plugin,
|
storage_plugin=self.storage_plugin.decode("ascii"),
|
||||||
node_config=format_config_items(self.node_config),
|
node_config=format_config_items(self.node_config),
|
||||||
plugin_config_section=plugin_config_section,
|
plugin_config_section=plugin_config_section,
|
||||||
)
|
)
|
||||||
|
@ -280,7 +280,7 @@ class PluginMatchedAnnouncement(SyncTestCase):
|
|||||||
configuration is matched and the plugin's storage client is used.
|
configuration is matched and the plugin's storage client is used.
|
||||||
"""
|
"""
|
||||||
plugin_config = {
|
plugin_config = {
|
||||||
b"abc": b"xyz",
|
"abc": "xyz",
|
||||||
}
|
}
|
||||||
plugin_name = b"tahoe-lafs-dummy-v1"
|
plugin_name = b"tahoe-lafs-dummy-v1"
|
||||||
yield self.make_node(
|
yield self.make_node(
|
||||||
@ -293,7 +293,7 @@ class PluginMatchedAnnouncement(SyncTestCase):
|
|||||||
u"service-name": u"storage",
|
u"service-name": u"storage",
|
||||||
u"storage-options": [{
|
u"storage-options": [{
|
||||||
# and this announcement is for a plugin with a matching name
|
# and this announcement is for a plugin with a matching name
|
||||||
u"name": plugin_name,
|
u"name": plugin_name.decode("ascii"),
|
||||||
u"storage-server-FURL": SOME_FURL.decode("ascii"),
|
u"storage-server-FURL": SOME_FURL.decode("ascii"),
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ class PluginMatchedAnnouncement(SyncTestCase):
|
|||||||
u"service-name": u"storage",
|
u"service-name": u"storage",
|
||||||
u"storage-options": [{
|
u"storage-options": [{
|
||||||
# and this announcement is for a plugin with a matching name
|
# and this announcement is for a plugin with a matching name
|
||||||
u"name": plugin_name,
|
u"name": plugin_name.decode("ascii"),
|
||||||
u"storage-server-FURL": SOME_FURL.decode("ascii"),
|
u"storage-server-FURL": SOME_FURL.decode("ascii"),
|
||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user